diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/DefaultErrorAttributes.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/DefaultErrorAttributes.java index 821c0a9fef..85ac4f85ba 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/DefaultErrorAttributes.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/DefaultErrorAttributes.java @@ -75,7 +75,7 @@ public class DefaultErrorAttributes implements ErrorAttributes, HandlerException private void storeErrorAttributes(HttpServletRequest request, Exception ex) { request.setAttribute(ERROR_ATTRIBUTE, ex); - + } @Override @@ -121,9 +121,8 @@ public class DefaultErrorAttributes implements ErrorAttributes, HandlerException addStackTrace(errorAttributes, error); } } - if (error==null || errorAttributes.get("message")==null) { - Object message = getAttribute(requestAttributes, - "javax.servlet.error.message"); + Object message = getAttribute(requestAttributes, "javax.servlet.error.message"); + if (message != null || errorAttributes.get("message") == null) { errorAttributes.put("message", message == null ? "No message available" : message); }