[
https://issues.apache.org/jira/browse/WW-5644?focusedWorklogId=1029570&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1029570
]
ASF GitHub Bot logged work on WW-5644:
--------------------------------------
Author: ASF GitHub Bot
Created on: 12/Jul/26 10:34
Start Date: 12/Jul/26 10:34
Worklog Time Spent: 10m
Work Description: lukaszlenart commented on PR #1776:
URL: https://github.com/apache/struts/pull/1776#issuecomment-4950856945
Thanks for the patch, and especially the concurrency regression tests. The
thread-safety problem is real — `StrutsJSONWriter` keeps per-write state on a
shared instance. I'm merging this as the immediate fix.
Longer term I'd rather address it at the lifecycle level in `JSONUtil` (a
fresh instance per operation) rather than per-field `ThreadLocal`s, to avoid
the cleanup contract. Tracked in
[WW-5650](https://issues.apache.org/jira/browse/WW-5650), which will preserve
your regression tests. Appreciate the contribution.
Issue Time Tracking
-------------------
Worklog Id: (was: 1029570)
Time Spent: 0.5h (was: 20m)
> StrutsJSONWriter write state shared across concurrent requests cross-request
> response leakage
> ----------------------------------------------------------------------------------------------
>
> Key: WW-5644
> URL: https://issues.apache.org/jira/browse/WW-5644
> Project: Struts 2
> Issue Type: Bug
> Components: Plugin - JSON
> Affects Versions: 7.2.1
> Environment: Reproducible under concurrent response serialization via
> the default
> "json" result type or JSONInterceptor, no special configuration
> required. JDK 17, Jackson 2.22.0, any Servlet container. Confirmed via
> a 16-thread contention test against a single shared StrutsJSONWriter
> instance (44,646/320,000 corrupted responses observed pre-fix).
> Reporter: Gouri Sankar A
> Priority: Major
> Fix For: 7.3.0
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> JSONUtil's JSONWriter is injected once and reused across every
> concurrent response handled by that JSONResult/JSONInterceptor.
> StrutsJSONWriter kept its output buffer and other per-write state as
> plain instance fields, reset in place at the start of write(). Two
> concurrent write() calls race on that reset: one call's in-progress
> buffer can be wiped and overwritten by a second call before the first
> reads it back, so one request's serialized JSON can be returned as a
> completely different, concurrently-served request's response body —
> exercised by the default json result type on every request.
> Fix: move per-write state into a ThreadLocal-confined object, scoped to
> a single write() call.
> Fixed by: https://github.com/apache/struts/pull/1776
--
This message was sent by Atlassian Jira
(v8.20.10#820010)