Skip to content

Commit

Permalink
ResponseStatusException sets detail from reason again, again
Browse files Browse the repository at this point in the history
 - leftover item that was not fully resolved in a27f2e9
  • Loading branch information
singhbaljit committed Nov 29, 2022
1 parent 61d8774 commit 3a37e18
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Expand Up @@ -56,7 +56,9 @@ public MethodNotAllowedException(String method, @Nullable Collection<HttpMethod>
}
this.method = method;
this.httpMethods = Collections.unmodifiableSet(new LinkedHashSet<>(supportedMethods));
setDetail(this.httpMethods.isEmpty() ? getReason() : "Supported methods: " + this.httpMethods);
if (!this.httpMethods.isEmpty()) {
setDetail("Supported methods: " + this.httpMethods);
}
}


Expand Down
Expand Up @@ -42,7 +42,6 @@ public MissingRequestValueException(String name, Class<?> type, String label, Me
this.name = name;
this.type = type;
this.label = label;
setDetail(getReason());
}


Expand Down
Expand Up @@ -78,6 +78,7 @@ public ResponseStatusException(int rawStatusCode, @Nullable String reason, @Null
public ResponseStatusException(HttpStatusCode status, @Nullable String reason, @Nullable Throwable cause) {
super(status, cause);
this.reason = reason;
setDetail(reason);
}

/**
Expand Down
Expand Up @@ -111,22 +111,22 @@ public void notAnnotated() {
}

@Test // SPR-12903
public void nestedException() throws Exception {
public void nestedException() {
Exception cause = new StatusCodeAndReasonMessageException();
TypeMismatchException ex = new TypeMismatchException("value", ITestBean.class, cause);
ModelAndView mav = exceptionResolver.resolveException(request, response, null, ex);
assertResolved(mav, 410, "gone.reason");
}

@Test
public void responseStatusException() throws Exception {
public void responseStatusException() {
ResponseStatusException ex = new ResponseStatusException(HttpStatus.BAD_REQUEST);
ModelAndView mav = exceptionResolver.resolveException(request, response, null, ex);
assertResolved(mav, 400, null);
}

@Test // SPR-15524
public void responseStatusExceptionWithReason() throws Exception {
public void responseStatusExceptionWithReason() {
ResponseStatusException ex = new ResponseStatusException(HttpStatus.BAD_REQUEST, "The reason");
ModelAndView mav = exceptionResolver.resolveException(request, response, null, ex);
assertResolved(mav, 400, "The reason");
Expand Down

0 comments on commit 3a37e18

Please sign in to comment.