Skip to content

Commit 202ece9

Browse files
committed
Generic error responses from multiple @ControllerAdvice are still nondeterministic across OS #3236
1 parent 2e22cbd commit 202ece9

File tree

1 file changed

+5
-4
lines changed
  • springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app27

1 file changed

+5
-4
lines changed

springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app27/Advice.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import io.swagger.v3.oas.annotations.Hidden;
2828

2929
import org.springframework.http.HttpStatus;
30+
import org.springframework.http.ResponseEntity;
3031
import org.springframework.web.bind.annotation.ExceptionHandler;
3132
import org.springframework.web.bind.annotation.ResponseStatus;
3233
import org.springframework.web.bind.annotation.RestControllerAdvice;
@@ -37,14 +38,14 @@ public class Advice {
3738

3839
@ExceptionHandler(Exception.class)
3940
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
40-
public Foo handleException(Exception ex, WebRequest request) {
41-
return new Foo();
41+
public ResponseEntity<Foo> handleException(Exception ex, WebRequest request) {
42+
return new ResponseEntity<>(new Foo(), HttpStatus.INTERNAL_SERVER_ERROR);
4243
}
4344

4445
@ExceptionHandler(MyException.class)
4546
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
46-
public Bar handleMyException(MyException ex, WebRequest request) {
47-
return new Bar();
47+
public ResponseEntity<Bar> handleMyException(MyException ex, WebRequest request) {
48+
return new ResponseEntity<>(new Bar(), HttpStatus.INTERNAL_SERVER_ERROR);
4849
}
4950

5051
@Hidden

0 commit comments

Comments
 (0)