Skip to content

Commit fdb05c2

Browse files
committed
spring-cloudGH-1384 Set application's context as binder context
Set application's context as binder context once the binder is initialized to ensure identical behavior in i multi-environment scenarios. Resolves spring-cloud#1384 Resolves spring-cloud#1357
1 parent b8da729 commit fdb05c2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

spring-cloud-stream/src/main/java/org/springframework/cloud/stream/binder/DefaultBinderFactory.java

+8
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,15 @@ private <T> boolean verifyBinderTypeMatchesTarget(Binder<T, ?, ?> binderInstance
204204
}
205205
ConfigurableApplicationContext binderProducingContext = springApplicationBuilder
206206
.run(args.toArray(new String[args.size()]));
207+
207208
Binder<T, ?, ?> binder = binderProducingContext.getBean(Binder.class);
209+
/*
210+
* This will ensure that application defined errorChannel and other beans are accessible within binder's context
211+
* (see https://github.com/spring-cloud/spring-cloud-stream/issues/1384)
212+
*/
213+
if (this.context != null && binder instanceof ApplicationContextAware) {
214+
((ApplicationContextAware)binder).setApplicationContext(this.context);
215+
}
208216
if (!CollectionUtils.isEmpty(this.listeners)) {
209217
for (Listener binderFactoryListener : listeners) {
210218
binderFactoryListener.afterBinderContextInitialized(configurationName, binderProducingContext);

0 commit comments

Comments
 (0)