From 492d68677d3b828af4b4b5bf57f17c8ab47d9eba Mon Sep 17 00:00:00 2001 From: Colin Alworth Date: Mon, 18 Nov 2024 11:05:15 -0600 Subject: [PATCH] fix: Close Jetty h2 streams with RST_STREAM and no error code Fixes #5996 --- .../servlet/jakarta/AsyncServletOutputStreamWriter.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/grpc-java/grpc-servlet-jakarta/src/main/java/io/grpc/servlet/jakarta/AsyncServletOutputStreamWriter.java b/grpc-java/grpc-servlet-jakarta/src/main/java/io/grpc/servlet/jakarta/AsyncServletOutputStreamWriter.java index 8b2c1da5412..9384be40faf 100644 --- a/grpc-java/grpc-servlet-jakarta/src/main/java/io/grpc/servlet/jakarta/AsyncServletOutputStreamWriter.java +++ b/grpc-java/grpc-servlet-jakarta/src/main/java/io/grpc/servlet/jakarta/AsyncServletOutputStreamWriter.java @@ -121,9 +121,15 @@ public boolean isFinestEnabled() { transportState.runOnTransportThread( () -> { transportState.complete(); - asyncContext.complete(); + // asyncContext.complete(); log.fine("call completed"); }); + // Jetty specific fix: When AsyncContext.complete() is called, Jetty sends a RST_STREAM with + // "cancel" error to the client, while other containers send "no error" in this case. Calling + // close() instead on the output stream still sends the RST_STREAM, but with "no error". Note + // that this does the opposite in at least Tomcat, so we're not going to upstream this change. + // See https://github.com/deephaven/deephaven-core/issues/6400 + outputStream.close(); }; this.isReady = () -> outputStream.isReady(); }