DefaultManagedTaskExecutor throws java.lang.UnsupportedOperationException: isShutdown when rejecting tasks #34514
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
I migrated old SpringBoot application running on Websphere Application Server to SpringBoot 3.2.5 running on WebSphere Liberty and I have encountered an issue with DefaultManagedTaskExecutor. I am connecting DefaultManagedTaskExecutor to jndi managedExecutorService defined on Liberty server:
Bean definition:
server.xml
I am then using appTaskExecutor in
@Async
annotation to run periodically scheduled async task. Problem happens when managedExecutorService task queue gets full and starts to reject new tasks. We are handeling such case with our logic triggering on TaskRejectedException throwing from TaskExecutorAdapter. Unfortunatelly this exception will be never thrown, indead we are expiriencing this:The problem lies in impelmentation of TaskRejectedException in executorDescription method method where executorService.isShutdown() gets called which is illegal in jakarta concurrent specification - chapter 3.1.6.1 in case when executorService is not managed by application itself but it is managed on server:
It looks like this behaviour is part of jakarta concurrent specification going all the way back to the first edition of concurrency utilities for Java EE.. I have discussed this topic on StackOverflow and accepted workaround by using JndiObjectFactoryBean exposing only Executor interface via proxy to ConcurrentTaskExecutor, but it is still a workaround. In open liberty ManagedExecutorServiceImpm can be seen isShutdown() implementation and it follows jakarta concurrency specification. To be frank I am not sure what would be the right thing to fix this. In StackOverflow discussion came up an idea to open feature request on jakarta concurrency for a new version specification, but first I would like to open this topic here.
The text was updated successfully, but these errors were encountered: