Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
dfuch committed Jun 14, 2024
1 parent 21b0641 commit 3451a70
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/jdk/java/nio/channels/SocketChannel/OpenLeak.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.fail;

public class OpenLeak {

Expand Down Expand Up @@ -69,32 +70,32 @@ public void test() throws Exception {
// where close should be called
SocketAddress sa = InetSocketAddress.createUnresolved(isa.getHostString(), isa.getPort());

System.out.println("Expecting Connection Refused for " + isa);
System.out.println("Expecting UnresolvedAddressException for " + sa);
System.err.println("Expecting Connection Refused for " + isa);
System.err.println("Expecting UnresolvedAddressException for " + sa);
int i = 0;
try {
for (i = 0; i < MAX_LOOP; i++) {
try {
SocketChannel.open(sa);
throw new RuntimeException("This should not happen");
fail("This should not happen");
} catch (UnresolvedAddressException x) {
if (i < 5 || i >= MAX_LOOP - 5) {
// print a message for the first five and last 5 exceptions
System.out.println(x);
System.err.println(x);
}
}
try {
SocketChannel.open(isa);
throw new RuntimeException("This should not happen");
fail("This should not happen");
} catch (ConnectException x) {
if (i < 5 || i >= MAX_LOOP - 5) {
// print a message for the first five and last 5 exceptions
System.out.println(x);
System.err.println(x);
}
}
}
} catch (Throwable t) {
System.out.println("Failed at " + i + " with " + t);
System.err.println("Failed at " + i + " with " + t);
throw t;
}
}
Expand Down

0 comments on commit 3451a70

Please sign in to comment.