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 a8c2974006 Use an dedicated lock
a8c2974006 is described below
commit a8c2974006a420ad24f1691556a6e6ada4b9c17b
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Oct 23 22:03:09 2026 +0100
Use an dedicated lock
---
java/org/apache/catalina/util/RateLimiterBase.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/java/org/apache/catalina/util/RateLimiterBase.java
b/java/org/apache/catalina/util/RateLimiterBase.java
index d34cab576f..43adde0885 100644
--- a/java/org/apache/catalina/util/RateLimiterBase.java
+++ b/java/org/apache/catalina/util/RateLimiterBase.java
@@ -45,8 +45,9 @@ public abstract class RateLimiterBase implements RateLimiter {
int actualDuration;
// Initial policy name can be rewritten by setPolicyName(). Lazily
initialized in getPolicyName() with the
- // object monitor guarding the auto-generation, so the field itself is
volatile for safe publication.
+ // policyNameLock guarding the auto-generation, so the field itself is
volatile for safe publication.
private volatile String policyName;
+ private final Object policyNameLock = new Object();
/*
* The self-owned utility executor, will be instantiated only when
ScheduledThreadPoolExecutor is absent during
@@ -67,7 +68,7 @@ public abstract class RateLimiterBase implements RateLimiter {
public String getPolicyName() {
String name = policyName;
if (name == null) {
- synchronized (this) {
+ synchronized (policyNameLock) {
name = policyName;
if (name == null) {
name = getDefaultPolicyName() + "-" +
index.incrementAndGet();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]