INT-4486: Properly implement stop(Runnable)

JIRA: https://jira.spring.io/browse/INT-4486

The `SmartLifecycle.stop(Runnable callback)` must always call the
`callback` in the end independently of the internal state

* Revise all the `SmartLifecycle` implementations for the proper
`callback` handling

**Cherry-pick to 5.0.x and 4.3.x**
This commit is contained in:
Artem Bilan
2018-06-11 14:29:06 -04:00
committed by Gary Russell
parent eb1efdb0ff
commit 85bc183849
11 changed files with 67 additions and 35 deletions

View File

@@ -375,6 +375,9 @@ public class ConsumerEndpointFactoryBean
if (this.endpoint != null) {
this.endpoint.stop(callback);
}
else {
callback.run();
}
}
@Override

View File

@@ -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.
@@ -247,6 +247,9 @@ public class SourcePollingChannelAdapterFactoryBean implements FactoryBean<Sourc
if (this.adapter != null) {
this.adapter.stop(callback);
}
else {
callback.run();
}
}
@Override

View File

@@ -98,6 +98,9 @@ public abstract class IntegrationFlowAdapter implements IntegrationFlow, SmartLi
if (this.running.getAndSet(false)) {
this.targetIntegrationFlow.stop(callback);
}
else {
callback.run();
}
}
@Override

View File

@@ -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.
@@ -199,6 +199,9 @@ public abstract class AbstractEndpoint extends IntegrationObjectSupport
logger.info("stopped " + this);
}
}
else {
callback.run();
}
}
finally {
this.lifecycleLock.unlock();