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.
This commit is contained in:
kurt
2024-09-26 23:51:33 +09:00
committed by Oleg Zhurakousky
parent 0336ffd8ca
commit 8148d55251

View File

@@ -20,7 +20,7 @@ import java.util.ArrayList;
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;
@@ -53,6 +53,7 @@ import org.springframework.util.StringUtils;
* @author Ilayaperumal Gopinathan
* @author Oleg Zhurakousky
* @author Michael Michailidis
* @author Kurt Hong
*/
@ConfigurationProperties("spring.cloud.stream")
@JsonInclude(Include.NON_DEFAULT)
@@ -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);
/**