8079651: (dc) Promiscuous.java fails with NumberFormatException due to network interference
Reviewed-by: alanb, chegar
Contributed-by: amy.lu@oracle.com
--- a/jdk/test/java/nio/channels/DatagramChannel/Promiscuous.java Fri May 08 10:37:14 2015 +0200
+++ b/jdk/test/java/nio/channels/DatagramChannel/Promiscuous.java Fri May 08 10:22:18 2015 +0100
@@ -97,7 +97,7 @@
// no datagram received
if (sa == null) {
if (datagramExepcted) {
- throw new RuntimeException("Expected message not recieved");
+ throw new RuntimeException("Expected message not received");
}
System.out.println("No message received (correct)");
return;
@@ -109,10 +109,15 @@
buf.flip();
byte[] bytes = new byte[buf.remaining()];
buf.get(bytes);
- int receivedId = Integer.parseInt(new String(bytes));
-
- System.out.format("Received message from %s (id=0x%x)\n",
- sender, receivedId);
+ String s = new String(bytes, "UTF-8");
+ int receivedId = -1;
+ try {
+ receivedId = Integer.parseInt(s);
+ System.out.format("Received message from %s (id=0x%x)\n",
+ sender, receivedId);
+ } catch (NumberFormatException x) {
+ System.out.format("Received message from %s (msg=%s)\n", sender, s);
+ }
if (!datagramExepcted) {
if (receivedId == id)