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;
}
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;
}

View File

@ -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;
}

View File

@ -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,21 +94,21 @@ public class SizeStatisticImpl extends StatisticImpl {
/**
* @return the maximum size of any step
*/
public synchronized void setMaxSize(long size) {
public void setMaxSize(long size) {
maxSize = size;
}
/**
* @return the minimum size of any step
*/
public synchronized long getMinSize() {
public long getMinSize() {
return minSize;
}
/**
* @return the maximum size of any step
*/
public synchronized void setMinSize(long size) {
public void setMinSize(long 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 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;
}