This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new 3f6d75168d Handle eviction running over a bucket boundary.
3f6d75168d is described below
commit 3f6d75168d65d224f6997ba7b9135e618a15cd37
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Mar 10 09:14:54 2025 +0000
Handle eviction running over a bucket boundary.
Patch by Chenjp
---
java/org/apache/catalina/util/TimeBucketCounterBase.java | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/java/org/apache/catalina/util/TimeBucketCounterBase.java
b/java/org/apache/catalina/util/TimeBucketCounterBase.java
index 4679a41f0a..122a7b02fa 100644
--- a/java/org/apache/catalina/util/TimeBucketCounterBase.java
+++ b/java/org/apache/catalina/util/TimeBucketCounterBase.java
@@ -181,10 +181,17 @@ public abstract class TimeBucketCounterBase {
* long run.
*/
public void periodicEvict() {
- String currentBucketPrefix = String.valueOf(getCurrentBucketPrefix());
+ /*
+ * The implementation of this method assumes that the time taken for
eviction is less than 1 bucket duration.
+ * It is possible that the eviction process starts in one bucket but
finishes in another. Therefore, keys for
+ * the current bucket and the next bucket when the eviction process
starts are excluded from eviction.
+ */
+ long currentBucketIndex = getCurrentBucketPrefix();
+ String currentBucketPrefix = String.valueOf(currentBucketIndex);
+ String nextBucketPrefix = String.valueOf(currentBucketIndex + 1);
ConcurrentHashMap.KeySetView<String,AtomicInteger> keys = map.keySet();
// remove obsolete keys
- keys.removeIf(k -> !k.startsWith(currentBucketPrefix));
+ keys.removeIf(k -> !k.startsWith(currentBucketPrefix) &&
!k.startsWith(nextBucketPrefix));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]