test/jdk/sun/net/InetAddress/nameservice/simple/DefaultCaching.java
changeset 58009 0daf32316b47
parent 54984 8f7d232b4225
--- a/test/jdk/sun/net/InetAddress/nameservice/simple/DefaultCaching.java	Wed Sep 04 17:36:53 2019 +0100
+++ b/test/jdk/sun/net/InetAddress/nameservice/simple/DefaultCaching.java	Wed Sep 04 18:10:07 2019 +0100
@@ -101,8 +101,22 @@
 
     static void sleep(int seconds) {
         try {
-            Thread.sleep(seconds * 1000);
-        } catch (InterruptedException e) {}
+            sleepms(seconds * 1000);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
+    static long sleepms(long millis) throws InterruptedException {
+        long start = System.nanoTime();
+        long ms = millis;
+        while (ms > 0) {
+            assert ms < Long.MAX_VALUE/1000_000L;
+            Thread.sleep(ms);
+            long elapsedms = (System.nanoTime() - start)/1000_000L;
+            ms = millis - elapsedms;
+        }
+        return millis - ms;
     }
 
     static void test(String host, String address, boolean shouldSucceed) {
@@ -114,7 +128,7 @@
                                            + addr + ")");
             }
             if (!address.equals(addr.getHostAddress())) {
-                throw new RuntimeException(host+":"+address+": compare failed (found "
+                throw new RuntimeException(host+"/"+address+": compare failed (found "
                                            + addr + ")");
             }
             System.out.println("test: " + host + "/" + address