This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push:
new cf36be12dc Use an dedicated lock
cf36be12dc is described below
commit cf36be12dc8abd223b1c2dbe621e4e5d6087303d
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 27930045d9..3c11056f57 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]