really only log exception in case the default injection was successful
authorKonrad Windszus <kwin@apache.org>
Thu, 8 Dec 2016 13:20:36 +0000 (13:20 +0000)
committerKonrad Windszus <kwin@apache.org>
Thu, 8 Dec 2016 13:20:36 +0000 (13:20 +0000)
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1773228 13f79535-47bb-0310-9956-ffa450edef68

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

index 6dcf209..35024e5 100644 (file)
@@ -483,11 +483,11 @@ public class ModelAdapterFactory implements AdapterFactory, Runnable, ModelFacto
         if (!wasInjectionSuccessful) {
             Result<Boolean> defaultInjectionResult = injectDefaultValue(element, annotationProcessor, callback);
             if (defaultInjectionResult.wasSuccessful()) {
+                wasInjectionSuccessful = defaultInjectionResult.getValue();
                 // log previous injection error, if there was any
-                if (lastInjectionException != null) {
+                if (lastInjectionException != null && wasInjectionSuccessful) {
                     log.debug("Although falling back to default value worked, injection into {} failed because of: " + lastInjectionException.getMessage(), element.getAnnotatedElement(), lastInjectionException);
                 }
-                wasInjectionSuccessful = defaultInjectionResult.getValue();
             } else {
                 return defaultInjectionResult.getThrowable();
             }