'Ganesh J' via google-guice
2017-05-13 22:28:47 UTC
Hi
We are using Guice 4.1 in out Jetty based web applications. We are exposing
APIs through jersey 1.19.3. We are using
com.google.inject.servlet.GuiceFilter in our web.xml to intercept all
requests. Now we do have couple of request scopes beans defined. Also we
have within a single request processing flow multiple thread hops: Main
Jetty thread -> FIrst thread -> Second thread. Request scope objects are
injected using Provider to classes that are invoked from second thread. So
to make that work we wrapped the callable submitted to first thread using
ServletScopes.transferRequest. The to transfer scope to second tread we
tried wrapping callable submitted to second thread by
ServletScopes.transferRequest. Now when this is executed the execution is
blocked. When we referred to the javadoc for ServletScopes.transferRequest
"Because request-scoped objects are not typically thread-safe, the callable
returned by this method must not be run on a different thread until the
current request scope has terminated. The returned callable will block
until the current thread has released the request scope."
It is a bit confusing why this is happening only to the second callable.
The argument of thread safety can also be made for the first callable.
We are kind of stuck here. Any suggestions on the right approach to
propagate scope would help immensely here
Thanks
Ganesh
We are using Guice 4.1 in out Jetty based web applications. We are exposing
APIs through jersey 1.19.3. We are using
com.google.inject.servlet.GuiceFilter in our web.xml to intercept all
requests. Now we do have couple of request scopes beans defined. Also we
have within a single request processing flow multiple thread hops: Main
Jetty thread -> FIrst thread -> Second thread. Request scope objects are
injected using Provider to classes that are invoked from second thread. So
to make that work we wrapped the callable submitted to first thread using
ServletScopes.transferRequest. The to transfer scope to second tread we
tried wrapping callable submitted to second thread by
ServletScopes.transferRequest. Now when this is executed the execution is
blocked. When we referred to the javadoc for ServletScopes.transferRequest
"Because request-scoped objects are not typically thread-safe, the callable
returned by this method must not be run on a different thread until the
current request scope has terminated. The returned callable will block
until the current thread has released the request scope."
It is a bit confusing why this is happening only to the second callable.
The argument of thread safety can also be made for the first callable.
We are kind of stuck here. Any suggestions on the right approach to
propagate scope would help immensely here
Thanks
Ganesh
--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice+***@googlegroups.com.
To post to this group, send email to google-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/230a682d-985e-4b10-92a7-fae719cf731d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice+***@googlegroups.com.
To post to this group, send email to google-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/230a682d-985e-4b10-92a7-fae719cf731d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.