]> source.dussan.org Git - sonarqube.git/commitdiff
Do not throw UnsupportedOperationException when httpRequest.getSession(false) is...
authorevernat <evernat@free.fr>
Sat, 15 Oct 2016 23:16:03 +0000 (01:16 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 19 Oct 2016 09:58:08 +0000 (11:58 +0200)
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](https://github.com/javamelody/sonar-javamelody/issues/4) in the [Sonar JavaMelody plugin](https://github.com/javamelody/javamelody/wiki/UserGuide#sonar-plugin).

server/sonar-server/src/main/java/org/sonar/server/platform/web/RootFilter.java

index 7d11e1782a0bbdaad4640493bef272d07ba16406..d1d408c2f1ea1e572d46e68134990dd3f924c371 100644 (file)
@@ -147,6 +147,9 @@ public class RootFilter implements Filter {
 
     @Override
     public HttpSession getSession(boolean create) {
+      if (!create) {
+        return null;
+      }
       throw notSupported();
     }