Skip to content

Commit

Permalink
do not cache managedexecutorservice among interceptor calls
Browse files Browse the repository at this point in the history
  • Loading branch information
aubi authored and breakponchito committed May 13, 2022
1 parent cfed537 commit 92a0ab7
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,10 @@
public class AsynchronousInterceptor {
static final Logger log = Logger.getLogger(AsynchronousInterceptor.class.getName());

private ManagedExecutorService mes = null;

@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
if (mes == null) {
String executor = context.getMethod().getAnnotation(Asynchronous.class).executor();
mes = (ManagedExecutorService) new InitialContext().lookup(executor != null ? executor : "java:comp/DefaultManagedExecutorService");
}
String executor = context.getMethod().getAnnotation(Asynchronous.class).executor();
ManagedExecutorService mes = (ManagedExecutorService) new InitialContext().lookup(executor != null ? executor : "java:comp/DefaultManagedExecutorService");
log.fine("AsynchronousInterceptor.intercept");
CompletableFuture<Object> resultFuture = new ManagedCompletableFuture<>(mes);
mes.submit(() -> {
Expand Down

0 comments on commit 92a0ab7

Please sign in to comment.