[hidden email] wrote:
> Author: jaz > Date: Fri May 1 17:47:52 2009 > New Revision: 770771 > > URL: http://svn.apache.org/viewvc?rev=770771&view=rev > Log: > Often thread pools do not clear ThreadLocal, implemented a workaround to handle this Actually, never, until the Thread is shutdown. ThreadLocal is just for storing stuff against a thread-type key. What you want is a PoolThreadLocal, which doesn't exist. I guess I could add code to support the same thing that webslinger does for this case. It would require modifying ControlServlet, JobPoller, and any other pool-like container class, to add a hook to run an AtExit list of hooks. Then, add a utility class that allows for singleton per-thread calls, and at-exit calls when the pool returns the thread for further processing. If this sounds confusing, it's that it's difficult for me to explain, and would just be easier if I add the feature(or otherwise show the code). |
Yeah I'm game for a more definite fix. But what about app server
threads? Andrew On May 1, 2009, at 2:42 PM, Adam Heath <[hidden email]> wrote: > [hidden email] wrote: >> Author: jaz >> Date: Fri May 1 17:47:52 2009 >> New Revision: 770771 >> >> URL: http://svn.apache.org/viewvc?rev=770771&view=rev >> Log: >> Often thread pools do not clear ThreadLocal, implemented a >> workaround to handle this > > Actually, never, until the Thread is shutdown. ThreadLocal is just > for storing stuff against a thread-type key. What you want is a > PoolThreadLocal, which doesn't exist. > > I guess I could add code to support the same thing that webslinger > does for this case. It would require modifying ControlServlet, > JobPoller, and any other pool-like container class, to add a hook to > run an AtExit list of hooks. Then, add a utility class that allows > for singleton per-thread calls, and at-exit calls when the pool > returns the thread for further processing. > > If this sounds confusing, it's that it's difficult for me to explain, > and would just be easier if I add the feature(or otherwise show the > code). |
Adam,
Another option which might be better/easier/less intrusive (or very similar) is to create an single place for storing thread local variables. Like an OFBizThreadLocal class, which extends ThreadLocal. Keep all the variables inside this class, then just tie in ContextFilter (after the final chain.doFilter() call) and in the JobInvoker class calls to OFBizThreadLocal.clear(). What do you think about that? Andrew On May 1, 2009, at 3:00 PM, [hidden email] wrote: > Yeah I'm game for a more definite fix. But what about app server > threads? > > Andrew > > > On May 1, 2009, at 2:42 PM, Adam Heath <[hidden email]> wrote: > >> [hidden email] wrote: >>> Author: jaz >>> Date: Fri May 1 17:47:52 2009 >>> New Revision: 770771 >>> >>> URL: http://svn.apache.org/viewvc?rev=770771&view=rev >>> Log: >>> Often thread pools do not clear ThreadLocal, implemented a >>> workaround to handle this >> >> Actually, never, until the Thread is shutdown. ThreadLocal is just >> for storing stuff against a thread-type key. What you want is a >> PoolThreadLocal, which doesn't exist. >> >> I guess I could add code to support the same thing that webslinger >> does for this case. It would require modifying ControlServlet, >> JobPoller, and any other pool-like container class, to add a hook to >> run an AtExit list of hooks. Then, add a utility class that allows >> for singleton per-thread calls, and at-exit calls when the pool >> returns the thread for further processing. >> >> If this sounds confusing, it's that it's difficult for me to explain, >> and would just be easier if I add the feature(or otherwise show the >> code). |
In reply to this post by Andrew Zeneski-2
[hidden email] wrote:
> Yeah I'm game for a more definite fix. But what about app server threads? At some point, the app server will call into ofbiz code. This code, in all likely hood, is restricted to a few select places(ie, like the ControlServlet is run by a jetty or catalina container). This code is what needs to be modified to run the post-thread cleanup. Any other code that actually *does* maintain it's own thread pool would also be modified with this hook. Have you looked at the Executor framework? |
Administrator
|
In reply to this post by Adam Heath-2
From: "Adam Heath" <[hidden email]> > [hidden email] wrote: >> Author: jaz >> Date: Fri May 1 17:47:52 2009 >> New Revision: 770771 >> >> URL: http://svn.apache.org/viewvc?rev=770771&view=rev >> Log: >> Often thread pools do not clear ThreadLocal, implemented a workaround to handle this > > Actually, never, until the Thread is shutdown. ThreadLocal is just > for storing stuff against a thread-type key. What you want is a > PoolThreadLocal, which doesn't exist. > > I guess I could add code to support the same thing that webslinger > does for this case. It would require modifying ControlServlet, > JobPoller, and any other pool-like container class, to add a hook to > run an AtExit list of hooks. Then, add a utility class that allows > for singleton per-thread calls, and at-exit calls when the pool > returns the thread for further processing. Actually it's very clear! Jacques > If this sounds confusing, it's that it's difficult for me to explain, > and would just be easier if I add the feature(or otherwise show the code). > |
Administrator
|
In reply to this post by Adam Heath-2
From: "Adam Heath" <[hidden email]>
To: <[hidden email]> Sent: Friday, May 01, 2009 10:52 PM Subject: Re: svn commit: r770771 - in /ofbiz/trunk: applications/securityext/src/org/ofbiz/securityext/test/ framework/security/src/org/ofbiz/security/authz/ framework/webapp/src/org/ofbiz/webapp/control/ > [hidden email] wrote: >> Yeah I'm game for a more definite fix. But what about app server threads? > > At some point, the app server will call into ofbiz code. This code, > in all likely hood, is restricted to a few select places(ie, like the > ControlServlet is run by a jetty or catalina container). This code is > what needs to be modified to run the post-thread cleanup. > > Any other code that actually *does* maintain it's own thread pool > would also be modified with this hook. > > Have you looked at the Executor framework? Executor framework : interesting, I was not aware ! Thanks Jacques |
In reply to this post by Adam Heath-2
Yeah, I've always wanted to change the service engine to use that...
On May 1, 2009, at 4:52 PM, Adam Heath wrote: > [hidden email] wrote: >> Yeah I'm game for a more definite fix. But what about app server >> threads? > > At some point, the app server will call into ofbiz code. This code, > in all likely hood, is restricted to a few select places(ie, like the > ControlServlet is run by a jetty or catalina container). This code is > what needs to be modified to run the post-thread cleanup. > > Any other code that actually *does* maintain it's own thread pool > would also be modified with this hook. > > Have you looked at the Executor framework? |
Administrator
|
I think we have currently some issues pending in Jira that would benefit of a such effort (look for Mouawad in Jira)
Jacques From: "Andrew Zeneski" <[hidden email]> > Yeah, I've always wanted to change the service engine to use that... > > On May 1, 2009, at 4:52 PM, Adam Heath wrote: > >> [hidden email] wrote: >>> Yeah I'm game for a more definite fix. But what about app server >>> threads? >> >> At some point, the app server will call into ofbiz code. This code, >> in all likely hood, is restricted to a few select places(ie, like the >> ControlServlet is run by a jetty or catalina container). This code is >> what needs to be modified to run the post-thread cleanup. >> >> Any other code that actually *does* maintain it's own thread pool >> would also be modified with this hook. >> >> Have you looked at the Executor framework? > |
Administrator
|
In reply to this post by Adam Heath-2
Finally not sure why, but I can't find Philippe Mouawad issues in Jira for OFBiz, anyway...
Jacques From: "Jacques Le Roux" <[hidden email]> >I think we have currently some issues pending in Jira that would benefit of a such effort (look for Mouawad in Jira) > > Jacques > > From: "Andrew Zeneski" <[hidden email]> >> Yeah, I've always wanted to change the service engine to use that... >> >> On May 1, 2009, at 4:52 PM, Adam Heath wrote: >> >>> [hidden email] wrote: >>>> Yeah I'm game for a more definite fix. But what about app server >>>> threads? >>> >>> At some point, the app server will call into ofbiz code. This code, >>> in all likely hood, is restricted to a few select places(ie, like the >>> ControlServlet is run by a jetty or catalina container). This code is >>> what needs to be modified to run the post-thread cleanup. >>> >>> Any other code that actually *does* maintain it's own thread pool >>> would also be modified with this hook. >>> >>> Have you looked at the Executor framework? >> |
Free forum by Nabble | Edit this page |