Repository: tomee Updated Branches: refs/heads/master ba30d45dc -> 55a37dc53
OPENEJB-2110 ResponseCodes.JNDI_ERROR can be an exception Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/55a37dc5 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/55a37dc5 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/55a37dc5 Branch: refs/heads/master Commit: 55a37dc53b031eb18c40611f150fbbdb2137d723 Parents: ba30d45 Author: Romain Manni-Bucau <[email protected]> Authored: Fri Mar 13 21:24:35 2015 +0100 Committer: Romain Manni-Bucau <[email protected]> Committed: Fri Mar 13 21:25:15 2015 +0100 ---------------------------------------------------------------------- .../java/org/apache/openejb/client/JNDIContext.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/55a37dc5/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java ---------------------------------------------------------------------- diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java b/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java index 5ef37aa..a38cac6 100644 --- a/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java +++ b/server/openejb-client/src/main/java/org/apache/openejb/client/JNDIContext.java @@ -461,8 +461,17 @@ public class JNDIContext implements InitialContextFactory, Context { case ResponseCodes.JNDI_RUNTIME_EXCEPTION: throw (RuntimeException) res.getResult(); - case ResponseCodes.JNDI_ERROR: - throw (Error) res.getResult(); + case ResponseCodes.JNDI_ERROR: { + Object result = res.getResult(); + if (Error.class.isInstance(result)) { + throw Error.class.cast(result); + } + if (RuntimeException.class.isInstance(result)) { + throw RuntimeException.class.cast(result); + } + final Throwable th = Throwable.class.cast(result); + throw new ClientRuntimeException(th.getMessage(), th); + } default: throw new ClientRuntimeException("Invalid response from server: " + res.getResponseCode());
