From e908de1dfdf9cbcb2640b9da25b6a6c5870c7790 Mon Sep 17 00:00:00 2001 From: Soby Chacko Date: Tue, 12 Dec 2023 21:14:11 -0500 Subject: [PATCH] GH-2870: Issues when closing multi-binder contexts - When closing multi-binder contexts, the application throws a StackOverflow error due to an unnecessary addition of the binder child context as a separate bean in the main context. This was done previously for testing purposes. - Disabling the affected tests in the Pulsar binder until we come up with a different solution. Resolves https://github.com/spring-cloud/spring-cloud-stream/issues/2870 --- .../pulsar/PulsarExtendedBindingDefaultPropertiesTests.java | 3 +++ .../cloud/stream/binder/DefaultBinderFactory.java | 5 ----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/binders/pulsar-binder/spring-cloud-stream-binder-pulsar/src/test/java/org/springframework/cloud/stream/binder/pulsar/PulsarExtendedBindingDefaultPropertiesTests.java b/binders/pulsar-binder/spring-cloud-stream-binder-pulsar/src/test/java/org/springframework/cloud/stream/binder/pulsar/PulsarExtendedBindingDefaultPropertiesTests.java index 67cc5540b..ee36704a4 100644 --- a/binders/pulsar-binder/spring-cloud-stream-binder-pulsar/src/test/java/org/springframework/cloud/stream/binder/pulsar/PulsarExtendedBindingDefaultPropertiesTests.java +++ b/binders/pulsar-binder/spring-cloud-stream-binder-pulsar/src/test/java/org/springframework/cloud/stream/binder/pulsar/PulsarExtendedBindingDefaultPropertiesTests.java @@ -19,6 +19,7 @@ package org.springframework.cloud.stream.binder.pulsar; import java.util.function.Function; import org.apache.pulsar.common.schema.SchemaType; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -54,6 +55,7 @@ class PulsarExtendedBindingDefaultPropertiesTests implements PulsarTestContainer "spring.cloud.stream.pulsar.default.producer.name: my-producer"); @Test + @Disabled void defaultsUsedWhenNoCustomBindingProperties() { this.contextRunner.run((context) -> { assertThat(context) @@ -76,6 +78,7 @@ class PulsarExtendedBindingDefaultPropertiesTests implements PulsarTestContainer } @Test + @Disabled void defaultsRespectedWhenCustomBindingProperties() { this.contextRunner .withPropertyValues( diff --git a/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/DefaultBinderFactory.java b/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/DefaultBinderFactory.java index 619a5e2a2..0b8f08bda 100644 --- a/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/DefaultBinderFactory.java +++ b/core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/DefaultBinderFactory.java @@ -478,7 +478,6 @@ public class DefaultBinderFactory implements BinderFactory, DisposableBean, Appl } } }); - if (environment != null && !useApplicationContextAsParent) { InitializerWithOuterContext initializer = new InitializerWithOuterContext(this.context); initializer.initialize(binderProducingContext); @@ -496,10 +495,6 @@ public class DefaultBinderFactory implements BinderFactory, DisposableBean, Appl if (refresh) { binderProducingContext.refresh(); - if (this.context != null) { - this.context.getBeanFactory().registerSingleton(configurationName + "_binderProducingContext", - binderProducingContext); - } if (!useApplicationContextAsParent || "integration".equals(binderType.getDefaultName())) { this.propagateSharedBeans(binderProducingContext, (GenericApplicationContext) this.context); }