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

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


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

commit e02b104b4d72ac035771e433c2ebbbc604850fee
Author: Matt Pavlovich <[email protected]>
AuthorDate: Mon Aug 10 12:40:21 2026 -0500

    [#2436] Fix SizeStatisticImpl.addSize on isEnabled like CountStatisticImpl 
(#2437)
---
 .../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: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to