MockMvc re-uses response instance on async dispatch
MockMvc now properly detects the presence of an AsyncContext and re-uses the response instance used to start it. This commit also includes a minor fix in ResponseBodyEmitterReturnValueHandler to ensure it does not disable ETag related content buffering for reactive return values that do not result in streaming (e.g. single value or collections). Issue: SPR-16067
This commit is contained in:
@@ -140,23 +140,23 @@ public class ResponseBodyEmitterReturnValueHandler implements HandlerMethodRetur
|
||||
|
||||
ServletRequest request = webRequest.getNativeRequest(ServletRequest.class);
|
||||
Assert.state(request != null, "No ServletRequest");
|
||||
ShallowEtagHeaderFilter.disableContentCaching(request);
|
||||
|
||||
ResponseBodyEmitter emitter;
|
||||
|
||||
if (returnValue instanceof ResponseBodyEmitter) {
|
||||
emitter = (ResponseBodyEmitter) returnValue;
|
||||
}
|
||||
else {
|
||||
emitter = this.reactiveHandler.handleValue(returnValue, returnType, mavContainer, webRequest);
|
||||
if (emitter == null) {
|
||||
// Not streaming..
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (emitter == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
emitter.extendResponse(outputMessage);
|
||||
|
||||
// At this point we know we're streaming..
|
||||
ShallowEtagHeaderFilter.disableContentCaching(request);
|
||||
|
||||
// Commit the response and wrap to ignore further header changes
|
||||
outputMessage.getBody();
|
||||
outputMessage.flush();
|
||||
|
||||
Reference in New Issue
Block a user