File tree Expand file tree Collapse file tree 3 files changed +12
-11
lines changed
test/jdk/java/net/Socket/asyncClose Expand file tree Collapse file tree 3 files changed +12
-11
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -36,19 +36,20 @@ public synchronized boolean hasPassed() {
3636 }
3737
3838 protected synchronized AsyncCloseTest passed () {
39- if (reason == null )
39+ if (failureReason () == null ) {
4040 passed = true ;
41+ }
4142 return this ;
4243 }
4344
4445 protected synchronized AsyncCloseTest failed (String r ) {
4546 passed = false ;
46- reason = r ;
47+ reason . append ( String . format ( "%n - %s" , r )) ;
4748 return this ;
4849 }
4950
5051 public synchronized String failureReason () {
51- return reason ;
52+ return reason . length () > 0 ? reason . toString () : null ;
5253 }
5354
5455 protected synchronized void closed () {
@@ -60,6 +61,6 @@ protected synchronized boolean isClosed() {
6061 }
6162
6263 private boolean passed ;
63- private String reason ;
64+ private final StringBuilder reason = new StringBuilder () ;
6465 private boolean closed ;
6566}
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,7 @@ public DatagramSocket_receive() throws SocketException {
4040 public DatagramSocket_receive (int timeout ) throws SocketException {
4141 this .timeout = timeout ;
4242 latch = new CountDownLatch (1 );
43- s = new DatagramSocket ();
43+ s = new DatagramSocket (0 , InetAddress . getLoopbackAddress () );
4444 }
4545
4646 public String description () {
@@ -60,7 +60,7 @@ public void run() {
6060 }
6161 latch .countDown ();
6262 s .receive (p );
63- failed ("DatagramSocket.receive(DatagramPacket) returned unexpectly!!" );
63+ failed ("DatagramSocket.receive(DatagramPacket) returned unexpectly!!" + " - " + p . getAddress () );
6464 } catch (SocketException se ) {
6565 if (latch .getCount () != 1 ) {
6666 closed ();
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,7 @@ public ServerSocket_accept() throws IOException {
4141 public ServerSocket_accept (int timeout ) throws IOException {
4242 this .timeout = timeout ;
4343 latch = new CountDownLatch (1 );
44- ss = new ServerSocket (0 );
44+ ss = new ServerSocket (0 , 0 , InetAddress . getLoopbackAddress () );
4545 }
4646
4747 public String description () {
@@ -56,7 +56,7 @@ public void run() {
5656 try {
5757 latch .countDown ();
5858 Socket s = ss .accept ();
59- failed ("ServerSocket.accept() returned unexpectly!!" );
59+ failed ("ServerSocket.accept() returned unexpectly!!" + " - " + s );
6060 } catch (SocketException se ) {
6161 closed ();
6262 } catch (Exception e ) {
You can’t perform that action at this time.
0 commit comments