Skip to content

Commit

Permalink
[WFLY-4331] clone result & exception of ejb async task part2 handle n…
Browse files Browse the repository at this point in the history
…ull return
  • Loading branch information
bmaxwell committed Mar 4, 2015
1 parent ac18593 commit 84fd498
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ejb3/src/main/java/org/jboss/as/ejb3/remote/LocalEjbReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 84fd498

Please sign in to comment.