You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When httpRequest.getSession(false) is called, the callers does not ask to create a http session.
(javadoc of HttpServletRequest: "If create is false and the request has no valid HttpSession, this method returns null.")
So throwing UnsupportedOperationException is not needed in this case and returning null is enough.
…n(false) is called
When httpRequest.getSession(false) is called, the callers does not ask to create a http session. (javadoc of HttpServletRequest: "If create is false and the request has no valid HttpSession, this method returns null.")
So throwing UnsupportedOperationException is not needed in this case and returning null is enough.
This will fix a [blocking issue](javamelody/sonar-javamelody#4) in the [Sonar JavaMelody plugin](https://github.com/javamelody/javamelody/wiki/UserGuide#sonar-plugin).
@evernat Why do the Sonar JavaMeledoy plugin needs to get a HTTP session ?
As Sonarqube is not allowing usage of HTTP session, it's a bad practice to not throw an exception.
@julienlancelot
No, Sonar JavaMelody plugin does not need to get a HTTP session.
In fact, the plugin calls httpRequest.getSession(false) to see if there is a session and if there is no session then no problem.
So the plugin does not need Sonarqube to allow usage of HTTP session, but the plugin needs that Sonarqube says there is no session.
The PR will not change the fact that Sonarqube refuses to create HTTP sessions. The PR will just do the right thing, according to the servlet api, for httpRequest.getSession(create) when create is false.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When httpRequest.getSession(false) is called, the callers does not ask to create a http session.
(javadoc of HttpServletRequest: "If create is false and the request has no valid HttpSession, this method returns null.")
So throwing UnsupportedOperationException is not needed in this case and returning null is enough.
This will fix a blocking issue in the Sonar JavaMelody plugin.