SLING-5389 improve logging in case of errors
authorKonrad Windszus <kwin@apache.org>
Fri, 8 Jan 2016 09:54:05 +0000 (09:54 +0000)
committerKonrad Windszus <kwin@apache.org>
Fri, 8 Jan 2016 09:54:05 +0000 (09:54 +0000)
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1723672 13f79535-47bb-0310-9956-ffa450edef68

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

index 4f0099a..bcb2795 100644 (file)
@@ -185,12 +185,7 @@ public class ModelAdapterFactory implements AdapterFactory, Runnable, ModelFacto
     public <AdapterType> AdapterType getAdapter(Object adaptable, Class<AdapterType> type) {
         Result<AdapterType> result = internalCreateModel(adaptable, type);
         if (!result.wasSuccessfull()) {
-            // treat post-construct and validation exceptions differently, because they are sometimes used for flow-control or validation purposes
-            if (result.getThrowable() instanceof PostConstructException || result.getThrowable() instanceof InvalidModelException) {
-                log.debug("Could not adapt to model", result.getThrowable());
-            } else {
-                log.error("Could not adapt to model", result.getThrowable());
-            }
+            log.warn("Could not adapt to model", result.getThrowable());
             return null;
         } else {
             return result.getValue();
@@ -441,12 +436,7 @@ public class ModelAdapterFactory implements AdapterFactory, Runnable, ModelFacto
             if (defaultInjectionResult.wasSuccessfull()) {
                 // log previous injection error, if there was any
                 if (lastInjectionException != null) {
-                    // treat post-construct and validation exceptions differently, because they are sometimes used for flow-control or validation purposes
-                    if (lastInjectionException instanceof PostConstructException || lastInjectionException instanceof InvalidModelException) {
-                        log.debug("Although falling back to default value worked, injection into {} failed because of: " + lastInjectionException.getMessage(), element.getAnnotatedElement(), lastInjectionException);
-                    } else {
-                        log.warn("Although falling back to default value worked, injection into {} failed because of: " + lastInjectionException.getMessage(), element.getAnnotatedElement(), lastInjectionException);
-                    }
+                    log.debug("Although falling back to default value worked, injection into {} failed because of: " + lastInjectionException.getMessage(), element.getAnnotatedElement(), lastInjectionException);
                 }
                 wasInjectionSuccessful = defaultInjectionResult.getValue();
             } else {