cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dhawal (JIRA)" <>
Subject [jira] [Commented] (CXF-7246) PhaseInterceptorChain's Message is not passed to child threads.
Date Tue, 14 Feb 2017 03:54:41 GMT


Dhawal commented on CXF-7246:

Hi Sergey,

I have few possible fixes in mind, mentioned below.. 

1. Write a custom ThreadPoolExecutor which will override the beforeExecute() method in which
we can copy and pass on the Message object to child threads and register this custom ThreadPoolExecutor
in xml for parallel processing.

2. Change Message object in PhaseInterceptorChain from ThreadLocal to InheritableThreadLocal
this automatically pass on the current threads Message object to child threads, but the problem
with this approach is that we cannot use Fixed thread pool executors because the object from
parent to child threads are only passed during thread creation alone, so for subsequent requests/jobs
we might end using older Message object belonging to older request/job

3. Combined approach of #1 and #2 - This is currently the best approach i see, which will
be able to cater all the possible scenarios I can think of right now. Where we can manage
inter-thread message passing. 

I will fix and test the same. Please let me know if you think of any corner case which we
might miss. 

Dhawal Patel

> PhaseInterceptorChain's Message is not passed to child threads. 
> ----------------------------------------------------------------
>                 Key: CXF-7246
>                 URL:
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.6.14
>            Reporter: Dhawal
> Hello,
> We put few information(usually request header information) in Message through RequestHandler
by doing PhaseInterceptorChain.getCurrentMessage.getExchange.put("","");  
> But when we create a new Threads from the thread which brings in request to the controller,
those objects which are put in the Exchange are not available to new threads.  The PhaseInterceptorChain
has Message object which is ThreadLocal so the objects are not available to subsequent threads
which are created, so exploiting parallelism is quite painful once we store something in Exchange
> As a suggestion can we have Message object as optional between ThreadLocal and InheritableThreadLocal
and via a configuration we can set that do we need to make available Message object to child
> Thanks,
> Dhawal Patel

This message was sent by Atlassian JIRA

View raw message