Skip to content

Commit 2f455ed

Browse files
PeyaPeyaPeyangdfuch
authored andcommitted
8371092: NullPointerException in AltServiceUsageTest.afterClass() test
Reviewed-by: dfuchs
1 parent 7d3c66f commit 2f455ed

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

test/jdk/java/net/httpclient/AltServiceUsageTest.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private void createServers() throws IOException {
123123
public void afterClass() throws Exception {
124124
safeStop(originServer);
125125
safeStop(altServer);
126-
udpNotResponding.close();
126+
safeClose(udpNotResponding);
127127
}
128128

129129
private static void safeStop(final HttpTestServer server) {
@@ -140,6 +140,19 @@ private static void safeStop(final HttpTestServer server) {
140140
}
141141
}
142142

143+
private static void safeClose(final DatagramChannel channel) {
144+
if (channel == null) {
145+
return;
146+
}
147+
try {
148+
System.out.println("Closing DatagramChannel " + channel.getLocalAddress());
149+
channel.close();
150+
} catch (Exception e) {
151+
System.err.println("Ignoring exception: " + e.getMessage() + " that occurred " +
152+
"during close of DatagramChannel: " + channel);
153+
}
154+
}
155+
143156
private static class H3AltServicePublisher implements HttpTestHandler {
144157
private static final String RESPONSE_CONTENT = "apple";
145158

0 commit comments

Comments
 (0)