8143016: java/time/test/java/time/TestClock_System.java failed intermittently
authorrriggs
Mon, 01 Feb 2016 14:50:06 -0500
changeset 35613 4c29bcd3a107
parent 35612 500ebb7a5ed9
child 35635 81b06244c712
8143016: java/time/test/java/time/TestClock_System.java failed intermittently Reviewed-by: lancea, scolebourne
jdk/test/java/time/test/java/time/TestClock_System.java
--- a/jdk/test/java/time/test/java/time/TestClock_System.java	Mon Feb 01 10:13:48 2016 -0500
+++ b/jdk/test/java/time/test/java/time/TestClock_System.java	Mon Feb 01 14:50:06 2016 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, 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
@@ -179,11 +179,17 @@
 
             int count=0;
             // let's preheat the system a bit:
+            int lastNanos = 0;
             for (int i = 0; i < 1000 ; i++) {
                 system1 = Instant.ofEpochMilli(System.currentTimeMillis());
-                highest1 = highestUTC.instant();
                 final int sysnan = system1.getNano();
-                final int nanos = highest1.getNano();
+                int nanos;
+                do {
+                    highest1 = highestUTC.instant();
+                    nanos = highest1.getNano();
+                } while (nanos == lastNanos); // Repeat to get a different value
+                lastNanos = nanos;
+
                 if ((nanos % 1000000) > 0) {
                     count++; // we have micro seconds
                 }