Skip to content

Commit 8148d55

Browse files
kurthong77olegz
authored andcommitted
BindingServiceProperties.bindings property should be thread-safe.
First, thanks for the excellent StreamBridge feature! I've found it very useful. However, I occasionally encounter the following exception during race conditions. ``` java.lang.NullPointerException: null at java.base/java.util.TreeMap.rotateRight(TreeMap.java:2240) at java.base/java.util.TreeMap.fixAfterInsertion(TreeMap.java:2272) at java.base/java.util.TreeMap.put(TreeMap.java:580) at org.springframework.cloud.stream.config.BindingServiceProperties.bindToDefault(BindingServiceProperties.java:397) at org.springframework.cloud.stream.config.BindingServiceProperties.bindIfNecessary(BindingServiceProperties.java:381) at org.springframework.cloud.stream.config.BindingServiceProperties.getBindingProperties(BindingServiceProperties.java:301) at org.springframework.cloud.stream.function.StreamBridge.send(StreamBridge.java:149) ``` BindingServiceProperties.bindings property should be thread-safe.
1 parent 0336ffd commit 8148d55

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/config/BindingServiceProperties.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import java.util.HashMap;
2121
import java.util.List;
2222
import java.util.Map;
23-
import java.util.TreeMap;
23+
import java.util.concurrent.ConcurrentSkipListMap;
2424

2525
import com.fasterxml.jackson.annotation.JsonInclude;
2626
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@@ -53,6 +53,7 @@
5353
* @author Ilayaperumal Gopinathan
5454
* @author Oleg Zhurakousky
5555
* @author Michael Michailidis
56+
* @author Kurt Hong
5657
*/
5758
@ConfigurationProperties("spring.cloud.stream")
5859
@JsonInclude(Include.NON_DEFAULT)
@@ -115,7 +116,7 @@ public class BindingServiceProperties
115116
* For example; This sets the content-type for the 'input' binding of a Sink
116117
* application: 'spring.cloud.stream.bindings.input.contentType=text/plain'
117118
*/
118-
private Map<String, BindingProperties> bindings = new TreeMap<>(
119+
private Map<String, BindingProperties> bindings = new ConcurrentSkipListMap(
119120
String.CASE_INSENSITIVE_ORDER);
120121

121122
/**

0 commit comments

Comments
 (0)