Do not fail with NPE if context path of request is null
This may result in the following error:
com.google.inject.ProvisionException: Guice provision errors:
1) Error injecting constructor, java.lang.NullPointerException: while trying
to invoke the method java.lang.String.isEmpty() of an object loaded from
local variable 'path'
at com.google.gerrit.httpd.WebSession.<init>(WebSession.java:79)
while locating com.google.gerrit.httpd.WebSession
for parameter 0 at
com.google.gerrit.httpd.HttpCurrentUserProvider.<init>(HttpCurrentUserProvider.java:27)
while locating com.google.gerrit.httpd.HttpCurrentUserProvider
while locating com.google.gerrit.server.CurrentUser
Change-Id: I6a2e5324f4efb1e141309aec2e8cc47ead7af4a5
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/CacheBasedWebSession.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/CacheBasedWebSession.java
index d27d684..d9203f5 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/CacheBasedWebSession.java
+++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/CacheBasedWebSession.java
@@ -195,7 +195,7 @@
String path = authConfig.getCookiePath();
if (path == null || path.isEmpty()) {
path = request.getContextPath();
- if (path.isEmpty()) {
+ if (path == null || path.isEmpty()) {
path = "/";
}
}