-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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
Check hasNext when when accessing sessionIds from UserDestinationResult #34333
Conversation
Signed-off-by: Branden Clark <brandenrayclark@gmail.com>
...ing/src/main/java/org/springframework/messaging/simp/user/UserDestinationMessageHandler.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Branden Clark <brandenrayclark@gmail.com>
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 <brandenrayclark@gmail.com>
Thanks for the feedback. I've left both constructors. |
Closes gh-34333 Signed-off-by: Branden Clark <brandenrayclark@gmail.com>
Found a bug in
UserDestinationMessageHandler.SendHelper#send
that occurs when theUserDestinationResult
was 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
UserDestinationMessageHandler
unsafely retrieves values from an iterator ofsessionId
strings to lookup ordered messages.This happens when the
UserDestinationResult
used 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
null
to the newer constructor for thesessionIds
constructor arg. The class attempts to safe handle thisnull
arg 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
UserDestinationResolver
as theDefaultUserDestinationResolver
always provides a populated set to the new constructor.