8371092: NullPointerException in AltServiceUsageTest.afterClass() test

Reviewed-by: dfuchs
This commit is contained in:
Peyang 2025-11-04 16:08:15 +00:00 committed by Daniel Fuchs
parent 7d3c66f379
commit 2f455ed146

View File

@ -123,7 +123,7 @@ public class AltServiceUsageTest implements HttpServerAdapters {
public void afterClass() throws Exception {
safeStop(originServer);
safeStop(altServer);
udpNotResponding.close();
safeClose(udpNotResponding);
}
private static void safeStop(final HttpTestServer server) {
@ -140,6 +140,19 @@ public class AltServiceUsageTest implements HttpServerAdapters {
}
}
private static void safeClose(final DatagramChannel channel) {
if (channel == null) {
return;
}
try {
System.out.println("Closing DatagramChannel " + channel.getLocalAddress());
channel.close();
} catch (Exception e) {
System.err.println("Ignoring exception: " + e.getMessage() + " that occurred " +
"during close of DatagramChannel: " + channel);
}
}
private static class H3AltServicePublisher implements HttpTestHandler {
private static final String RESPONSE_CONTENT = "apple";