Prevent possible NPE in LoginForm
urlProvider is injected as @Nullable but then is used without first checking if it's null. Add checks to prevent dereference of null pointer. Change-Id: Ida2bca9ff33336df21c657f80d96752ae4c35b48
This commit is contained in:
@@ -79,7 +79,7 @@ class LoginForm extends HttpServlet {
|
||||
"openid", "maxRedirectUrlLength",
|
||||
10);
|
||||
|
||||
if (Strings.isNullOrEmpty(urlProvider.get())) {
|
||||
if (urlProvider == null || Strings.isNullOrEmpty(urlProvider.get())) {
|
||||
log.error("gerrit.canonicalWebUrl must be set in gerrit.config");
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ class LoginForm extends HttpServlet {
|
||||
private void sendForm(HttpServletRequest req, HttpServletResponse res,
|
||||
boolean link, @Nullable String errorMessage) throws IOException {
|
||||
String self = req.getRequestURI();
|
||||
String cancel = Objects.firstNonNull(urlProvider.get(), "/");
|
||||
String cancel = Objects.firstNonNull(urlProvider != null ? urlProvider.get() : "/", "/");
|
||||
String token = getToken(req);
|
||||
if (!token.equals("/")) {
|
||||
cancel += "#" + token;
|
||||
|
||||
Reference in New Issue
Block a user