Revert "Infer HTTP 404 from empty Optional/Publisher types"
This reverts commit 7e91733502.
This commit is contained in:
@@ -55,8 +55,6 @@ public class ResponseEntityResultHandler extends AbstractMessageWriterResultHand
|
||||
|
||||
private static final Set<HttpMethod> SAFE_METHODS = EnumSet.of(HttpMethod.GET, HttpMethod.HEAD);
|
||||
|
||||
private static final ResponseEntity<Object> notFound = new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
|
||||
|
||||
/**
|
||||
* Basic constructor with a default {@link ReactiveAdapterRegistry}.
|
||||
@@ -121,8 +119,7 @@ public class ResponseEntityResultHandler extends AbstractMessageWriterResultHand
|
||||
|
||||
if (adapter != null) {
|
||||
Assert.isTrue(!adapter.isMultiValue(), "Only a single ResponseEntity supported");
|
||||
returnValueMono = Mono.from(adapter.toPublisher(result.getReturnValue()))
|
||||
.defaultIfEmpty(notFound);
|
||||
returnValueMono = Mono.from(adapter.toPublisher(result.getReturnValue()));
|
||||
bodyParameter = actualParameter.nested().nested();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -350,20 +350,6 @@ public class ResponseEntityResultHandlerTests {
|
||||
assertResponseBodyIsEmpty(exchange);
|
||||
}
|
||||
|
||||
@Test // SPR-13281
|
||||
public void handleEmptyMonoShouldResultInNotFoundStatus() {
|
||||
MockServerWebExchange exchange = MockServerWebExchange.from(get("/path"));
|
||||
exchange.getAttributes().put(PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, Collections.singleton(APPLICATION_JSON));
|
||||
|
||||
MethodParameter type = on(TestController.class).resolveReturnType(Mono.class, ResponseEntity.class);
|
||||
HandlerResult result = new HandlerResult(new TestController(), Mono.empty(), type);
|
||||
|
||||
this.resultHandler.handleResult(exchange, result).block(Duration.ofSeconds(5));
|
||||
|
||||
assertEquals(HttpStatus.NOT_FOUND, exchange.getResponse().getStatusCode());
|
||||
assertResponseBodyIsEmpty(exchange);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void testHandle(Object returnValue, MethodParameter returnType) {
|
||||
|
||||
Reference in New Issue
Block a user