Skip to content

Commit

Permalink
Add Duration overload to SlowLoadableComponent constructor (#13309)
Browse files Browse the repository at this point in the history
* Add Duration overload to SlowLoadableComponent constructor

* Deprecate SlowLoadableComponent(Clock, int)

* Formatting files

---------

Co-authored-by: Diego Molina <diemol@users.noreply.github.com>
Co-authored-by: Diego Molina <diemol@gmail.com>
  • Loading branch information
3 people committed Dec 19, 2023
1 parent 34e0986 commit 343aa78
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions java/src/org/openqa/selenium/support/ui/SlowLoadableComponent.java
Expand Up @@ -36,11 +36,19 @@ public abstract class SlowLoadableComponent<T extends LoadableComponent<T>>
extends LoadableComponent<T> {

private final Clock clock;
private final Duration timeOutInSeconds;
private final Duration timeOut;

public SlowLoadableComponent(java.time.Clock clock, int timeOutInSeconds) {
/**
* @deprecated Use {@link #SlowLoadableComponent(Clock, Duration)} instead.
*/
@Deprecated
public SlowLoadableComponent(Clock clock, int timeOutInSeconds) {
this(clock, Duration.ofSeconds(timeOutInSeconds));
}

public SlowLoadableComponent(Clock clock, Duration timeOut) {
this.clock = clock;
this.timeOutInSeconds = Duration.ofSeconds(timeOutInSeconds);
this.timeOut = timeOut;
}

@Override
Expand All @@ -53,7 +61,7 @@ public T get() {
load();
}

Instant end = clock.instant().plus(timeOutInSeconds);
Instant end = clock.instant().plus(timeOut);

while (clock.instant().isBefore(end)) {
try {
Expand Down

0 comments on commit 343aa78

Please sign in to comment.