Skip to content

Commit 10ac2fd

Browse files
committed
Enforce a minimum task execution and service time of 1 nanosecond
Resolves #27371
1 parent 8ed0120 commit 10ac2fd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/src/main/java/org/elasticsearch/common/util/concurrent/TimedRunnable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ long getTotalNanos() {
7979
// There must have been an exception thrown, the total time is unknown (-1)
8080
return -1;
8181
}
82-
return finishTimeNanos - creationTimeNanos;
82+
return Math.max(finishTimeNanos - creationTimeNanos, 1);
8383
}
8484

8585
/**
@@ -91,7 +91,7 @@ long getTotalExecutionNanos() {
9191
// There must have been an exception thrown, the total time is unknown (-1)
9292
return -1;
9393
}
94-
return finishTimeNanos - startTimeNanos;
94+
return Math.max(finishTimeNanos - startTimeNanos, 1);
9595
}
9696

9797
}

0 commit comments

Comments
 (0)