From 5e5d8e4a2314b06e7318865016758774f36f2a1d Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 28 Jan 2021 17:03:08 +0000 Subject: [PATCH] Handle flushingFailed() for Servlet containers Closes gh-26434 --- .../reactive/AbstractListenerWriteFlushProcessor.java | 11 ++++++----- .../server/reactive/UndertowServerHttpResponse.java | 8 +------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteFlushProcessor.java b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteFlushProcessor.java index 81c8098d32..3a323c86bc 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteFlushProcessor.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteFlushProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -186,12 +186,13 @@ public abstract class AbstractListenerWriteFlushProcessor implements Processo protected abstract boolean isFlushPending(); /** - * Invoked when an error happens while flushing. Sub-classes may choose - * to ignore this if they know the underlying API will provide an error - * notification in a container thread. - *

Defaults to no-op. + * Invoked when an error happens while flushing. + *

The default implementation cancels the upstream write publisher and + * sends an onError downstream as the result of request handling. */ protected void flushingFailed(Throwable t) { + cancel(); + onError(t); } diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpResponse.java b/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpResponse.java index 3e1d5c35c2..5f8034b724 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -283,12 +283,6 @@ class UndertowServerHttpResponse extends AbstractListenerServerHttpResponse impl } } - @Override - protected void flushingFailed(Throwable t) { - cancel(); - onError(t); - } - @Override protected boolean isWritePossible() { StreamSinkChannel channel = UndertowServerHttpResponse.this.responseChannel;