Skip to content

Commit 5e5d8e4

Browse files
committed
Handle flushingFailed() for Servlet containers
Closes gh-26434
1 parent d7e05aa commit 5e5d8e4

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

spring-web/src/main/java/org/springframework/http/server/reactive/AbstractListenerWriteFlushProcessor.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -186,12 +186,13 @@ public final void subscribe(Subscriber<? super Void> subscriber) {
186186
protected abstract boolean isFlushPending();
187187

188188
/**
189-
* Invoked when an error happens while flushing. Sub-classes may choose
190-
* to ignore this if they know the underlying API will provide an error
191-
* notification in a container thread.
192-
* <p>Defaults to no-op.
189+
* Invoked when an error happens while flushing.
190+
* <p>The default implementation cancels the upstream write publisher and
191+
* sends an onError downstream as the result of request handling.
193192
*/
194193
protected void flushingFailed(Throwable t) {
194+
cancel();
195+
onError(t);
195196
}
196197

197198

spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpResponse.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -283,12 +283,6 @@ protected void flush() throws IOException {
283283
}
284284
}
285285

286-
@Override
287-
protected void flushingFailed(Throwable t) {
288-
cancel();
289-
onError(t);
290-
}
291-
292286
@Override
293287
protected boolean isWritePossible() {
294288
StreamSinkChannel channel = UndertowServerHttpResponse.this.responseChannel;

0 commit comments

Comments
 (0)