AMQ-7402: Inconsistent synchronization of getters/setters of some classes

Make synchronization consistent or remove it and declare the field volatile.
This commit is contained in:
Pascal Schumacher 2020-02-10 20:31:13 +01:00
parent 6417d62f60
commit 5356893fac
4 changed files with 11 additions and 11 deletions

View File

@ -504,7 +504,7 @@ public class TopicSubscription extends AbstractSubscription {
this.messageEvictionStrategy = messageEvictionStrategy; this.messageEvictionStrategy = messageEvictionStrategy;
} }
public int getMaxProducersToAudit() { public synchronized int getMaxProducersToAudit() {
return maxProducersToAudit; return maxProducersToAudit;
} }
@ -515,7 +515,7 @@ public class TopicSubscription extends AbstractSubscription {
} }
} }
public int getMaxAuditDepth() { public synchronized int getMaxAuditDepth() {
return maxAuditDepth; return maxAuditDepth;
} }

View File

@ -260,7 +260,7 @@ public abstract class AbstractPendingMessageCursor implements PendingMessageCurs
* @return the maxProducersToAudit * @return the maxProducersToAudit
*/ */
@Override @Override
public int getMaxProducersToAudit() { public synchronized int getMaxProducersToAudit() {
return maxProducersToAudit; return maxProducersToAudit;
} }
@ -279,7 +279,7 @@ public abstract class AbstractPendingMessageCursor implements PendingMessageCurs
* @return the maxAuditDepth * @return the maxAuditDepth
*/ */
@Override @Override
public int getMaxAuditDepth() { public synchronized int getMaxAuditDepth() {
return maxAuditDepth; return maxAuditDepth;
} }

View File

@ -19,8 +19,8 @@ package org.apache.activemq.management;
public class SizeStatisticImpl extends StatisticImpl { public class SizeStatisticImpl extends StatisticImpl {
private long count; private long count;
private long maxSize; private volatile long maxSize;
private long minSize; private volatile long minSize;
private long totalSize; private long totalSize;
private SizeStatisticImpl parent; private SizeStatisticImpl parent;
@ -94,21 +94,21 @@ public class SizeStatisticImpl extends StatisticImpl {
/** /**
* @return the maximum size of any step * @return the maximum size of any step
*/ */
public synchronized void setMaxSize(long size) { public void setMaxSize(long size) {
maxSize = size; maxSize = size;
} }
/** /**
* @return the minimum size of any step * @return the minimum size of any step
*/ */
public synchronized long getMinSize() { public long getMinSize() {
return minSize; return minSize;
} }
/** /**
* @return the maximum size of any step * @return the maximum size of any step
*/ */
public synchronized void setMinSize(long size) { public void setMinSize(long size) {
minSize = size; minSize = size;
} }

View File

@ -122,7 +122,7 @@ public class HashIndex<Key,Value> implements Index<Key,Value> {
private Metadata.Marshaller metadataMarshaller = new Metadata.Marshaller(); private Metadata.Marshaller metadataMarshaller = new Metadata.Marshaller();
private HashBin.Marshaller<Key,Value> hashBinMarshaller = new HashBin.Marshaller<Key,Value>(this); 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; private Marshaller<Value> valueMarshaller;
@ -392,7 +392,7 @@ public class HashIndex<Key,Value> implements Index<Key,Value> {
* *
* @param marshaller * @param marshaller
*/ */
public synchronized void setKeyMarshaller(Marshaller<Key> marshaller) { public void setKeyMarshaller(Marshaller<Key> marshaller) {
this.keyMarshaller = marshaller; this.keyMarshaller = marshaller;
} }