Consistent volatile access to running flag in Lifecycle implementations
Issue: SPR-16488
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -111,10 +111,10 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
|
||||
@Nullable
|
||||
private MessageHeaderInitializer headerInitializer;
|
||||
|
||||
private final Object lifecycleMonitor = new Object();
|
||||
|
||||
private volatile boolean running = false;
|
||||
|
||||
private final Object lifecycleMonitor = new Object();
|
||||
|
||||
|
||||
/**
|
||||
* Create an instance of SimpAnnotationMethodMessageHandler with the given
|
||||
@@ -299,9 +299,7 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
|
||||
|
||||
@Override
|
||||
public final boolean isRunning() {
|
||||
synchronized (this.lifecycleMonitor) {
|
||||
return this.running;
|
||||
}
|
||||
return this.running;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -156,9 +156,7 @@ public abstract class AbstractBrokerMessageHandler
|
||||
@Override
|
||||
public void start() {
|
||||
synchronized (this.lifecycleMonitor) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Starting...");
|
||||
}
|
||||
logger.info("Starting...");
|
||||
this.clientInboundChannel.subscribe(this);
|
||||
this.brokerChannel.subscribe(this);
|
||||
if (this.clientInboundChannel instanceof InterceptableChannel) {
|
||||
@@ -176,9 +174,7 @@ public abstract class AbstractBrokerMessageHandler
|
||||
@Override
|
||||
public void stop() {
|
||||
synchronized (this.lifecycleMonitor) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Stopping...");
|
||||
}
|
||||
logger.info("Stopping...");
|
||||
stopInternal();
|
||||
this.clientInboundChannel.unsubscribe(this);
|
||||
this.brokerChannel.unsubscribe(this);
|
||||
@@ -209,9 +205,7 @@ public abstract class AbstractBrokerMessageHandler
|
||||
*/
|
||||
@Override
|
||||
public final boolean isRunning() {
|
||||
synchronized (this.lifecycleMonitor) {
|
||||
return this.running;
|
||||
}
|
||||
return this.running;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -67,10 +67,10 @@ public class UserDestinationMessageHandler implements MessageHandler, SmartLifec
|
||||
@Nullable
|
||||
private MessageHeaderInitializer headerInitializer;
|
||||
|
||||
private final Object lifecycleMonitor = new Object();
|
||||
|
||||
private volatile boolean running = false;
|
||||
|
||||
private final Object lifecycleMonitor = new Object();
|
||||
|
||||
|
||||
/**
|
||||
* Create an instance with the given client and broker channels subscribing
|
||||
@@ -185,9 +185,7 @@ public class UserDestinationMessageHandler implements MessageHandler, SmartLifec
|
||||
|
||||
@Override
|
||||
public final boolean isRunning() {
|
||||
synchronized (this.lifecycleMonitor) {
|
||||
return this.running;
|
||||
}
|
||||
return this.running;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user