Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensuring Thread-Safety for BindingServiceProperties.bindings #3011

Conversation

kurthong
Copy link
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
1 check passed
@olegz
Copy link
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
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