[activemq] branch activemq-5.15.x updated: AMQ-7402: Inconsistent synchronization of getters/setters of some classes

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[activemq] branch activemq-5.15.x updated: AMQ-7402: Inconsistent synchronization of getters/setters of some classes

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

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


The following commit(s) were added to refs/heads/activemq-5.15.x by this push:
     new 0a0b524  AMQ-7402: Inconsistent synchronization of getters/setters of some classes
0a0b524 is described below

commit 0a0b524c9d1afdc3f14445409613a7474760cfb1
Author: Pascal Schumacher <[hidden email]>
AuthorDate: Mon Feb 10 20:31:13 2020 +0100

    AMQ-7402: Inconsistent synchronization of getters/setters of some classes
   
    Make synchronization consistent or remove it and declare the field volatile.
   
    (cherry picked from commit 5356893fac70d9f67a407d836f8cc8260961b792)
---
 .../java/org/apache/activemq/broker/region/TopicSubscription.java   | 4 ++--
 .../broker/region/cursors/AbstractPendingMessageCursor.java         | 4 ++--
 .../main/java/org/apache/activemq/management/SizeStatisticImpl.java | 6 +++---
 .../java/org/apache/activemq/store/kahadb/disk/index/HashIndex.java | 4 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicSubscription.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicSubscription.java
index 0bf1c4e..6f654a4 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicSubscription.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/TopicSubscription.java
@@ -504,7 +504,7 @@ public class TopicSubscription extends AbstractSubscription {
         this.messageEvictionStrategy = messageEvictionStrategy;
     }
 
-    public int getMaxProducersToAudit() {
+    public synchronized int getMaxProducersToAudit() {
         return maxProducersToAudit;
     }
 
@@ -515,7 +515,7 @@ public class TopicSubscription extends AbstractSubscription {
         }
     }
 
-    public int getMaxAuditDepth() {
+    public synchronized int getMaxAuditDepth() {
         return maxAuditDepth;
     }
 
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/cursors/AbstractPendingMessageCursor.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/cursors/AbstractPendingMessageCursor.java
index dad4a59..20bc061 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/cursors/AbstractPendingMessageCursor.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/cursors/AbstractPendingMessageCursor.java
@@ -260,7 +260,7 @@ public abstract class AbstractPendingMessageCursor implements PendingMessageCurs
      * @return the maxProducersToAudit
      */
     @Override
-    public int getMaxProducersToAudit() {
+    public synchronized int getMaxProducersToAudit() {
         return maxProducersToAudit;
     }
 
@@ -279,7 +279,7 @@ public abstract class AbstractPendingMessageCursor implements PendingMessageCurs
      * @return the maxAuditDepth
      */
     @Override
-    public int getMaxAuditDepth() {
+    public synchronized int getMaxAuditDepth() {
         return maxAuditDepth;
     }
 
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 e2bc033..8df870d 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
@@ -19,8 +19,8 @@ package org.apache.activemq.management;
 public class SizeStatisticImpl extends StatisticImpl {
 
     private long count;
-    private long maxSize;
-    private long minSize;
+    private volatile long maxSize;
+    private volatile long minSize;
     private long totalSize;
     private SizeStatisticImpl parent;
 
@@ -94,7 +94,7 @@ public class SizeStatisticImpl extends StatisticImpl {
     /**
      * @return the minimum size of any step
      */
-    public synchronized long getMinSize() {
+    public long getMinSize() {
         return minSize;
     }
 
diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/index/HashIndex.java b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/index/HashIndex.java
index 7a92f05..df7078e 100644
--- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/index/HashIndex.java
+++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/index/HashIndex.java
@@ -122,7 +122,7 @@ public class HashIndex<Key,Value> implements Index<Key,Value> {
     
     private Metadata.Marshaller metadataMarshaller = new Metadata.Marshaller();
     private HashBin.Marshaller<Key,Value> hashBinMarshaller = new HashBin.Marshaller<Key,Value>(this);
-    private Marshaller<Key> keyMarshaller;
+    private volatile Marshaller<Key> keyMarshaller;
     private Marshaller<Value> valueMarshaller;
 
     
@@ -392,7 +392,7 @@ public class HashIndex<Key,Value> implements Index<Key,Value> {
      *
      * @param marshaller
      */
-    public synchronized void setKeyMarshaller(Marshaller<Key> marshaller) {
+    public void setKeyMarshaller(Marshaller<Key> marshaller) {
         this.keyMarshaller = marshaller;
     }