Skip to content
Permalink
Browse files

Fix `SmartLifecycle.stop(Runnable)` usage

* Also remove redundant `stop(Runnable)` implementations which repeat
 a `default` one in the `SmartLifecycle`

**Cherry-pick to 2.1.x & 2.0.x**
  • Loading branch information...
artembilan authored and garyrussell committed Jun 21, 2019
1 parent f1541f4 commit 715d43d5c1bd88d456a8dc78751b64f136181911
@@ -554,12 +554,6 @@ public boolean isAutoStartup() {
return this.autoStartup;
}

@Override
public void stop(Runnable callback) {
stop();
callback.run();
}

@SuppressWarnings("unchecked")
@Override
public void onMessage(Message message, Channel channel) {
@@ -515,6 +515,9 @@ public void stop(Runnable callback) {
if (this.listenerContainer != null) {
this.listenerContainer.stop(callback);
}
else {
callback.run();
}
}

/**
@@ -185,12 +185,6 @@ public void setAutoStartup(boolean autoStartup) {
this.autoStartup = autoStartup;
}

@Override
public void stop(Runnable callback) {
stop();
callback.run();
}

@Override
public void onMessage(Message message) {
if (this.applicationEventPublisher != null) {
@@ -1336,16 +1336,6 @@ public void stop() {
}
}

@Override
public void stop(Runnable callback) {
try {
stop();
}
finally {
callback.run();
}
}

/**
* This method is invoked when the container is stopping.
*/
@@ -260,17 +260,22 @@ public void stop() {
@Override
public void stop(Runnable callback) {
Collection<MessageListenerContainer> containers = getListenerContainers();
AggregatingCallback aggregatingCallback = new AggregatingCallback(containers.size(), callback);
for (MessageListenerContainer listenerContainer : containers) {
try {
listenerContainer.stop(aggregatingCallback);
}
catch (Exception e) {
if (this.logger.isWarnEnabled()) {
this.logger.warn("Failed to stop listener container [" + listenerContainer + "]", e);
if (containers.size() > 0) {
AggregatingCallback aggregatingCallback = new AggregatingCallback(containers.size(), callback);
for (MessageListenerContainer listenerContainer : containers) {
try {
listenerContainer.stop(aggregatingCallback);
}
catch (Exception e) {
if (this.logger.isWarnEnabled()) {
this.logger.warn("Failed to stop listener container [" + listenerContainer + "]", e);
}
}
}
}
else {
callback.run();
}
}

@Override

0 comments on commit 715d43d

Please sign in to comment.
You can’t perform that action at this time.