Skip to content

Commit 7dde315

Browse files
committed
GH-3234 Fix TestChannelBinder subscriber leak on context pause/resume
1 parent 495d7e7 commit 7dde315

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

  • core/spring-cloud-stream-test-binder/src/main/java/org/springframework/cloud/stream/binder/test

core/spring-cloud-stream-test-binder/src/main/java/org/springframework/cloud/stream/binder/test/TestChannelBinder.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ protected MessageProducer createConsumerEndpoint(ConsumerDestination destination
158158
.getChannel();
159159

160160
IntegrationMessageListeningContainer messageListenerContainer = new IntegrationMessageListeningContainer();
161-
IntegrationBinderInboundChannelAdapter adapter = new IntegrationBinderInboundChannelAdapter(
161+
IntegrationBinderInboundChannelAdapter adapter = new IntegrationBinderInboundChannelAdapter(siBinderInputChannel,
162162
messageListenerContainer);
163163

164164
String groupName = StringUtils.hasText(group) ? group : "anonymous";
@@ -228,9 +228,12 @@ private static class IntegrationBinderInboundChannelAdapter
228228

229229
private RecoveryCallback<? extends Object> recoveryCallback;
230230

231-
IntegrationBinderInboundChannelAdapter(
231+
private final SubscribableChannel subscribableChannel;
232+
233+
IntegrationBinderInboundChannelAdapter(SubscribableChannel subscribableChannel,
232234
IntegrationMessageListeningContainer listenerContainer) {
233235
this.listenerContainer = listenerContainer;
236+
this.subscribableChannel = subscribableChannel;
234237
}
235238

236239
// Temporarily unused until DLQ strategy for this binder becomes a requirement
@@ -243,6 +246,12 @@ public void setRetryTemplate(RetryTemplate retryTemplate) {
243246
this.retryTemplate = retryTemplate;
244247
}
245248

249+
@Override
250+
protected void doStop() {
251+
super.doStop();
252+
this.subscribableChannel.unsubscribe(listenerContainer);
253+
}
254+
246255
@Override
247256
protected void onInit() {
248257
if (this.retryTemplate != null) {

0 commit comments

Comments
 (0)