Johan, thanks a lot. This way could be a huge project, because parallelStream is used everywhere. Maybe we got wrong usage from the beginning.
> On 30 Nov 2017, at 19:23, Johan Compagner <jcompag...@servoy.com> wrote: > > 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 > > <https://stackoverflow.com/questions/21163108/custom-thread-pool-in-java-8-parallel-stream/22269778#22269778> > > On 30 November 2017 at 03:31, Xueheng Wu <x...@thoughtworks.com > <mailto:x...@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