[
https://issues.redhat.com/browse/WFLY-13051?page=com.atlassian.jira.plugi...
]
nimo stephan commented on WFLY-13051:
-------------------------------------
Ok I had time to dig into this: The *ManagedScheduledExecutorService ex* can be indeed
cancelled:
{code:java}
ex.cancel(false);{code}
So this works as expected.
By the way, what currently is not supported by the the *ManagedScheduledExecutorService
(*which is an instance of *ScheduledExecutorService)* are the follwoing inherited method:
{code:java}
// Those methods are not supported by ManagedScheduledExecutorService and will throw an
Exception
ex.shutdownNow();
ex.shutdown();
ex.isShutdown();{code}
Having this:
{code:java}
if(scheduler instanceof ScheduledExecutorService) {
log.info("scheduler instanceof ScheduledExecutorService = true");
// throws Exceptions
log.infov("scheduler.isShutdown() = {0}", scheduler.isShutdown());
ScheduledExecutorService impl = (ScheduledExecutorService) scheduler;
// impl.shutdown(); // cannot use this on JEE Envirnoment
}{code}
Throws this:
{code:java}
FLYEE0110: Failed to run scheduled task: java.lang.IllegalStateException: Lifecycle
operation not supported
at org.glassfish.javax.enterprise.concurrent
//org.glassfish.enterprise.concurrent.AbstractManagedExecutorServiceAdapter.isShutdown(AbstractManagedExecutorServiceAdapter.java:45)
{code}
provide setRemoveOnCancelPolicy on ManagedScheduledExecutorService
------------------------------------------------------------------
Key: WFLY-13051
URL:
https://issues.redhat.com/browse/WFLY-13051
Project: WildFly
Issue Type: Enhancement
Components: Concurrency Utilities
Affects Versions: 19.0.0.Beta1
Reporter: nimo stephan
Assignee: Eduardo Martins
Priority: Major
Using
{code:java}
@Resource
private ManagedScheduledExecutorService executor;
{code}
provides no possiblity to setRemoveOnCancelPolicy to true.
A casting within a method:
{code:java}
((ScheduledThreadPoolExecutor) executor).setRemoveOnCancelPolicy(true);
{code}
throws the error:
{code:java}
Caused by: javax.ejb.EJBException: java.lang.ClassCastException: class
org.glassfish.enterprise.concurrent.ManagedScheduledExecutorServiceAdapter cannot be cast
to class java.util.concurrent.ScheduledThreadPoolExecutor
(org.glassfish.enterprise.concurrent.ManagedScheduledExecutorServiceAdapter is in unnamed
module of loader 'org.glassfish.javax.enterprise.concurrent' @a93b7af;
java.util.concurrent.ScheduledThreadPoolExecutor is in module java.base of loader
'bootstrap')
at
org.jboss.as.ejb3@17.0.1.Final//org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:246)
at
org.jboss.as.ejb3@17.0.1.Final//org.jboss.as.ejb3.tx.CMTTxInterceptor.requiresNew(CMTTxInterceptor.java:388)
at
org.jboss.as.ejb3@17.0.1.Final//org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor.processInvocation(LifecycleCMTTxInterceptor.java:68)
{code}
Please provide option to cast or if not possible to add the property
{code:java}
setRemoveOnCancelPolicy()
{code}
within the object ManagedScheduledExecutorService. Because without it, we cannot remove
a task from the queue with "future.cancel(false)".
--
This message was sent by Atlassian Jira
(v8.13.1#813001)