You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2018/03/26 11:29:49 UTC
lucene-solr:branch_7x: SOLR-12087: Fixed bug in TimeOut.waitFor that
can cause an infinite loop and added javadocs
Repository: lucene-solr
Updated Branches:
refs/heads/branch_7x 13fdd07e2 -> 983a443b2
SOLR-12087: Fixed bug in TimeOut.waitFor that can cause an infinite loop and added javadocs
(cherry picked from commit b0f677c)
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/983a443b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/983a443b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/983a443b
Branch: refs/heads/branch_7x
Commit: 983a443b2fb72dfe08d1a0919ed7ac31ceb8a89f
Parents: 13fdd07
Author: Shalin Shekhar Mangar <sh...@apache.org>
Authored: Mon Mar 26 16:58:56 2018 +0530
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Mon Mar 26 16:59:42 2018 +0530
----------------------------------------------------------------------
solr/core/src/java/org/apache/solr/util/TimeOut.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/983a443b/solr/core/src/java/org/apache/solr/util/TimeOut.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/TimeOut.java b/solr/core/src/java/org/apache/solr/util/TimeOut.java
index 52694e9..ce996f4 100644
--- a/solr/core/src/java/org/apache/solr/util/TimeOut.java
+++ b/solr/core/src/java/org/apache/solr/util/TimeOut.java
@@ -51,9 +51,16 @@ public class TimeOut {
return unit.convert(timeSource.getTimeNs() - startTime, NANOSECONDS);
}
+ /**
+ * Wait until the given {@link Supplier} returns true or the time out expires which ever happens first
+ * @param messageOnTimeOut the exception message to be used in case a TimeoutException is thrown
+ * @param supplier a {@link Supplier} that returns a {@link Boolean} value
+ * @throws InterruptedException if any thread has interrupted the current thread
+ * @throws TimeoutException if the timeout expires
+ */
public void waitFor(String messageOnTimeOut, Supplier<Boolean> supplier)
throws InterruptedException, TimeoutException {
- while (!supplier.get() && hasTimedOut()) {
+ while (!supplier.get() && !hasTimedOut()) {
Thread.sleep(500);
}
if (hasTimedOut()) throw new TimeoutException(messageOnTimeOut);