[jboss-jira] [JBoss JIRA] (WFLY-12098) Thread context class loader is wrong for ScheduledExecutorService threads

Paul Pogonyshev (Jira) issues at jboss.org
Mon May 20 12:23:00 EDT 2019


    [ https://issues.jboss.org/browse/WFLY-12098?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13735635#comment-13735635 ] 

Paul Pogonyshev commented on WFLY-12098:
----------------------------------------

When trying to write a workaround, I determined that the problem is that executor services change as an application is being deployed from "broken" (with class loaders that cannot find the application's classes) to correct ones. So, the first calls to executor services were broken, not the subsequent. What changed between 14 and 16 is probably order of some steps in deployment procedure that made our application use ScheduledExecutorService "earlier".

Is there a good way for the application to determine when exactly JNDI lookups return "proper" objects that are correctly initialized for the application's deployment?

> Thread context class loader is wrong for ScheduledExecutorService threads
> -------------------------------------------------------------------------
>
>                 Key: WFLY-12098
>                 URL: https://issues.jboss.org/browse/WFLY-12098
>             Project: WildFly
>          Issue Type: Bug
>          Components: Class Loading
>    Affects Versions: 16.0.0.Final
>            Reporter: Paul Pogonyshev
>            Assignee: Richard Opalka
>            Priority: Major
>
> Tasks submitted to the standard ScheduledExecutorService (JNDI: java:comp/DefaultManagedScheduledExecutorService) are executed in threads with class loader that cannot find application classes. This is a regression in 16.0 compared to 14.0 (haven't tested 15). Tasks submitted to the simple ExecutorService (JNDI: java:comp/DefaultManagedExecutorService) see the correct class loader.
> I.e. if I submit something like
>     () -> { System.out.println (Thread.currentThread ().getContextClassLoader (); }
> to both services (i.e. exactly the same task), I get the following output. For ScheduledExecutorService (wrong):
>     ModuleClassLoader for Module "org.jboss.as.ee" version 16.0.0.Final from local module loader @275710fc (finder: local module finder @525f1e4e (roots: [...]/wildfly/modules,[...]/wildfly/modules/system/layers/base))
> For ExecutorService (as expected):
>     ModuleClassLoader for Module "deployment.[...].war" from Service Module Loader
> Plain ExecutorService sees exactly the same class loader as normal threads in which HTTP request are processed. In version 14.0 this was also true for ScheduledExecutorService.



--
This message was sent by Atlassian Jira
(v7.12.1#712002)


More information about the jboss-jira mailing list