changeset 57643:8654e0b4763a

8208281: java/nio/channels/AsynchronousSocketChannel/Basic.java timed out Summary: modify the test to accept the peer socket before closing the client socket Reviewed-by: alanb
author dfuchs
date Tue, 14 Jan 2020 11:45:29 +0000
parents e6e85a53b3e3
children 2080e45e61ea
files test/jdk/java/nio/channels/AsynchronousSocketChannel/Basic.java
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/test/jdk/java/nio/channels/AsynchronousSocketChannel/Basic.java	Tue Jan 14 10:43:55 2020 +0100
+++ b/test/jdk/java/nio/channels/AsynchronousSocketChannel/Basic.java	Tue Jan 14 11:45:29 2020 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2020, 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
@@ -336,8 +336,9 @@
             }
 
             // close channel (should cause initial read to complete)
+            SocketChannel peer = server.accept();
             ch.close();
-            server.accept().close();
+            peer.close();
 
             // check that AsynchronousCloseException is thrown
             try {
@@ -352,7 +353,7 @@
 
             ch = AsynchronousSocketChannel.open();
             ch.connect(server.address()).get();
-            SocketChannel peer = server.accept();
+            peer = server.accept();
             peer.setOption(SO_RCVBUF, 1);
 
             final AtomicReference<Throwable> writeException =