Skip to content

Commit

Permalink
Null checks
Browse files Browse the repository at this point in the history
Signed-off-by: Bukhtawar Khan <[email protected]>
  • Loading branch information
Bukhtawar committed Jul 22, 2024
1 parent de8f6aa commit d3d78cf
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.apache.logging.log4j.Logger;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.common.util.concurrent.TimeoutAwareRunnable;
import org.opensearch.core.common.util.CollectionUtils;

import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -39,6 +40,9 @@ public void run() {
logger.debug("Starting execution of runnable of size [{}]", timeoutAwareRunnables.size());
Collections.shuffle(timeoutAwareRunnables);
long startTime = System.nanoTime();
if (CollectionUtils.isEmpty(timeoutAwareRunnables)) {
return;
}
for (TimeoutAwareRunnable workQueue : timeoutAwareRunnables) {
if (System.nanoTime() - startTime > timeoutSupplier.get().nanos()) {
workQueue.run();
Expand Down

0 comments on commit d3d78cf

Please sign in to comment.