Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
10.10-rc-1
-
None
-
Unknown
-
Description
When an asynchronous rendering is cached and its context entries include request.parameters, the cached result is never reused as soon as the request has at least one parameter: the content is computed again on each view, even with exactly the same URL.
Steps to reproduce
- Create a page with the following content:
{{async cached="true" context="request.parameters"}} {{velocity}}$datetool.date{{/velocity}} {{/async}} - View the page with a request parameter, e.g. ?foo=bar
- Reload the same URL
EXPECTED RESULTS: the second view displays the cached result (same date as the first view).
ACTUAL RESULTS: the content is computed again on each view (the date changes).
Without any request parameter the cache works, since the map of parameters is empty.
Cause
DefaultAsyncRendererExecutor#getJobId builds the job id, which is also the key of the cached result, from String.valueOf() of each context entry value. The request.parameters entry is stored as a Map<String, String[]>, and the string representation of a String[] is based on its identity hash code (e.g. [Ljava.lang.String;@1b2c3d), which is different for each request. The same problem affects the request.cookies entry, stored as a Cookie[].
Workaround
Use the request.url context entry instead, which includes the query string and has a stable string representation. Note that the request restored for the asynchronous execution then has no parameters, so they have to be parsed from the URL.
Environment
Observed on XWiki 17.10.15 and 18.4.6 (Tomcat 10.1, MariaDB). The code involved has not changed since it was introduced in XWIKI-15640.
Attachments
Issue Links
- relates to
-
XWIKI-15640 Allow executing UI extensions and panels asynchronously
-
- Closed
-