[
https://issues.apache.org/jira/browse/WW-3576?focusedWorklogId=1048268&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1048268
]
ASF GitHub Bot logged work on WW-3576:
--------------------------------------
Author: ASF GitHub Bot
Created on: 19/Oct/26 12:44
Start Date: 19/Oct/26 12:44
Worklog Time Spent: 10m
Work Description: sonarqubecloud[bot] commented on PR #2042:
URL: https://github.com/apache/struts/pull/2042#issuecomment-6267510401
## [](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=2042)
**Quality Gate passed**
Issues
 [2 New
issues](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=2042&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted
issues](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=2042&issueStatuses=ACCEPTED)
Measures
 [0 Security
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_struts&pullRequest=2042&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [93.6% Coverage on New
Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=2042&metric=new_coverage&view=list)
 [0.0% Duplication on New
Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=2042&metric=new_duplicated_lines_density&view=list)
<!
Issue Time Tracking
-------------------
Worklog Id: (was: 1048268)
Time Spent: 2h 20m (was: 2h 10m)
> SessionMap is not thread-safe
> -----------------------------
>
> Key: WW-3576
> URL: https://issues.apache.org/jira/browse/WW-3576
> Project: Struts 2
> Issue Type: Bug
> Components: Other
> Affects Versions: 2.2.1
> Reporter: Sylvain VeyriƩ
> Assignee: Lukasz Lenart
> Priority: Major
> Fix For: 7.5.0
>
> Time Spent: 2h 20m
> Remaining Estimate: 0h
>
> Searching for a bug after some stress test (Exception on "getAttribute":
> already invalidated session), I reviewed SessionMap.java.
> Following WW-239, SessionMap has been made thread-safe.
> All methods are like this :
> {code:java}
> public void doSomething() {
> if (session == null) {
> return;
> }
>
> synchronized (session) {
> session.doSometing();
> }
> }
> {code}
> For example:
> {code:java}
> public void invalidate() {
> if (session == null) {
> return;
> }
>
> synchronized (session) {
> session.invalidate();
> session = null;
> entries = null;
> }
> }
> {code}
> IMHO this is not thread-safe. With the example of invalidate(), if there is a
> context switch just before the synchronized, the nullity is no more checked.
> If another invalidate() is called at least a NPE can be thrown. There are
> probably other side-effects like my exception problem.
> As now Struts 2 only supports Java 5+, there is two ways to fix it :
> * use a double-check-locking (DCL) and set session "volatile" (easy way)
> * use java.util.concurrent instead of synchronized keyword
> If you agree and choose one of those fixes, I can provide a patch.
> For the moment, I don't know if my bug is resolved if we directly use javax
> session, without this wrapper.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)