tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r689002 - /tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIService.java
Date Tue, 26 Aug 2008 09:02:57 GMT
Author: antelder
Date: Tue Aug 26 02:02:53 2008
New Revision: 689002

URL: http://svn.apache.org/viewvc?rev=689002&view=rev
Log:
TUSCANY-2545: Don't include the exception cause object when return ing and exception response

Modified:
    tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIService.java

Modified: tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIService.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIService.java?rev=689002&r1=689001&r2=689002&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIService.java
(original)
+++ tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIService.java
Tue Aug 26 02:02:53 2008
@@ -19,10 +19,13 @@
 
 package org.apache.tuscany.sca.binding.rmi;
 
+import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.rmi.Remote;
 import java.rmi.server.UnicastRemoteObject;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
 
 import net.sf.cglib.asm.ClassWriter;
 import net.sf.cglib.asm.Constants;
@@ -100,12 +103,26 @@
                 try {
                     return invokeTarget(JavaInterfaceUtil.findOperation(method, serviceInterface.getOperations()),
args);
                 } catch (InvocationTargetException e) {
-                    Throwable cause = e.getCause();
+                    final Throwable cause = e.getCause();
                     for (Class<?> declaredType : method.getExceptionTypes()) {
                         if (declaredType.isInstance(cause)) {
                             throw e;
                         }
                     }
+
+                    if (cause.getCause() != null) {
+                        // TUSCANY-2545: don't inlcude nested cause object
+                        AccessController.doPrivileged(new PrivilegedExceptionAction<Object>()
{
+                            public Object run() throws Exception {
+                                Field field = Throwable.class.getDeclaredField("cause");
+                                field.setAccessible(true);
+                                field.set(cause, null);
+                                field.setAccessible(false);
+                                return null;
+                            }
+                        });
+                    }
+
                     throw cause;
                 }
             }



Mime
View raw message