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

SimpMessageHeaderAccessor#getUser is now nullable. How to handle? #25

Open
stefanos-kalantzis opened this issue Oct 24, 2018 · 0 comments

Comments

@stefanos-kalantzis
Copy link

stefanos-kalantzis commented Oct 24, 2018

I couldn't find a better place to open this... Please redirect me if there is.

spring-messaging, since v5.0.0, has marked method SimpMessageHeaderAccessor#getUser as @Nullable.
Which actually causes Findbugs to fail with code similar to your example, and rightfully so.

Specifically here: PresenceEventListener#handleSessionConnected

String username = headers.getUser().getName();

My question is how is this supposed to be handled properly? (i.e. when #getUser returns null)
Should the code throw an exception? do nothing?
And what does it actually mean that the user is null in this context?

Principal principal = headers.getUser();
if (principal == null) {
    // what should happen here ?
}

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant