Skip to content

Commit

Permalink
ARTEMIS-2912 Handle NPE due to uninitialized members
Browse files Browse the repository at this point in the history
(cherry picked from commit 69fa4f3)

downstream: ENTMQBR-4194
  • Loading branch information
franz1981 committed Nov 11, 2020
1 parent 460b401 commit 28e5a7e
Showing 1 changed file with 30 additions and 11 deletions.
Expand Up @@ -1081,17 +1081,24 @@ void stop(boolean failoverOnServerShutdown, final boolean criticalIOError, boole
state = SERVER_STATE.STOPPING;

if (criticalIOError) {
// notifications trigger disk IO so we don't want to send any on a critical IO error
managementService.enableNotifications(false);
final ManagementService managementService = this.managementService;
if (managementService != null) {
// notifications trigger disk IO so we don't want to send any on a critical IO error
managementService.enableNotifications(false);
}
}

final FileStoreMonitor fileStoreMonitor = this.fileStoreMonitor;
if (fileStoreMonitor != null) {
fileStoreMonitor.stop();
fileStoreMonitor = null;
this.fileStoreMonitor = null;
}

if (failoverOnServerShutdown) {
activation.sendLiveIsStopping();
final Activation activation = this.activation;
if (activation != null) {
activation.sendLiveIsStopping();
}
}

stopComponent(connectorsService);
Expand All @@ -1105,6 +1112,7 @@ void stop(boolean failoverOnServerShutdown, final boolean criticalIOError, boole
stopComponent(federationManager);
stopComponent(clusterManager);

final RemotingService remotingService = this.remotingService;
if (remotingService != null) {
remotingService.pauseAcceptors();
}
Expand All @@ -1126,7 +1134,10 @@ void stop(boolean failoverOnServerShutdown, final boolean criticalIOError, boole
freezeConnections();
}

activation.postConnectionFreeze();
final Activation activation = this.activation;
if (activation != null) {
activation.postConnectionFreeze();
}

closeAllServerSessions(criticalIOError);

Expand All @@ -1139,6 +1150,7 @@ void stop(boolean failoverOnServerShutdown, final boolean criticalIOError, boole
//
// *************************************************************************************************************

final StorageManager storageManager = this.storageManager;
if (storageManager != null)
storageManager.clearContext();

Expand All @@ -1147,10 +1159,12 @@ void stop(boolean failoverOnServerShutdown, final boolean criticalIOError, boole

stopComponent(backupManager);

try {
activation.preStorageClose();
} catch (Throwable t) {
ActiveMQServerLogger.LOGGER.errorStoppingComponent(t, activation.getClass().getName());
if (activation != null) {
try {
activation.preStorageClose();
} catch (Throwable t) {
ActiveMQServerLogger.LOGGER.errorStoppingComponent(t, activation.getClass().getName());
}
}

stopComponent(pagingManager);
Expand All @@ -1164,6 +1178,7 @@ void stop(boolean failoverOnServerShutdown, final boolean criticalIOError, boole

// We stop remotingService before otherwise we may lock the system in case of a critical IO
// error shutdown
final RemotingService remotingService = this.remotingService;
if (remotingService != null)
try {
remotingService.stop(criticalIOError);
Expand All @@ -1172,6 +1187,7 @@ void stop(boolean failoverOnServerShutdown, final boolean criticalIOError, boole
}

// Stop the management service after the remoting service to ensure all acceptors are deregistered with JMX
final ManagementService managementService = this.managementService;
if (managementService != null)
try {
managementService.unregisterServer();
Expand Down Expand Up @@ -1224,7 +1240,7 @@ void stop(boolean failoverOnServerShutdown, final boolean criticalIOError, boole
messagingServerControl = null;
memoryManager = null;
backupManager = null;
storageManager = null;
this.storageManager = null;

sessions.clear();

Expand Down Expand Up @@ -1321,7 +1337,10 @@ public boolean checkLiveIsNotColocated(String nodeId) {
* {@link #stop(boolean, boolean, boolean)}.
*/
private void freezeConnections() {
activation.freezeConnections(remotingService);
Activation activation = this.activation;
if (activation != null) {
activation.freezeConnections(remotingService);
}

// after disconnecting all the clients close all the server sessions so any messages in delivery will be cancelled back to the queue
for (ServerSession serverSession : sessions.values()) {
Expand Down

0 comments on commit 28e5a7e

Please sign in to comment.