GH-2081 Add synchronization on channel resolution method in StreamBridge

This should mitigate  race condition when StreamBridge is used in an async way
Resolves #2081
This commit is contained in:
Oleg Zhurakousky
2021-01-25 16:01:37 +01:00
parent 2256933fcd
commit 44c3fe3ce6

View File

@@ -181,8 +181,8 @@ public final class StreamBridge implements SmartInitializingSingleton {
this.initialized = true;
}
@SuppressWarnings({ "unchecked", "deprecation" })
SubscribableChannel resolveDestination(String destinationName, ProducerProperties producerProperties) {
@SuppressWarnings("unchecked")
synchronized SubscribableChannel resolveDestination(String destinationName, ProducerProperties producerProperties) {
SubscribableChannel messageChannel = this.channelCache.get(destinationName);
if (messageChannel == null && this.applicationContext.containsBean(destinationName)) {
messageChannel = this.applicationContext.getBean(destinationName, SubscribableChannel.class);