From 84fd49839be7140d4307810f46a208691fea2dc3 Mon Sep 17 00:00:00 2001 From: bmaxwell Date: Tue, 10 Feb 2015 17:58:16 -0600 Subject: [PATCH] [WFLY-4331] clone result & exception of ejb async task part2 handle null return --- .../jboss/as/ejb3/remote/LocalEjbReceiver.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ejb3/src/main/java/org/jboss/as/ejb3/remote/LocalEjbReceiver.java b/ejb3/src/main/java/org/jboss/as/ejb3/remote/LocalEjbReceiver.java index 22009ca66081..cdca095d6b5e 100644 --- a/ejb3/src/main/java/org/jboss/as/ejb3/remote/LocalEjbReceiver.java +++ b/ejb3/src/main/java/org/jboss/as/ejb3/remote/LocalEjbReceiver.java @@ -30,6 +30,7 @@ import java.security.PrivilegedExceptionAction; import java.util.Collections; import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -226,10 +227,18 @@ protected Object runInvocation() throws Exception { setSecurityContextOnAssociation(securityContext); try { Object result = view.invoke(interceptorContext); + // if the result is null, there is no cloning needed + if(result == null) { + return result; + } // WFLY-4331 - clone the result of an async task - if(result instanceof AsyncResult) { - Object asyncValue = ((AsyncResult)result).get(); - return new AsyncResult(LocalEjbReceiver.clone(asyncValue.getClass(), resultCloner, asyncValue, allowPassByReference)); + if(result instanceof Future) { + Object asyncValue = ((Future)result).get(); + // if the return value is null, there is no cloning needed + if(asyncValue == null) { + return asyncValue; + } + return new AsyncResult(LocalEjbReceiver.clone(asyncValue.getClass(), resultCloner, asyncValue, allowPassByReference)); } return LocalEjbReceiver.clone(result.getClass(), resultCloner, result, allowPassByReference); } catch(ExecutionException e) {