Author: sseifert
Date: Thu Oct 16 16:10:16 2014
New Revision: 1632374

URL: http://svn.apache.org/r1632374
Log:
SLING-4042 make sure dependency injection is continued even if not all 
injections succeeded, and report root cause of invocation target exceptions

Modified:
    
sling/trunk/testing/mocks/osgi-mock/src/main/java/org/apache/sling/testing/mock/osgi/ReflectionServiceUtil.java

Modified: 
sling/trunk/testing/mocks/osgi-mock/src/main/java/org/apache/sling/testing/mock/osgi/ReflectionServiceUtil.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/testing/mocks/osgi-mock/src/main/java/org/apache/sling/testing/mock/osgi/ReflectionServiceUtil.java?rev=1632374&r1=1632373&r2=1632374&view=diff
==============================================================================
--- 
sling/trunk/testing/mocks/osgi-mock/src/main/java/org/apache/sling/testing/mock/osgi/ReflectionServiceUtil.java
 (original)
+++ 
sling/trunk/testing/mocks/osgi-mock/src/main/java/org/apache/sling/testing/mock/osgi/ReflectionServiceUtil.java
 Thu Oct 16 16:10:16 2014
@@ -85,7 +85,7 @@ final class ReflectionServiceUtil {
                         + targetClass.getName(), ex);
             } catch (InvocationTargetException ex) {
                 throw new RuntimeException("Unable to invoke 
activate/deactivate method for class "
-                        + targetClass.getName(), ex);
+                        + targetClass.getName(), ex.getCause());
             }
         }
         log.warn("Method {}(ComponentContext) not found in class {}", 
methodName, targetClass.getName());
@@ -119,7 +119,8 @@ final class ReflectionServiceUtil {
         // try to inject services
         boolean allInjected = true;
         for (Reference reference : references) {
-            allInjected = allInjected && injectServiceReference(reference, 
target, bundleContext);
+            boolean injectSuccess = injectServiceReference(reference, target, 
bundleContext);
+            allInjected = allInjected && injectSuccess;
         }
         return allInjected;
     }
@@ -179,7 +180,7 @@ final class ReflectionServiceUtil {
                                 + targetClass.getName(), ex);
                     } catch (InvocationTargetException ex) {
                         throw new RuntimeException("Unable to invoke method " 
+ bindMethodName + " for class "
-                                + targetClass.getName(), ex);
+                                + targetClass.getName(), ex.getCause());
                     }
                 }
                 return true;
@@ -200,7 +201,7 @@ final class ReflectionServiceUtil {
                                     + targetClass.getName(), ex);
                         } catch (InvocationTargetException ex) {
                             throw new RuntimeException("Unable to invoke 
method " + bindMethodName + " for class "
-                                    + targetClass.getName(), ex);
+                                    + targetClass.getName(), ex.getCause());
                         }
                     }
                     return true;
@@ -221,7 +222,7 @@ final class ReflectionServiceUtil {
                                             + " for class " + 
targetClass.getName(), ex);
                                 } catch (InvocationTargetException ex) {
                                     throw new RuntimeException("Unable to 
invoke method " + bindMethodName
-                                            + " for class " + 
targetClass.getName(), ex);
+                                            + " for class " + 
targetClass.getName(), ex.getCause());
                                 }
                             }
                         }


Reply via email to