codeconsole commented on code in PR #16797:
URL: https://github.com/apache/grails-core/pull/16797#discussion_r4418917875
##########
grails-web-common/src/main/groovy/org/grails/web/servlet/mvc/GrailsWebRequest.java:
##########
@@ -495,12 +495,22 @@ public PropertyEditorRegistry getPropertyEditorRegistry()
{
/**
* Looks up the GrailsWebRequest from the current request.
+ * <p>
+ * The web request bound to the current thread wins when it was built with
this very request, so a
+ * task running alongside the request it was started during, which is
bound to a web request of its
+ * own, and the request thread each find their own. Otherwise the web
request stored on the request
+ * is returned, such as for a wrapper of the request, falling back to the
one bound to the thread.
+ *
* @param request The current request
* @return The GrailsWebRequest
*/
public static @Nullable GrailsWebRequest lookup(HttpServletRequest
request) {
+ GrailsWebRequest bound = lookup();
+ if (bound != null && bound.getRequest() == request) {
Review Comment:
Fixed in e9d3b4e2a1. `lookup(request)` now returns the web request bound to
the thread whenever both requests are, or wrap, the same request the container
created, not only when given the very object it was built with. So inside a
task, `lookup(new HttpServletRequestWrapper(currentRequest))` returns the
task's web request, and `params.id` written through it lands in the task's map.
The other direction is covered too: a task bound to a wrapper finds its own web
request from the request that wrapper wraps. A request that wraps a different
container request still finds the web request stored on it.
On the request thread this gives the same answers as before, forwards and
includes included: a forward's wrapper stores its web request on the request it
wraps, so the attribute and the bound web request agree there.
Tests: `a task finds its own web request from a wrapper of its request, so
its params stay its own` is your case, and it fails on b35184a8f8. `a task
given a wrapper of the request finds its own web request from the request it
wraps`, and the two wrapper cases in `GrailsWebRequestSpec` (a wrapper two
deep, and a sibling wrapper of the same request), fail there too.
--
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]