This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new e8cd4d096a Copilot/review commit f206204 (#997)
e8cd4d096a is described below
commit e8cd4d096a11bab4082a39b56999b3518cbe4dfb
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Apr 23 19:30:13 2026 +0200
Copilot/review commit f206204 (#997)
* Fix race condition in ReplicatedContext.getServletContext()
Co-authored-by: copilot-swe-agent[bot]
<[email protected]>
Co-authored-by: markt-asf <[email protected]>
---
java/org/apache/catalina/ha/context/ReplicatedContext.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/java/org/apache/catalina/ha/context/ReplicatedContext.java
b/java/org/apache/catalina/ha/context/ReplicatedContext.java
index c04803d8b5..d292b4890d 100644
--- a/java/org/apache/catalina/ha/context/ReplicatedContext.java
+++ b/java/org/apache/catalina/ha/context/ReplicatedContext.java
@@ -118,9 +118,13 @@ public class ReplicatedContext extends StandardContext
implements MapOwner {
@Override
public ServletContext getServletContext() {
if (context == null) {
- context = new ReplApplContext(this);
- if (getAltDDName() != null) {
- context.setAttribute(Globals.ALT_DD_ATTR, getAltDDName());
+ synchronized (this) {
+ if (context == null) {
+ context = new ReplApplContext(this);
+ if (getAltDDName() != null) {
+ context.setAttribute(Globals.ALT_DD_ATTR,
getAltDDName());
+ }
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]