You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2023/05/22 16:31:10 UTC
[tomcat] 02/04: Fix concurrency bug in back-port - reported by SpotBugs
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 1b5bfeaf6616cffb62e48f615196a27ca890dd93
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon May 22 17:18:21 2023 +0100
Fix concurrency bug in back-port - reported by SpotBugs
---
java/org/apache/catalina/util/TimeBucketCounter.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/java/org/apache/catalina/util/TimeBucketCounter.java b/java/org/apache/catalina/util/TimeBucketCounter.java
index ef93f51665..2af67de403 100644
--- a/java/org/apache/catalina/util/TimeBucketCounter.java
+++ b/java/org/apache/catalina/util/TimeBucketCounter.java
@@ -88,7 +88,10 @@ public class TimeBucketCounter {
// there is a small chance of a benign data race where we might not count a request or
// two but as a tradeoff in favor of performance we do not synchronize this operation
ai = new AtomicInteger();
- map.putIfAbsent(key, ai);
+ AtomicInteger currentValue = map.putIfAbsent(key, ai);
+ if (currentValue != null) {
+ ai = currentValue;
+ }
}
return ai.incrementAndGet();
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org