jersey - Using Server Request and Response filters for ThreadLocal storage in a RestEasy based service -


i working on resteasy based restful service. have filter class serves server request filter server response filter (i.e. implements containerrequestfilter , containerresponsefilter interfaces).

at beginning of request, use filter put object threadlocal. object used resources throughout request. @ end of request, before sending out response, filter removes object threadlocal.

my question is there guarantee the request filter, resource , response filter execute in same thread? there possibility after request filter puts object threadlocal, different thread execute request (and not have access object)?

i sure case saw http://jersey.576304.n2.nabble.com/does-filter-method-of-containerrequestfilter-run-in-resource-method-thread-td7582648.html (official jersey forum) , have doubts.

javax.ws.rs.container.containerrequestcontext.setproperty(...)

and

javax.ws.rs.container.containerrequestcontext.getproperty(...)

are right approach. javadoc states:

in servlet container, properties synchronized servletrequest , expose attributes available in servletrequest. modifications of properties reflected in set of properties of associated servletrequest.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -