-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Check hasNext when when accessing sessionIds from UserDestinationResult #34333
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
Check hasNext when when accessing sessionIds from UserDestinationResult #34333
Conversation
Signed-off-by: Branden Clark <[email protected]>
...ing/src/main/java/org/springframework/messaging/simp/user/UserDestinationMessageHandler.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Branden Clark <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proposed updates make sense. Thanks for the pull request.
As UserDestinationResult is typically created by the framework, and we no longer use the pre-6.1 constructor, we should probably deprecate it. Could you clarify what or who is calling that constructor?
|
We have a custom I'm pretty novice in this space, but it seems like the pre-6.1 constructor is still useful when needing to customize the |
See gh-34333 Signed-off-by: Branden Clark <[email protected]>
|
Thanks for the feedback. I've left both constructors. |
Closes gh-34333 Signed-off-by: Branden Clark <[email protected]>
Found a bug in
UserDestinationMessageHandler.SendHelper#sendthat occurs when theUserDestinationResultwas created by the pre-6.1.x constructor. Bug was introduced with 3277b0dIdeally this fix will target 6.1+ and should be compatible. Not sure if there's a special way to call that out as a first-time contributor.
Changes
Bug Details
The
UserDestinationMessageHandlerunsafely retrieves values from an iterator ofsessionIdstrings to lookup ordered messages.This happens when the
UserDestinationResultused to route the message was created with the pre-6.1.x constructor this retrieval throws aNoSuchElementException.This is because the older constructor passes a
nullto the newer constructor for thesessionIdsconstructor arg. The class attempts to safe handle thisnullarg by creating an EmptySet that eventually provides an [EmptyIterator],(https://github.com/openjdk/jdk/blob/98a93e115137a305aed6b7dbf1d4a7d5906fe77c/src/java.base/share/classes/java/util/Collections.java#L4559) which then throws forSet#next.This bug seems to only happen for custom implementations of
UserDestinationResolveras theDefaultUserDestinationResolveralways provides a populated set to the new constructor.