From 85bc1838491f46afd8ef1aaa610a114775fa0829 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Mon, 11 Jun 2018 14:29:06 -0400 Subject: [PATCH] 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** --- .../AbstractSubscribableAmqpChannel.java | 5 +++- .../amqp/config/AmqpChannelFactoryBean.java | 14 +++++----- .../config/ConsumerEndpointFactoryBean.java | 3 +++ ...ourcePollingChannelAdapterFactoryBean.java | 5 +++- .../dsl/IntegrationFlowAdapter.java | 3 +++ .../endpoint/AbstractEndpoint.java | 5 +++- ...eTailInboundChannelAdapterFactoryBean.java | 6 ++++- .../jms/SubscribableJmsChannel.java | 21 ++++++++++----- .../jms/config/JmsChannelFactoryBean.java | 5 +++- .../channel/SubscribableRedisChannel.java | 27 +++++++------------ ...logReceivingChannelAdapterFactoryBean.java | 8 +++++- 11 files changed, 67 insertions(+), 35 deletions(-) diff --git a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/channel/AbstractSubscribableAmqpChannel.java b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/channel/AbstractSubscribableAmqpChannel.java index 44191c99ed..b6a406fe5d 100644 --- a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/channel/AbstractSubscribableAmqpChannel.java +++ b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/channel/AbstractSubscribableAmqpChannel.java @@ -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. @@ -234,6 +234,9 @@ abstract class AbstractSubscribableAmqpChannel extends AbstractAmqpChannel this.container.stop(callback); this.declared = false; } + else { + callback.run(); + } } @Override diff --git a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpChannelFactoryBean.java b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpChannelFactoryBean.java index 5b86987dbc..426e542ff9 100644 --- a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpChannelFactoryBean.java +++ b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpChannelFactoryBean.java @@ -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. @@ -66,10 +66,11 @@ import org.springframework.util.StringUtils; * @author Mark Fisher * @author Gary Russell * @author Artem Bilan + * * @since 2.1 */ -public class AmqpChannelFactoryBean extends AbstractFactoryBean implements SmartLifecycle, - DisposableBean, BeanNameAware { +public class AmqpChannelFactoryBean extends AbstractFactoryBean + implements SmartLifecycle, DisposableBean, BeanNameAware { private volatile AbstractAmqpChannel channel; @@ -516,13 +517,14 @@ public class AmqpChannelFactoryBean extends AbstractFactoryBean