diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java index 5de876185a..19e9b69f06 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java @@ -53,16 +53,16 @@ public class JDBCSequentialFile implements SequentialFile { private long writePosition = 0; - private Executor executor; + private final Executor executor; - private JDBCSequentialFileFactory fileFactory; + private final JDBCSequentialFileFactory fileFactory; private final Object writeLock; private final JDBCSequentialFileFactoryDriver dbDriver; // Allows DB Drivers to cache meta data. - private Map metaData = new ConcurrentHashMap<>(); + private final Map metaData = new ConcurrentHashMap<>(); public JDBCSequentialFile(final JDBCSequentialFileFactory fileFactory, final String filename, diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactory.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactory.java index b222fd97d3..48d03bffbf 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactory.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactory.java @@ -39,11 +39,11 @@ public class JDBCSequentialFileFactory implements SequentialFileFactory, ActiveM private boolean started; - private List files; + private final List files = new ArrayList<>(); - private Executor executor; + private final Executor executor; - private Map fileLocks = new HashMap<>(); + private final Map fileLocks = new HashMap<>(); private final JDBCSequentialFileFactoryDriver dbDriver; @@ -52,7 +52,6 @@ public class JDBCSequentialFileFactory implements SequentialFileFactory, ActiveM final String tableName, Executor executor) throws Exception { this.executor = executor; - files = new ArrayList<>(); dbDriver = JDBCUtils.getDBFileDriver(dataSource, tableName, sqlProvider); } @@ -61,7 +60,6 @@ public class JDBCSequentialFileFactory implements SequentialFileFactory, ActiveM final SQLProvider sqlProvider, Executor executor) throws Exception { this.executor = executor; - files = new ArrayList<>(); dbDriver = JDBCUtils.getDBFileDriver(className, connectionUrl, sqlProvider); } diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java index d472efa235..924fdc8054 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java @@ -83,7 +83,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { private Map transactions = new ConcurrentHashMap<>(); // Sequence ID for journal records - private AtomicLong seq = new AtomicLong(0); + private final AtomicLong seq = new AtomicLong(0); public JDBCJournalImpl(DataSource dataSource, SQLProvider provider, String tableName, ScheduledExecutorService scheduledExecutorService, Executor completeExecutor) { super(dataSource, provider); diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ThreadAwareContext.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ThreadAwareContext.java index 602704d026..7bdf35cb8b 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ThreadAwareContext.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ThreadAwareContext.java @@ -39,7 +39,7 @@ public class ThreadAwareContext { * Use a set because JMSContext can create more than one JMSConsumer * to receive asynchronously from different destinations. */ - private Set messageListenerThreads = new ConcurrentHashSet<>(); + private final Set messageListenerThreads = new ConcurrentHashSet<>(); /** * Sets current thread to the context diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java index 018e82d423..a29b3ee862 100644 --- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java +++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java @@ -144,13 +144,13 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se private final AtomicBoolean asyncException = new AtomicBoolean(false); // Clebert: Artemis session has meta-data support, perhaps we could reuse it here - private Map sessionIdMap = new ConcurrentHashMap<>(); + private final Map sessionIdMap = new ConcurrentHashMap<>(); private final Map consumerExchanges = new ConcurrentHashMap<>(); private final Map producerExchanges = new ConcurrentHashMap<>(); // Clebert TODO: Artemis already stores the Session. Why do we need a different one here - private Map sessions = new ConcurrentHashMap<>(); + private final Map sessions = new ConcurrentHashMap<>(); private ConnectionState state; @@ -160,7 +160,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se * But always without any association with Sessions. * This collection will hold nonXA transactions. Hopefully while they are in transit only. */ - private Map txMap = new ConcurrentHashMap<>(); + private final Map txMap = new ConcurrentHashMap<>(); private volatile AMQSession advisorySession; diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java index a9057d0a5b..b14effcf88 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java @@ -115,9 +115,9 @@ public class ActiveMQActivation { private ActiveMQConnectionFactory factory; - private List nodes = Collections.synchronizedList(new ArrayList()); + private final List nodes = Collections.synchronizedList(new ArrayList()); - private Map removedNodes = new ConcurrentHashMap<>(); + private final Map removedNodes = new ConcurrentHashMap<>(); private boolean lastReceived = false; diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueDestinationsResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueDestinationsResource.java index 4f66bb9250..2a74a52a89 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueDestinationsResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/queue/QueueDestinationsResource.java @@ -45,8 +45,8 @@ import org.w3c.dom.Document; @Path(Constants.PATH_FOR_QUEUES) public class QueueDestinationsResource { - private Map queues = new ConcurrentHashMap<>(); - private QueueServiceManager manager; + private final Map queues = new ConcurrentHashMap<>(); + private final QueueServiceManager manager; public QueueDestinationsResource(QueueServiceManager manager) { this.manager = manager; diff --git a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicDestinationsResource.java b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicDestinationsResource.java index dda2a0b642..bd3980c3b9 100644 --- a/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicDestinationsResource.java +++ b/artemis-rest/src/main/java/org/apache/activemq/artemis/rest/topic/TopicDestinationsResource.java @@ -46,8 +46,8 @@ import org.w3c.dom.Document; @Path("/topics") public class TopicDestinationsResource { - private Map topics = new ConcurrentHashMap<>(); - private TopicServiceManager manager; + private final Map topics = new ConcurrentHashMap<>(); + private final TopicServiceManager manager; public TopicDestinationsResource(TopicServiceManager manager) { this.manager = manager; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java index bdb17d64a2..ce8b14c05c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java @@ -69,7 +69,7 @@ public class ClusterController implements ActiveMQComponent { private final ActiveMQServer server; - private Map locators = new HashMap<>(); + private final Map locators = new HashMap<>(); private SimpleString defaultClusterConnectionName; @@ -394,7 +394,7 @@ public class ClusterController implements ActiveMQComponent { */ private final class ConnectRunnable implements Runnable { - private ServerLocatorInternal serverLocator; + private final ServerLocatorInternal serverLocator; private ConnectRunnable(ServerLocatorInternal serverLocator) { this.serverLocator = serverLocator; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java index c38e186519..249f60f776 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java @@ -38,7 +38,7 @@ public class ColocatedHAManager implements HAManager { private final ActiveMQServer server; - private Map backupServers = new HashMap<>(); + private final Map backupServers = new HashMap<>(); private boolean started; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumManager.java index 76a5d5e605..72bcb0064b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumManager.java @@ -46,7 +46,7 @@ public final class QuorumManager implements ClusterTopologyListener, ActiveMQCom /** * all the current registered {@link org.apache.activemq.artemis.core.server.cluster.qourum.Quorum}'s */ - private Map quorums = new HashMap<>(); + private final Map quorums = new HashMap<>(); /** * any currently running runnables. @@ -253,7 +253,7 @@ public final class QuorumManager implements ClusterTopologyListener, ActiveMQCom private final class VoteRunnableHolder { - private QuorumVote quorumVote; + private final QuorumVote quorumVote; private final List runnables; private int size; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/LocalGroupingHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/LocalGroupingHandler.java index 60e9ae8d1c..4c62b46e0f 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/LocalGroupingHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/LocalGroupingHandler.java @@ -80,7 +80,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { private ScheduledFuture reaperFuture; - private long reaperPeriod; + private final long reaperPeriod; public LocalGroupingHandler(final ExecutorFactory executorFactory, final ScheduledExecutorService scheduledExecutor, diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java index 9bf084da30..b72d8f6035 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java @@ -293,7 +293,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { private Activation activation; - private Map activationParams = new HashMap<>(); + private final Map activationParams = new HashMap<>(); private final ShutdownOnCriticalErrorListener shutdownOnCriticalIO = new ShutdownOnCriticalErrorListener(); @@ -306,7 +306,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { private boolean scheduledPoolSupplied = false; - private ServiceRegistry serviceRegistry; + private final ServiceRegistry serviceRegistry; private Date startDate; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java index d5862c817a..f449788a2d 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java @@ -227,9 +227,9 @@ public class QueueImpl implements Queue { private final ReusableLatch deliveriesInTransit = new ReusableLatch(0); - private AtomicLong queueRateCheckTime = new AtomicLong(System.currentTimeMillis()); + private final AtomicLong queueRateCheckTime = new AtomicLong(System.currentTimeMillis()); - private AtomicLong messagesAddedSnapshot = new AtomicLong(0); + private final AtomicLong messagesAddedSnapshot = new AtomicLong(0); private ScheduledFuture slowConsumerReaperFuture; @@ -3005,9 +3005,9 @@ public class QueueImpl implements Queue { private final class SlowConsumerReaperRunnable implements Runnable { - private SlowConsumerPolicy policy; - private float threshold; - private long checkPeriod; + private final SlowConsumerPolicy policy; + private final float threshold; + private final long checkPeriod; private SlowConsumerReaperRunnable(long checkPeriod, float threshold, SlowConsumerPolicy policy) { this.checkPeriod = checkPeriod; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManagerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManagerImpl.java index ff72c37111..fd4929ebc6 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManagerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManagerImpl.java @@ -36,7 +36,7 @@ public class ReloadManagerImpl extends ActiveMQScheduledComponent implements Rel private volatile Runnable tick; - private Map registry = new HashMap<>(); + private final Map registry = new HashMap<>(); public ReloadManagerImpl(ScheduledExecutorService scheduledExecutorService, Executor executor, long checkPeriod) { super(scheduledExecutorService, executor, checkPeriod, TimeUnit.MILLISECONDS, false); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/CertificateLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/CertificateLoginModule.java index 232fc6ecba..0037e67363 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/CertificateLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/CertificateLoginModule.java @@ -46,7 +46,7 @@ public abstract class CertificateLoginModule extends PropertiesLoader implements private X509Certificate[] certificates; private String username; - private Set principals = new HashSet<>(); + private final Set principals = new HashSet<>(); /** * Overriding to allow for proper initialization. Standard JAAS. diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/GuestLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/GuestLoginModule.java index a19a5fc6e6..22fdb7efa3 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/GuestLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/GuestLoginModule.java @@ -50,7 +50,7 @@ public class GuestLoginModule implements LoginModule { private Subject subject; private boolean debug; private boolean credentialsInvalidate; - private Set principals = new HashSet<>(); + private final Set principals = new HashSet<>(); private CallbackHandler callbackHandler; private boolean loginSucceeded; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/InVMLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/InVMLoginModule.java index 49bd24fc08..9aa656c59f 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/InVMLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/InVMLoginModule.java @@ -44,7 +44,7 @@ public class InVMLoginModule implements LoginModule { private SecurityConfiguration configuration; private Subject subject; private String user; - private Set principals = new HashSet<>(); + private final Set principals = new HashSet<>(); private CallbackHandler callbackHandler; private boolean loginSucceeded; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java index 942b328270..df5c7d516b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java @@ -82,7 +82,7 @@ public class LDAPLoginModule implements LoginModule { private CallbackHandler handler; private LDAPLoginProperty[] config; private String username; - private Set groups = new HashSet<>(); + private final Set groups = new HashSet<>(); @Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPriorityTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPriorityTest.java index dce42bc03e..3b7e1807d4 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPriorityTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverPriorityTest.java @@ -48,9 +48,9 @@ public class FailoverPriorityTest extends OpenwireArtemisBaseTest { private final HashMap urls = new HashMap<>(); private final List connections = new ArrayList<>(); - private EmbeddedJMS[] servers = new EmbeddedJMS[3]; + private final EmbeddedJMS[] servers = new EmbeddedJMS[3]; private String clientUrl; - private Map params = new HashMap<>(); + private final Map params = new HashMap<>(); @Before public void setUp() throws Exception { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueDuplicatesTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueDuplicatesTest.java index 18c19f5cd8..4588a8eafa 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueDuplicatesTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/usecases/QueueDuplicatesTest.java @@ -118,7 +118,7 @@ public class QueueDuplicatesTest extends TestCase { private class SendingThread extends Thread { - private String subject; + private final String subject; SendingThread(String brokerUrl, String subject) { this.subject = subject; @@ -149,7 +149,7 @@ public class QueueDuplicatesTest extends TestCase { private static class SimpleConsumer implements MessageListener { - private Map msgs = new HashMap<>(); + private final Map msgs = new HashMap<>(); @Override public void onMessage(Message message) {