diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-26 09:02:53 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-26 09:02:53 +0000 |
commit | 573cd7b4f5b143293a3d44819c17f58cae74a946 (patch) | |
tree | 3c1d80df9b68e34b21dabccfd6bb2fa73799bff2 /java/sca/modules | |
parent | b53ef076f74560e183986dd2d088a30b9757bfd5 (diff) |
TUSCANY-2545: Don't include the exception cause object when return ing and exception response
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@689002 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules')
-rw-r--r-- | java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIService.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIService.java b/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIService.java index 4d5278b49c..25beb58820 100644 --- a/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIService.java +++ b/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIService.java @@ -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 @@ public class RMIService implements ComponentLifecycle { 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; } } |