tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Johan Compagner <jcompag...@servoy.com>
Subject Re: Context class loader of worker thread got null (using parallelStream)
Date Thu, 30 Nov 2017 11:23:20 GMT
I think tomcat has nothing todo with this.

This is the Threadpool that parallelStream() uses. So this is a problem of
the streaming api of java
The threadpool needs to set the context classloader on its created threads..
So you need to use i think your own ThreadPool, i think that is doable:

https://stackoverflow.com/questions/21163108/custom-thread-pool-in-java-8-parallel-stream/22269778#22269778

On 30 November 2017 at 03:31, Xueheng Wu <xhwu@thoughtworks.com> wrote:

> Hi,
> I met a strange error these days, and need help.
> Our application is running on Tomcat 8.5.11 (windows 10 64bit)with
> JRE 1.8.0_121.
> In the application, we use parallelStream to do some logic, like this:
> There are many steps in the logic, and some of them use togglz, then we
> got error.
>
> After checking togglz’s code, I found that it calls
> “Thread.currentThread().getContextClassLoader()” every times calling
> togglz.
>
> Then I print out context class loader when calling togglz, like this:
> And I find a strange thing. Only *execute thread* has context class
> loader, *worker thread *created by parallelStream got *null* for class
> loader.
> But when it start as an springboot application, all threads has context
> class loader:
> So please tell me why class loader got null and how to avoid it.
> Best regards.
>



-- 
Johan Compagner
Servoy

Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message