Author: ssmiweve
Date: 2009-01-03 03:00:18 +0100 (Sat, 03 Jan 2009)
New Revision: 7124

Modified:
   
branches/2.18/data-model-javabean-impl/src/main/java/no/sesat/search/datamodel/BeanDataObjectInvocationHandler.java
Log:
prevent the ClassCastException happening hundreds of times per request

Modified: 
branches/2.18/data-model-javabean-impl/src/main/java/no/sesat/search/datamodel/BeanDataObjectInvocationHandler.java
===================================================================
--- 
branches/2.18/data-model-javabean-impl/src/main/java/no/sesat/search/datamodel/BeanDataObjectInvocationHandler.java
 2008-12-29 13:16:53 UTC (rev 7123)
+++ 
branches/2.18/data-model-javabean-impl/src/main/java/no/sesat/search/datamodel/BeanDataObjectInvocationHandler.java
 2009-01-03 02:00:18 UTC (rev 7124)
@@ -469,16 +469,29 @@
         // try invoking one of our own methods. (Works for example on methods 
declared by the Object class).
 
         Object result = null;
-        try{
-            result = method.invoke(this, args);
 
-        }catch(IllegalAccessException iae){
-            LOG.info(iae.getMessage(), iae);
-        }catch(IllegalArgumentException iae){
-            LOG.debug(iae.getMessage());
-        }catch(InvocationTargetException ite){
-            LOG.info(ite.getMessage(), ite);
+        // a quick optimisation is to check if there's any method at all with 
the same name.
+        final Method[] knownMethods = this.getClass().getMethods();
+        boolean hasSameNameMethod = false;
+        for(Method m : knownMethods){
+            if(m.getName().equals(method.getName())){
+                hasSameNameMethod = true;
+                break;
+            }
         }
+
+        if(hasSameNameMethod){
+            try{
+                result = method.invoke(this, args);
+
+            }catch(IllegalAccessException iae){
+                LOG.info(iae.getMessage(), iae);
+            }catch(IllegalArgumentException iae){
+                LOG.debug(iae.getMessage());
+            }catch(InvocationTargetException ite){
+                LOG.info(ite.getMessage(), ite);
+            }
+        }
         return result;
     }
 

_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits

Reply via email to