Skip to content

Fix race condition in StandardContext.getServletContext()#994

Open
dsoumis wants to merge 1 commit intoapache:mainfrom
dsoumis:fix-tempdir-issue
Open

Fix race condition in StandardContext.getServletContext()#994
dsoumis wants to merge 1 commit intoapache:mainfrom
dsoumis:fix-tempdir-issue

Conversation

@dsoumis
Copy link
Copy Markdown
Member

@dsoumis dsoumis commented Apr 21, 2026

The context field was not volatile and getServletContext()was not synchronized, allowing concurrent threads to create competing ApplicationContext instances during reload. This could cause the TEMPDIR servlet context attribute to be permanently lost.

The context field was not volatile and getServletContext()was not synchronized, allowing concurrent threads to create competing ApplicationContext instances during reload. This could cause the TEMPDIR servlet context attribute to be permanently lost.
@rmaucher
Copy link
Copy Markdown
Contributor

Ok, I think it makes sense. No need to add weird tests after fixing though, you might as well testing the pattern itself in a generic way at some point.

@dsoumis
Copy link
Copy Markdown
Member Author

dsoumis commented Apr 22, 2026

I think the test adds value to the commit as it acts both as a reproducer and as a resource for anyone inspecting the commit to seamlessly understand what was wrong and fixed. I would keep it if no objections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants