# HG changeset patch # User mli # Date 1571290446 -28800 # Node ID d2108d9fc4f50342980edc229cc31f50ff2e6d46 # Parent 7a81cc7ca25ccb3714ff211ed692d2d7c045ff35 8134599: TEST_BUG: java/rmi/transport/closeServerSocket/CloseServerSocket.java fails intermittently with Address already in use Reviewed-by: weijun, darcy, rriggs, coffeys diff -r 7a81cc7ca25c -r d2108d9fc4f5 test/jdk/java/rmi/transport/closeServerSocket/CloseServerSocket.java --- a/test/jdk/java/rmi/transport/closeServerSocket/CloseServerSocket.java Thu Oct 17 13:18:01 2019 +0800 +++ b/test/jdk/java/rmi/transport/closeServerSocket/CloseServerSocket.java Thu Oct 17 13:34:06 2019 +0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2019, 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 @@ -63,8 +63,19 @@ verifyPortInUse(PORT); UnicastRemoteObject.unexportObject(registry, true); System.err.println("- unexported registry"); - Thread.sleep(1000); // work around BindException (bug?) - verifyPortFree(PORT); + int tries = (int)TestLibrary.getTimeoutFactor(); + tries = Math.max(tries, 1); + while (tries-- > 0) { + Thread.sleep(1000); + try { + verifyPortFree(PORT); + break; + } catch (IOException ignore) { } + } + if (tries < 0) { + throw new RuntimeException("time out after tries: " + tries); + } + /* * The follow portion of this test is disabled temporarily @@ -101,6 +112,7 @@ private static void verifyPortInUse(int port) throws IOException { try { verifyPortFree(port); + throw new RuntimeException("port is not in use: " + port); } catch (BindException e) { System.err.println("- port " + port + " is in use"); return;