Skip to content

The DefaultBinderFactory.propagateSharedBeans() is looking for shared bean in wrong context #2728

@mayur-solace

Description

@mayur-solace

The call to the this.propagateSharedBeans(...) is passing the fromContext and toContext contexts in wrong order. The binderProducingContext should be toContext.

Also calling the binderProducingContext.refresh() before call to this.propagateSharedBeans(..) creates new beans (that depends on shared beans) before shared beans are available for auto-wiring.

Code snippet from org.springframework.cloud.stream.binder.DefaultBinderFactory

 if (refresh) {
	binderProducingContext.refresh();
	if (!useApplicationContextAsParent || "integration".equals(binderType.getDefaultName())) {
		this.propagateSharedBeans((GenericApplicationContext) this.context, binderProducingContext);
	}
}

should the call be instead....

if (refresh) {
	if (!useApplicationContextAsParent || "integration".equals(binderType.getDefaultName())) {
		this.propagateSharedBeans(binderProducingContext, (GenericApplicationContext) this.context);
	}
        binderProducingContext.refresh();
}

is there a tests that covers shared bean propagation ?

this.propagateSharedBeans((GenericApplicationContext) this.context, binderProducingContext);

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions