jamesfredley commented on code in PR #16797:
URL: https://github.com/apache/grails-core/pull/16797#discussion_r4418430837
##########
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:
Inside a decorated task, `GrailsWebRequest.lookup(new
HttpServletRequestWrapper(currentRequest))` fails this identity check and then
reads the `WEB_REQUEST` attribute, which still holds the outer web request.
Writing `params.id` on that result changes the request thread's parameter map
and leaves the task's map unchanged. `DefaultDataBindingSourceCreator` looks up
a request this way before `getParams()`. Treat a wrapper of the task-bound
servlet request as the task's web request, and keep the fallback for a
different request.
--
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]