Cancel cleaner future in doClose() rather than doStop()

Original commit: elastic/x-pack-elasticsearch@39ca253b31
This commit is contained in:
Tanguy Leroux 2016-04-04 19:11:12 +02:00
parent 7ea2a4da9d
commit 192e0cd582
1 changed files with 4 additions and 4 deletions

View File

@ -65,14 +65,14 @@ public class CleanerService extends AbstractLifecycleComponent<CleanerService> {
protected void doStop() { protected void doStop() {
logger.debug("stopping cleaning service"); logger.debug("stopping cleaning service");
listeners.clear(); listeners.clear();
runnable.cancel();
logger.debug("cleaning service stopped"); logger.debug("cleaning service stopped");
} }
@Override @Override
protected void doClose() { protected void doClose() {
// Cleaner runnable should have been cancelled in doStop() method, logger.debug("closing cleaning service");
// normally called just before this one runnable.cancel();
logger.debug("cleaning service closed");
} }
private String executorName() { private String executorName() {
@ -220,7 +220,7 @@ public class CleanerService extends AbstractLifecycleComponent<CleanerService> {
* stopped. * stopped.
*/ */
public void cancel() { public void cancel() {
if (future.isCancelled() == false) { if (future != null && future.isCancelled() == false) {
FutureUtils.cancel(future); FutureUtils.cancel(future);
} }
} }