Merge branch '5.1.x'
This commit is contained in:
commit
fb66619187
|
|
@ -29,6 +29,7 @@ import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.context.ApplicationContextAware;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
import org.springframework.core.ReactiveAdapterRegistry;
|
import org.springframework.core.ReactiveAdapterRegistry;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.codec.HttpMessageReader;
|
import org.springframework.http.codec.HttpMessageReader;
|
||||||
import org.springframework.http.codec.ServerCodecConfigurer;
|
import org.springframework.http.codec.ServerCodecConfigurer;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
|
|
@ -209,6 +210,9 @@ public class RequestMappingHandlerAdapter implements HandlerAdapter, Application
|
||||||
|
|
||||||
// Success and error responses may use different content types
|
// Success and error responses may use different content types
|
||||||
exchange.getAttributes().remove(HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE);
|
exchange.getAttributes().remove(HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE);
|
||||||
|
if (!exchange.getResponse().isCommitted()) {
|
||||||
|
exchange.getResponse().getHeaders().remove(HttpHeaders.CONTENT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
InvocableHandlerMethod invocable = this.methodResolver.getExceptionHandlerMethod(exception, handlerMethod);
|
InvocableHandlerMethod invocable = this.methodResolver.getExceptionHandlerMethod(exception, handlerMethod);
|
||||||
if (invocable != null) {
|
if (invocable != null) {
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ public class RequestMappingExceptionHandlingIntegrationTests extends AbstractReq
|
||||||
public void exceptionFromMethodWithProducesCondition() throws Exception {
|
public void exceptionFromMethodWithProducesCondition() throws Exception {
|
||||||
try {
|
try {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.add("Accept", "text/csv, application/problem+json");
|
headers.add("Accept", "text/plain, application/problem+json");
|
||||||
performGet("/SPR-16318", headers, String.class).getBody();
|
performGet("/SPR-16318", headers, String.class).getBody();
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
|
|
@ -152,9 +152,9 @@ public class RequestMappingExceptionHandlingIntegrationTests extends AbstractReq
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = "/SPR-16318", produces = "text/csv")
|
@GetMapping(path = "/SPR-16318", produces = "text/plain")
|
||||||
public String handleCsv() throws Exception {
|
public Mono<String> handleTextPlain() throws Exception {
|
||||||
throw new Spr16318Exception();
|
return Mono.error(new Spr16318Exception());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler
|
@ExceptionHandler
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue