From a7d4828bea82c64e295f9b62aa6afb74fa28b2df Mon Sep 17 00:00:00 2001 From: Hamlin Li Date: Wed, 16 Nov 2016 17:29:14 -0800 Subject: [PATCH] 8169764: output more information when java/nio/channels/AsynchronousSocketChannel/Basic.java fails Reviewed-by: alanb --- .../AsynchronousSocketChannel/Basic.java | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java b/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java index e12ab09c32b..f98fca05391 100644 --- a/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java +++ b/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java @@ -219,7 +219,8 @@ public class Basic { throw new RuntimeException("ExecutionException expected"); } catch (ExecutionException x) { if (!(x.getCause() instanceof ClosedChannelException)) - throw new RuntimeException("Cause of ClosedChannelException expected"); + throw new RuntimeException("Cause of ClosedChannelException expected", + x.getCause()); } final AtomicReference connectException = new AtomicReference<>(); ch.connect(server.address(), (Void)null, new CompletionHandler() { @@ -233,7 +234,8 @@ public class Basic { Thread.sleep(100); } if (!(connectException.get() instanceof ClosedChannelException)) - throw new RuntimeException("ClosedChannelException expected"); + throw new RuntimeException("ClosedChannelException expected", + connectException.get()); } // test that failure to connect closes the channel @@ -353,7 +355,8 @@ public class Basic { Thread.sleep(100); } if (!(writeException.get() instanceof AsynchronousCloseException)) - throw new RuntimeException("AsynchronousCloseException expected"); + throw new RuntimeException("AsynchronousCloseException expected", + writeException.get()); } } @@ -460,7 +463,8 @@ public class Basic { throw new RuntimeException("ExecutionException expected"); } catch (ExecutionException x) { if (!(x.getCause() instanceof ClosedChannelException)) - throw new RuntimeException("Cause of ClosedChannelException expected"); + throw new RuntimeException("Cause of ClosedChannelException expected", + x.getCause()); } } } @@ -630,7 +634,8 @@ public class Basic { throw new RuntimeException("ExecutionException expected"); } catch (ExecutionException x) { if (!(x.getCause() instanceof ClosedChannelException)) - throw new RuntimeException("Cause of ClosedChannelException expected"); + throw new RuntimeException("Cause of ClosedChannelException expected", + x.getCause()); } } } @@ -738,7 +743,8 @@ public class Basic { throw new RuntimeException("ClosedChannelException expected"); } catch (ExecutionException x) { if (!(x.getCause() instanceof ClosedChannelException)) - throw new RuntimeException("ClosedChannelException expected"); + throw new RuntimeException("ClosedChannelException expected", + x.getCause()); } } } @@ -776,7 +782,8 @@ public class Basic { Thread.sleep(100); } if (!(readException.get() instanceof InterruptedByTimeoutException)) - throw new RuntimeException("InterruptedByTimeoutException expected"); + throw new RuntimeException("InterruptedByTimeoutException expected", + readException.get()); // after a timeout then further reading should throw unspecified runtime exception boolean exceptionThrown = false; @@ -813,7 +820,8 @@ public class Basic { Thread.sleep(100); } if (!(writeException.get() instanceof InterruptedByTimeoutException)) - throw new RuntimeException("InterruptedByTimeoutException expected"); + throw new RuntimeException("InterruptedByTimeoutException expected", + writeException.get()); // after a timeout then further writing should throw unspecified runtime exception boolean exceptionThrown = false;