Skip to content

Commit

Permalink
8286610: Add additional diagnostic output to java/net/DatagramSocket/…
Browse files Browse the repository at this point in the history
…InterruptibleDatagramSocket.java

Reviewed-by: msheppar, dfuchs, jpai
  • Loading branch information
bwhuang-us authored and jaikiran committed Jul 3, 2022
1 parent 70f5693 commit d8444aa
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/jdk/java/net/DatagramSocket/InterruptibleDatagramSocket.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -28,6 +28,7 @@
import java.net.SocketTimeoutException;
import java.nio.channels.ClosedByInterruptException;
import java.nio.channels.DatagramChannel;
import java.util.Arrays;
import java.util.concurrent.CountDownLatch;

import static java.lang.Thread.sleep;
Expand Down Expand Up @@ -60,6 +61,8 @@ private static void test0(DatagramSocket s) throws Exception {
latch.countDown();
try {
s.receive(p);
System.out.println("Received data " + Arrays.toString(p.getData())
+ " from " + p.getSocketAddress());
} finally {
try {
coordinator.join();
Expand Down Expand Up @@ -95,12 +98,18 @@ else if (!s.isClosed() && interruptible)

public static void main(String[] args) throws Exception {
try (DatagramSocket s = new DatagramSocket()) {
System.out.println("Testing interrupt of DatagramSocket receive " +
"on endpoint " + s.getLocalSocketAddress());
test(s, false);
}
try (DatagramSocket s = new MulticastSocket()) {
System.out.println("Testing interrupt of MulticastSocket receive" +
" on endpoint " + s.getLocalSocketAddress());
test(s, false);
}
try (DatagramSocket s = DatagramChannel.open().socket()) {
try (DatagramSocket s = DatagramChannel.open().bind(null).socket()) {
System.out.println("Testing interrupt of DatagramChannel socket " +
"receive on endpoint " + s.getLocalSocketAddress());
test(s, true);
}
}
Expand Down

1 comment on commit d8444aa

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.