Author: fmeschbe
Date: Fri Oct  5 05:14:55 2007
New Revision: 582225

URL: http://svn.apache.org/viewvc?rev=582225&view=rev
Log:
FELIX-392 Better handle unexpected issues when trying to get a activation or 
binding method by reflection

Modified:
    
felix/trunk/scr/src/main/java/org/apache/felix/scr/AbstractComponentManager.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/DependencyManager.java

Modified: 
felix/trunk/scr/src/main/java/org/apache/felix/scr/AbstractComponentManager.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/AbstractComponentManager.java?rev=582225&r1=582224&r2=582225&view=diff
==============================================================================
--- 
felix/trunk/scr/src/main/java/org/apache/felix/scr/AbstractComponentManager.java
 (original)
+++ 
felix/trunk/scr/src/main/java/org/apache/felix/scr/AbstractComponentManager.java
 Fri Oct  5 05:14:55 2007
@@ -19,6 +19,7 @@
 package org.apache.felix.scr;
 
 
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
@@ -765,8 +766,11 @@
      *
      * @throws NoSuchMethodException If no public or protected method with
      *      the given name can be found in the class or any of its super 
classes.
+     * @throws InvocationTargetException If an unexpected Throwable is caught
+     *      trying to access the desired method.
      */
-    static Method getMethod( Class clazz, String name, Class[] parameterTypes, 
boolean only ) throws NoSuchMethodException
+    static Method getMethod( Class clazz, String name, Class[] parameterTypes, 
boolean only )
+        throws NoSuchMethodException, InvocationTargetException
     {
         for ( ; clazz != null; clazz = clazz.getSuperclass() )
         {
@@ -791,6 +795,12 @@
             catch ( NoSuchMethodException nsme )
             {
                 // ignore for now
+            }
+            catch ( Throwable throwable )
+            {
+                // unexpected problem accessing the method, don't let 
everything
+                // blow up in this situation, just throw a declared exception
+                throw new InvocationTargetException( throwable, "Unexpected 
problem trying to get method " + name );
             }
         }
 

Modified: 
felix/trunk/scr/src/main/java/org/apache/felix/scr/DependencyManager.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/DependencyManager.java?rev=582225&r1=582224&r2=582225&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/DependencyManager.java 
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/DependencyManager.java 
Fri Oct  5 05:14:55 2007
@@ -663,9 +663,13 @@
      * @param parameterClassName the name of the class of the parameter that is
      *            passed to the method
      * @return the method or null
-     * @throws java.lang.ClassNotFoundException if the class was not found
+     * @throws ClassNotFoundException if the class for parameterClassName 
cannot
+     *      be found.
+     * @throws InvocationTargetException If an unexpected error occurrs trying
+     *      to get the method from the targetClass.
      */
     private Method getBindingMethod( String methodname, Class targetClass, 
String parameterClassName )
+        throws InvocationTargetException
     {
         Class parameterClass = null;
 


Reply via email to