File tree Expand file tree Collapse file tree 3 files changed +10
-2
lines changed
main/java/org/elasticsearch/xpack/core/common/time
test/java/org/elasticsearch/xpack/core/common/time Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -236,8 +236,6 @@ tests:
236236- class : org.elasticsearch.snapshots.SnapshotShutdownIT
237237 method : testRestartNodeDuringSnapshot
238238 issue : https://github.com/elastic/elasticsearch/issues/116730
239- - class : org.elasticsearch.xpack.inference.InferenceRestIT
240- issue : https://github.com/elastic/elasticsearch/issues/116740
241239- class : org.elasticsearch.action.search.SearchRequestTests
242240 method : testSerializationConstants
243241 issue : https://github.com/elastic/elasticsearch/issues/116752
Original file line number Diff line number Diff line change @@ -18,8 +18,13 @@ public interface RemainingTime extends Supplier<TimeValue> {
1818 * Create a {@link Supplier} that returns a decreasing {@link TimeValue} on each invocation, representing the amount of time until
1919 * the call times out. The timer starts when this method is called and counts down from remainingTime to 0.
2020 * currentTime should return the most up-to-date system time, for example Instant.now() or Clock.instant().
21+ * {@link TimeValue#MAX_VALUE} is a special case where the remaining time is always TimeValue.MAX_VALUE.
2122 */
2223 static RemainingTime from (Supplier <Instant > currentTime , TimeValue remainingTime ) {
24+ if (remainingTime .equals (TimeValue .MAX_VALUE )) {
25+ return () -> TimeValue .MAX_VALUE ;
26+ }
27+
2328 var timeout = currentTime .get ().plus (remainingTime .duration (), remainingTime .timeUnit ().toChronoUnit ());
2429 var maxRemainingTime = remainingTime .nanos ();
2530 return () -> {
Original file line number Diff line number Diff line change @@ -32,6 +32,11 @@ public void testRemainingTimeMaxValue() {
3232 assertThat (remainingTime .get (), Matchers .equalTo (TimeValue .ZERO ));
3333 }
3434
35+ public void testMaxTime () {
36+ var remainingTime = RemainingTime .from (Instant ::now , TimeValue .MAX_VALUE );
37+ assertThat (remainingTime .get (), Matchers .equalTo (TimeValue .MAX_VALUE ));
38+ }
39+
3540 // always add the first value, which is read when RemainingTime.from is called, then add the test values
3641 private Supplier <Instant > times (Instant ... instants ) {
3742 var startTime = Stream .of (Instant .now ());
You can’t perform that action at this time.
0 commit comments