Add channel check before dispose which may cause reactor-netty PrematureCloseException

Fixes gh-2046
Fixes gh-2093
This commit is contained in:
YoungWeng
2020-12-29 21:02:08 +08:00
committed by spencergibb
parent 8dc4a0fb84
commit 2f2163c49a

View File

@@ -123,7 +123,8 @@ public class NettyWriteResponseFilter implements GlobalFilter, Ordered {
private void cleanup(ServerWebExchange exchange) {
Connection connection = exchange.getAttribute(CLIENT_RESPONSE_CONN_ATTR);
if (connection != null) {
if (connection != null && connection.channel().isActive()
&& !connection.isPersistent()) {
connection.dispose();
}
}