Skip to content

Commit

Permalink
BindingServiceProperties.bindings property should be thread-safe.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kurthong77 committed Sep 26, 2024
1 parent 2f4ae47 commit fd20513
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentSkipListMap;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
Expand Down Expand Up @@ -53,6 +53,7 @@
* @author Ilayaperumal Gopinathan
* @author Oleg Zhurakousky
* @author Michael Michailidis
* @author Kurt Hong
*/
@ConfigurationProperties("spring.cloud.stream")
@JsonInclude(Include.NON_DEFAULT)
Expand Down Expand Up @@ -115,7 +116,7 @@ public class BindingServiceProperties
* For example; This sets the content-type for the 'input' binding of a Sink
* application: 'spring.cloud.stream.bindings.input.contentType=text/plain'
*/
private Map<String, BindingProperties> bindings = new TreeMap<>(
private Map<String, BindingProperties> bindings = new ConcurrentSkipListMap(
String.CASE_INSENSITIVE_ORDER);

/**
Expand Down

0 comments on commit fd20513

Please sign in to comment.