Browse Source

Adjust timeout in Spring MVC for reactive streaming

Issue: SPR-15669
pull/1460/head
Rossen Stoyanchev 8 years ago
parent
commit
ef3e309c12
  1. 7
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ReactiveTypeHandler.java

7
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ReactiveTypeHandler.java

@ -70,6 +70,9 @@ import org.springframework.web.servlet.HandlerMapping; @@ -70,6 +70,9 @@ import org.springframework.web.servlet.HandlerMapping;
*/
class ReactiveTypeHandler {
private static final long STREAMING_TIMEOUT_VALUE = -1;
private static Log logger = LogFactory.getLog(ReactiveTypeHandler.class);
private final ReactiveAdapterRegistry reactiveRegistry;
@ -126,7 +129,7 @@ class ReactiveTypeHandler { @@ -126,7 +129,7 @@ class ReactiveTypeHandler {
if (adapter.isMultiValue()) {
if (mediaTypes.stream().anyMatch(MediaType.TEXT_EVENT_STREAM::includes) ||
ServerSentEvent.class.isAssignableFrom(elementClass)) {
SseEmitter emitter = new SseEmitter();
SseEmitter emitter = new SseEmitter(STREAMING_TIMEOUT_VALUE);
new SseEmitterSubscriber(emitter, this.taskExecutor).connect(adapter, returnValue);
return emitter;
}
@ -162,7 +165,7 @@ class ReactiveTypeHandler { @@ -162,7 +165,7 @@ class ReactiveTypeHandler {
}
private ResponseBodyEmitter getEmitter(MediaType mediaType) {
return new ResponseBodyEmitter() {
return new ResponseBodyEmitter(STREAMING_TIMEOUT_VALUE) {
@Override
protected void extendResponse(ServerHttpResponse outputMessage) {
outputMessage.getHeaders().setContentType(mediaType);

Loading…
Cancel
Save