From eea619137f997d28f45ffe68cf1e789fb087a407 Mon Sep 17 00:00:00 2001 From: Domenico Francesco Bruscino Date: Mon, 18 Jan 2021 15:51:11 +0100 Subject: [PATCH] ARTEMIS-3073 Improve replication manger NPE logs --- .../impl/journal/JournalStorageManager.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java index 59dcc637f7..735ffcc349 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java @@ -593,7 +593,13 @@ public class JournalStorageManager extends AbstractJournalStorageManager { for (JournalFile jf : journalFiles) { if (!started) return; - replicator.syncJournalFile(jf, type); + + ReplicationManager replicatorInUse = replicator; + if (replicatorInUse == null) { + throw ActiveMQMessageBundle.BUNDLE.replicatorIsNull(); + } + + replicatorInUse.syncJournalFile(jf, type); } } @@ -724,11 +730,13 @@ public class JournalStorageManager extends AbstractJournalStorageManager { SequentialFile seqFile = largeMessagesFactory.createSequentialFile(fileName); if (!seqFile.exists()) continue; - if (replicator != null) { - replicator.syncLargeMessageFile(seqFile, size, id); - } else { + + ReplicationManager replicatorInUse = replicator; + if (replicatorInUse == null) { throw ActiveMQMessageBundle.BUNDLE.replicatorIsNull(); } + + replicatorInUse.syncLargeMessageFile(seqFile, size, id); } } @@ -796,8 +804,14 @@ public class JournalStorageManager extends AbstractJournalStorageManager { for (Map.Entry> entry : pageFilesToSync.entrySet()) { if (!started) return; + + ReplicationManager replicatorInUse = replicator; + if (replicatorInUse == null) { + throw ActiveMQMessageBundle.BUNDLE.replicatorIsNull(); + } + PagingStore store = manager.getPageStore(entry.getKey()); - store.sendPages(replicator, entry.getValue()); + store.sendPages(replicatorInUse, entry.getValue()); } }