Skip to content

Commit

Permalink
Modify WELD-1234 fix to avoid calling SessionObjectReference.isRemove…
Browse files Browse the repository at this point in the history
…d() on every invocation.
  • Loading branch information
pferraro committed Jul 3, 2023
1 parent c538ec4 commit 846c02a
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Set;

import jakarta.ejb.EJBException;
import jakarta.ejb.NoSuchEJBException;

import org.jboss.weld.annotated.enhanced.MethodSignature;
import org.jboss.weld.annotated.enhanced.jlr.MethodSignatureImpl;
Expand Down Expand Up @@ -123,17 +124,21 @@ public Object invoke(Object self, Method method, Method proceed, Object[] args)
throw BeanLogger.LOG.invalidRemoveMethodInvocation(method);
}
Class<?> businessInterface = getBusinessInterface(method);
if (reference.isRemoved() && isToStringMethod(method)) {
return businessInterface.getName() + " [REMOVED]";
}
Object proxiedInstance = reference.getBusinessObject(businessInterface);

if (!Modifier.isPublic(method.getModifiers())) {
throw new EJBException("Not a business method " + method.toString() +". Do not call non-public methods on EJB's.");
}
Object returnValue = Reflections.invokeAndUnwrap(proxiedInstance, method, args);
BeanLogger.LOG.callProxiedMethod(method, proxiedInstance, args, returnValue);
return returnValue;
try {
Object returnValue = Reflections.invokeAndUnwrap(proxiedInstance, method, args);
BeanLogger.LOG.callProxiedMethod(method, proxiedInstance, args, returnValue);
return returnValue;
} catch (NoSuchEJBException e) {
if (isToStringMethod(method)) {
return businessInterface.getName() + " [REMOVED]";
}
throw e;
}
}

private boolean isRemoveMethod(Method method) {
Expand Down

0 comments on commit 846c02a

Please sign in to comment.