You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ma...@apache.org on 2026/10/21 17:30:49 UTC

(activemq) branch activemq-5.19.x updated: [#2436] Fix SizeStatisticImpl.addSize on isEnabled like CountStatisticImpl (#2437) (#2713)

This is an automated email from the ASF dual-hosted git repository.

mattrpav pushed a commit to branch activemq-5.19.x
in repository https://gitbox.apache.org/repos/asf/activemq.git


The following commit(s) were added to refs/heads/activemq-5.19.x by this push:
     new d11bbeb87f [#2436] Fix SizeStatisticImpl.addSize on isEnabled like CountStatisticImpl (#2437) (#2713)
d11bbeb87f is described below

commit d11bbeb87f8239e4208ce2309ba8761c318405cd
Author: Matt Pavlovich <ma...@apache.org>
AuthorDate: Wed Oct 21 13:30:42 2026 -0400

    [#2436] Fix SizeStatisticImpl.addSize on isEnabled like CountStatisticImpl (#2437) (#2713)
    
    (cherry picked from commit e02b104b4d72ac035771e433c2ebbbc604850fee)
---
 .../activemq/management/SizeStatisticImpl.java     | 30 ++++++++++++++--------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/activemq-client/src/main/java/org/apache/activemq/management/SizeStatisticImpl.java b/activemq-client/src/main/java/org/apache/activemq/management/SizeStatisticImpl.java
index 3681083317..6a35740c0f 100644
--- a/activemq-client/src/main/java/org/apache/activemq/management/SizeStatisticImpl.java
+++ b/activemq-client/src/main/java/org/apache/activemq/management/SizeStatisticImpl.java
@@ -52,18 +52,26 @@ public class SizeStatisticImpl extends StatisticImpl {
         return count;
     }
 
-    public synchronized void addSize(long size) {
-        count++;
-        totalSize += size;
-        if (size > maxSize) {
-            maxSize = size;
+    public void addSize(long size) {
+        // Same enabled gate as CountStatisticImpl.increment(): skip the monitor
+        // (and parent propagation) entirely when statistics are disabled —
+        // enabled is a volatile read, so the disabled fast path is contention-free.
+        if (!isEnabled()) {
+            return;
         }
-        if (size < minSize || minSize == 0) {
-            minSize = size;
-        }
-        updateSampleTime();
-        if (parent != null) {
-            parent.addSize(size);
+        synchronized (this) {
+            count++;
+            totalSize += size;
+            if (size > maxSize) {
+                maxSize = size;
+            }
+            if (size < minSize || minSize == 0) {
+                minSize = size;
+            }
+            updateSampleTime();
+            if (parent != null) {
+                parent.addSize(size);
+            }
         }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@activemq.apache.org
For additional commands, e-mail: commits-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact