Skip to content

Ensuring Thread-Safety for BindingServiceProperties.bindings#3011

Merged
olegz merged 1 commit intospring-cloud:mainfrom
kurthong:BindingServiceProperties.bindings-property-should-be-thread-safe
Sep 27, 2024
Merged

Ensuring Thread-Safety for BindingServiceProperties.bindings#3011
olegz merged 1 commit intospring-cloud:mainfrom
kurthong:BindingServiceProperties.bindings-property-should-be-thread-safe

Conversation

@kurthong
Copy link
Copy Markdown
Contributor

First, thank you for the excellent StreamBridge feature! I’ve found it very useful.
However, I rarely 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)

It seems the BindingServiceProperties.bindings property should be thread-safe when utilizing StreamBridge on the producer side to avoid such issues in concurrent scenarios.

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.
@olegz olegz merged commit 9aabfbe into spring-cloud:main Sep 27, 2024
@olegz
Copy link
Copy Markdown
Contributor

olegz commented Sep 27, 2024

Thank you for your contribution!!!

@olegz olegz added this to the 4.2.0-M2 milestone Sep 27, 2024
@olegz
Copy link
Copy Markdown
Contributor

olegz commented Sep 27, 2024

Back-ported to 4.1.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants