mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8373362: Http3TestServer should not log an exception stack trace when it is stopping normally
Reviewed-by: jpai, djelinski
This commit is contained in:
parent
655e9cda3f
commit
54430a8722
@ -108,6 +108,11 @@ public final class Http3ServerExchange implements Http2TestExchange {
|
||||
rspheadersBuilder = new HttpHeadersBuilder();
|
||||
}
|
||||
|
||||
Http3ServerConnection http3Connection() {
|
||||
return serverConn;
|
||||
}
|
||||
|
||||
|
||||
String connectionTag() {
|
||||
return serverConn.quicConnection().logTag();
|
||||
}
|
||||
|
||||
@ -55,6 +55,7 @@ import jdk.internal.net.http.http3.ConnectionSettings;
|
||||
import jdk.internal.net.http.http3.Http3Error;
|
||||
import jdk.internal.net.http.http3.frames.SettingsFrame;
|
||||
import jdk.internal.net.quic.QuicTLSContext;
|
||||
import jdk.internal.net.quic.QuicTransportErrors;
|
||||
import jdk.internal.net.quic.QuicVersion;
|
||||
import static java.nio.charset.StandardCharsets.US_ASCII;
|
||||
|
||||
@ -261,7 +262,23 @@ public class Http3TestServer implements QuicServer.ConnectionAcceptor, AutoClose
|
||||
handler.handle(exchange);
|
||||
} catch (Throwable failure) {
|
||||
System.err.println("Failed to handle exchange: " + failure);
|
||||
failure.printStackTrace();
|
||||
boolean noError = false;
|
||||
if (exchange instanceof Http3ServerExchange http3ServerExchange) {
|
||||
var quicConnection = http3ServerExchange.http3Connection().quicConnection();
|
||||
var cause = quicConnection.terminationCause();
|
||||
if (cause != null) {
|
||||
var code = cause.getCloseCode();
|
||||
noError = cause.isAppLayer()
|
||||
? Http3Error.isNoError(code)
|
||||
: code == QuicTransportErrors.NO_ERROR.code();
|
||||
}
|
||||
}
|
||||
// don't print the full stack trace if the connection
|
||||
// is terminated with no error, in order to avoid
|
||||
// cluttering the log.
|
||||
if (!noError) {
|
||||
failure.printStackTrace();
|
||||
}
|
||||
final var ioException = (failure instanceof IOException)
|
||||
? (IOException) failure
|
||||
: new IOException(failure);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user