https://bz.apache.org/bugzilla/show_bug.cgi?id=64503

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WONTFIX
             Status|NEW                         |RESOLVED

--- Comment #3 from Mark Thomas <ma...@apache.org> ---
Sorry, this is by design.

JNDI relies on the ThreadContextClassLoader (TCCL) being set to correctly
identify the correct JNDI Context for the web application. Tomcat ensures that
threads used to serve requests have the correct TCCL set at the start and also
ensure the TCCL is cleared at the end to avoid memory leaks and potential
security issues.

parallelStream() uses ForkJoinPool/ForkJoinTask which has its own internal
thread pool that has no knowledge of these TCCL requirements.

I'm guessing what you have presented is a simplified test case and the real
problem is rather more complex. You should be able to pass in the correct TCCL
and have the code use it. I am assuming that the additional complexity of
passing and using the TCCL is worth it for the benefit of performing the tasks
in parallel. However be aware that:
- you need to use a try/finally block to ensure the TCCL is reset after use
- depending on your Tomcat settings (defaults should not do this) it may be the
case that ForkJoinPool is using a thread pool that produces threads where you
can't set the TCCL.

Some background you might find interesting:
http://tomcat.markmail.org/thread/7w5wspqeayx7dr5x
http://tomcat.markmail.org/thread/qcy6rqhw52sspyv7

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to