commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jcar...@apache.org
Subject svn commit: r278903 - /jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/interceptor/ExecutorMethodInterceptor.java
Date Tue, 06 Sep 2005 03:40:11 GMT
Author: jcarman
Date: Mon Sep  5 20:40:08 2005
New Revision: 278903

URL: http://svn.apache.org/viewcvs?rev=278903&view=rev
Log:
Added special case for finalize() method.

Modified:
    jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/interceptor/ExecutorMethodInterceptor.java

Modified: jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/interceptor/ExecutorMethodInterceptor.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/interceptor/ExecutorMethodInterceptor.java?rev=278903&r1=278902&r2=278903&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/interceptor/ExecutorMethodInterceptor.java
(original)
+++ jakarta/commons/sandbox/proxy/trunk/src/java/org/apache/commons/proxy/interceptor/ExecutorMethodInterceptor.java
Mon Sep  5 20:40:08 2005
@@ -22,10 +22,12 @@
 
 /**
  * A method interceptor that uses an {@link Executor} to execute the method invocation.
- * <p />
- * <b>Note</b>: Only <em>void</em> methods can be intercepted using
this class!  Any attempts to intercept
- * non-void methods will result in an {@link IllegalArgumentException}.  If the proxy interfaces
include non-void
- * methods, try using a {@link FilteredMethodInterceptor} along with a {@link org.apache.commons.proxy.interceptor.filter.ReturnTypeFilter}
to wrap an instance of this class.
+ * <p/>
+ * <b>Note</b>: Only <em>void</em> methods can be intercepted using
this class!  Any attempts to intercept non-void
+ * methods will result in an {@link IllegalArgumentException}.  If the proxy interfaces include
non-void methods, try
+ * using a {@link FilteredMethodInterceptor} along with a {@link org.apache.commons.proxy.interceptor.filter.ReturnTypeFilter}
+ * to wrap an instance of this class.
+ *
  * @author James Carman
  * @version 1.0
  */
@@ -42,21 +44,30 @@
     {
         if( Void.TYPE.equals( methodInvocation.getMethod().getReturnType() ) )
         {
-            executor.execute( new Runnable()
+            // Special case for finalize() method (should not be run in a different thread...
+            if( !( methodInvocation.getMethod().getName().equals( "finalize" ) &&
+                   methodInvocation.getMethod().getParameterTypes().length == 0 ) )
             {
-                public void run()
+                executor.execute( new Runnable()
                 {
-                    try
+                    public void run()
                     {
-                        methodInvocation.proceed();
+                        try
+                        {
+                            methodInvocation.proceed();
+                        }
+                        catch( Throwable t )
+                        {
+                            getLog().error( "Method invocation threw an exception.", t );
+                        }
                     }
-                    catch( Throwable t )
-                    {
-                        getLog().error( "Method invocation threw an exception.", t );
-                    }
-                }
-            } );
-            return null;
+                } );
+                return null;
+            }
+            else
+            {
+                return methodInvocation.proceed();
+            }
         }
         else
         {



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message