Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ default ResponseEntity<Problem> handleResponseStatusException(
final ResponseStatusException exception,
final NativeWebRequest request) {
String reason = exception.getReason();
return create(new HttpStatusAdapter(exception.getStatusCode()),exception, request);
return create(new HttpStatusAdapter(exception.getStatusCode()),exception, request, exception.getHeaders());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import dev.failsafe.CircuitBreaker;
import dev.failsafe.Failsafe;
import lombok.Data;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
Expand Down Expand Up @@ -112,6 +113,13 @@ private static final class MyResponseStatusException extends ResponseStatusExcep
MyResponseStatusException() {
super(HttpStatus.NOT_IMPLEMENTED);
}

@Override
public HttpHeaders getHeaders() {
var headers = new HttpHeaders();
headers.set(HttpHeaders.RETRY_AFTER, "5");
return headers;
}
}

@RequestMapping(path = "/nested-throwable", method = GET)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ void throwableProblem() throws Exception {
mvc().perform(request(GET, "http://localhost/api/handler-throwable-extended"))
.andExpect(status().isNotImplemented())
.andExpect(header().string("Content-Type", is("application/problem+json")))
.andExpect(header().string("Retry-After", is("5")))
.andExpect(jsonPath("$.type").doesNotExist())
.andExpect(jsonPath("$.title", is("Not Implemented")))
.andExpect(jsonPath("$.status", is(501)));
Expand Down