Skip to content
Permalink
Browse files

WFLY-11866 Exception can not be passed-by-reference

https://issues.jboss.org/browse/WFLY-11866 is a regression of WFLY-2949.

Exceptions are not passed-by-reference if enabled, this cause issues if the Exception is not marked as Serializable.
  • Loading branch information
wfink committed Mar 19, 2019
1 parent 1e89028 commit da74e8dfa11a48e1f8b1f434af473bf3db85e6f6
Showing with 7 additions and 5 deletions.
  1. +7 −5 ejb3/src/main/java/org/jboss/as/ejb3/remote/LocalEjbReceiver.java
@@ -204,7 +204,7 @@ protected void processInvocation(final EJBReceiverInvocationContext receiverCont
result = view.invoke(interceptorContext);
} catch (Exception e) {
// WFLY-4331 - clone the exception of an async task
receiverContext.resultReady(new CloningExceptionProducer(resultCloner, e));
receiverContext.resultReady(new CloningExceptionProducer(resultCloner, e, allowPassByReference));
return;
}
// if the result is null, there is no cloning needed
@@ -225,7 +225,7 @@ protected void processInvocation(final EJBReceiverInvocationContext receiverCont
intr = true;
} catch (ExecutionException e) {
// WFLY-4331 - clone the exception of an async task
receiverContext.resultReady(new CloningExceptionProducer(resultCloner, e));
receiverContext.resultReady(new CloningExceptionProducer(resultCloner, e, allowPassByReference));
return;
}
} finally {
@@ -267,7 +267,7 @@ protected void processInvocation(final EJBReceiverInvocationContext receiverCont
} catch (Exception e) {
//we even have to clone the exception type
//to make sure it matches
receiverContext.resultReady(new CloningExceptionProducer(resultCloner, e));
receiverContext.resultReady(new CloningExceptionProducer(resultCloner, e, allowPassByReference));
return;
}
receiverContext.resultReady(new CloningResultProducer(invocation, resultCloner, result, allowPassByReference));
@@ -309,14 +309,16 @@ public void discardResult() {
static final class CloningExceptionProducer implements EJBReceiverInvocationContext.ResultProducer {
private final ObjectCloner resultCloner;
private final Exception exception;
private final boolean allowPassByReference;

CloningExceptionProducer(final ObjectCloner resultCloner, final Exception exception) {
CloningExceptionProducer(final ObjectCloner resultCloner, final Exception exception, final boolean allowPassByReference) {
this.resultCloner = resultCloner;
this.exception = exception;
this.allowPassByReference = allowPassByReference;
}

public Object getResult() throws Exception {
throw (Exception) LocalEjbReceiver.clone(resultCloner, exception);
throw (Exception) LocalEjbReceiver.clone(Exception.class, resultCloner, exception, allowPassByReference);
}

public void discardResult() {

0 comments on commit da74e8d

Please sign in to comment.
You can’t perform that action at this time.