SLING-5389 - also log injection exceptions with level debug in case the injection...
authorKonrad Windszus <kwin@apache.org>
Fri, 8 Jan 2016 10:00:18 +0000 (10:00 +0000)
committerKonrad Windszus <kwin@apache.org>
Fri, 8 Jan 2016 10:00:18 +0000 (10:00 +0000)
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1723673 13f79535-47bb-0310-9956-ffa450edef68

src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java

index bcb2795..983fc26 100644 (file)
@@ -447,6 +447,10 @@ public class ModelAdapterFactory implements AdapterFactory, Runnable, ModelFacto
         // if default is not set, check if mandatory
         if (!wasInjectionSuccessful) {
             if (element.isOptional(annotationProcessor)) {
+                // log previous injection error, if there was any
+                if (lastInjectionException != null) {
+                    log.debug("Injection into optional element {} failed because of: " + lastInjectionException.getMessage(), element.getAnnotatedElement(), lastInjectionException);
+                }
                 if (element.isPrimitive()) {
                     RuntimeException throwable = injectPrimitiveInitialValue(element, callback);
                     if (throwable != null) {