Skip to content

Commit 2a3b5d2

Browse files
committed
Fix NPE in DefaultErrorController
Closes gh-1286
1 parent 2895169 commit 2a3b5d2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: samples/demo-authorizationserver/src/main/java/sample/web/DefaultErrorController.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.springframework.boot.web.servlet.error.ErrorController;
2222
import org.springframework.stereotype.Controller;
2323
import org.springframework.ui.Model;
24+
import org.springframework.util.StringUtils;
2425
import org.springframework.web.bind.annotation.RequestMapping;
2526

2627
/**
@@ -44,7 +45,8 @@ public String handleError(Model model, HttpServletRequest request) {
4445
}
4546

4647
private String getErrorMessage(HttpServletRequest request) {
47-
return (String) request.getAttribute(RequestDispatcher.ERROR_MESSAGE);
48+
String errorMessage = (String) request.getAttribute(RequestDispatcher.ERROR_MESSAGE);
49+
return StringUtils.hasText(errorMessage) ? errorMessage : "";
4850
}
4951

5052
}

0 commit comments

Comments
 (0)