diff --git a/java/client/src/org/openqa/selenium/support/ui/Sleeper.java b/java/client/src/org/openqa/selenium/support/ui/Sleeper.java index 82e5810cdeb72..52782e2f12354 100644 --- a/java/client/src/org/openqa/selenium/support/ui/Sleeper.java +++ b/java/client/src/org/openqa/selenium/support/ui/Sleeper.java @@ -17,6 +17,7 @@ package org.openqa.selenium.support.ui; +import java.time.temporal.ChronoUnit; import java.util.concurrent.TimeUnit; /** @@ -24,26 +25,7 @@ */ public interface Sleeper { - public static final Sleeper SYSTEM_SLEEPER = new Sleeper() { - - /** - * Sleeps for the specified duration of time. - * - * @deprecated use {@link #sleep(java.time.Duration)} - * - * @param duration How long to sleep. - * @throws InterruptedException If the thread is interrupted while sleeping. - */ - @Deprecated - public void sleep(Duration duration) throws InterruptedException { - Thread.sleep(duration.in(TimeUnit.MILLISECONDS)); - } - - @Override - public void sleep(java.time.Duration duration) throws InterruptedException { - Thread.sleep(duration.toMillis()); - } - }; + Sleeper SYSTEM_SLEEPER = duration -> Thread.sleep(duration.toMillis()); /** * Sleeps for the specified duration of time. @@ -54,7 +36,9 @@ public void sleep(java.time.Duration duration) throws InterruptedException { * @throws InterruptedException If the thread is interrupted while sleeping. */ @Deprecated - void sleep(Duration duration) throws InterruptedException; + default void sleep(Duration duration) throws InterruptedException { + sleep(java.time.Duration.of(duration.in(TimeUnit.MILLISECONDS), ChronoUnit.MICROS)); + } /** * Sleeps for the specified duration of time. diff --git a/java/client/test/org/openqa/selenium/support/ui/TickingClock.java b/java/client/test/org/openqa/selenium/support/ui/TickingClock.java index 7d73847768dbf..3060b1a6d7bec 100644 --- a/java/client/test/org/openqa/selenium/support/ui/TickingClock.java +++ b/java/client/test/org/openqa/selenium/support/ui/TickingClock.java @@ -17,8 +17,6 @@ package org.openqa.selenium.support.ui; -import java.util.concurrent.TimeUnit; - public class TickingClock implements Clock, Sleeper { private long now = 0; @@ -34,12 +32,8 @@ public boolean isNowBefore(long endInMillis) { return now < endInMillis; } - public void sleep(Duration duration) { - now += duration.in(TimeUnit.MILLISECONDS); - } - @Override - public void sleep(java.time.Duration duration) throws InterruptedException { + public void sleep(java.time.Duration duration) { now += duration.toMillis(); } }