hk2166 commented on issue #13593: URL: https://github.com/apache/grails-core/issues/13593#issuecomment-6541088473
I'd like to work on this. It still happens on 7.2.x and 8.0.x. When the filter runs for a forward or an include and finds no Grails web request before it, its `finally` neither restores nor clears anything. So after the forward returns, the completed `GrailsWebRequest` stays in `RequestContextHolder` on that thread, and stays on the request as `org.grails.WEB_REQUEST`. **Proposed fix:** restore exactly what was there before the forward. - Before binding its web request, the filter takes `RequestContextHolder.getRequestAttributes()`. In the `finally` it puts that back, or resets the holder when there was none. - When there was no previous web request, it also removes the `WEB_REQUEST` attribute it stored. Restoring is better than always clearing when the forward comes from a servlet with request attributes of its own bound, such as Spring's `DispatcherServlet`. Today the filter leaves its own web request in their place, because `GrailsWebRequest.lookup` only finds a Grails one. **Tests** in `GrailsWebRequestFilterSpec`, for a forward and an include: - with nothing bound before: the holder is empty afterwards and no attribute is left; - with a Grails web request bound before: it is restored, as today; - with plain Spring `ServletRequestAttributes` bound before: they are restored. I'd target 7.2.x and merge forward. #16604 converts this module to Groovy on a side branch, so I'd keep the change small. @jdaugherty, does that sound right? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
