-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RequestEvent for RequestEventListener might lost request attributes for async flow #5695
Comments
Could you please share a reproducer? |
@jansupol Attached is the reproducer. |
I was trying your reproducer, but I was unable to reproduce the exactly described behaviour outside of the spring boot environment. What happens is that this is FINISHED event. So at first, Response.close() is called, all the data are wired on the network and after that the FINISHED event is called. By that time, it can be possible (depending on the server implementation) that the data from Request are no longer available, the attributes data are cleared. The issue could be with the Spring injecting the HttpServletRequest, there could be a long way from that servlet to Jersey RequestEvent. Maybe instead of injecting HttpServletRequest by Spring and setting the request attribute, you can try to inject Jersey ContainerRequest and set the property there:
|
As you can see from above screen shot:
Thread A: request will be recycled ( attributes of request will be cleared)
Thread B: try to get request attribute from container request.
(Put breakpoints in 2 threads as above screenshot shows, let thread A go first to reproduce.)
And this is a simple spring boot application with parent: (could happen in older spring boot version)
Not sure if it's a known issue or expected behavior, please have a look.
And from the RequestEvent contract, it supposed to be able to get a stable ContainerRequest rather than a fragile one.
I guess maybe we had a chance to clone/copy the request context somewhere instead of relying underlying tomcat request object.
Thanks in advance!
The text was updated successfully, but these errors were encountered: