lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sar...@apache.org
Subject svn commit: r1674866 - /lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrQueryTimeoutImpl.java
Date Mon, 20 Apr 2015 14:25:52 GMT
Author: sarowe
Date: Mon Apr 20 14:25:52 2015
New Revision: 1674866

URL: http://svn.apache.org/r1674866
Log:
SOLR-7419: document intentional overflow in SolrQueryTimeoutImpl thread local

Modified:
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrQueryTimeoutImpl.java

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrQueryTimeoutImpl.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrQueryTimeoutImpl.java?rev=1674866&r1=1674865&r2=1674866&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrQueryTimeoutImpl.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrQueryTimeoutImpl.java Mon
Apr 20 14:25:52 2015
@@ -33,6 +33,23 @@ public class SolrQueryTimeoutImpl implem
    * The ThreadLocal variable to store the time beyond which, the processing should exit.
    */
   public static ThreadLocal<Long> timeoutAt = new ThreadLocal<Long>() {
+    /**
+     * {@inheritDoc}
+     * <p>
+     * By default, timeoutAt is set as far in the future as possible, 
+     * so that it effectively never happens.
+     * <p>
+     * Since nanoTime() values can be anything from Long.MIN_VALUE to
+     * Long.MAX_VALUE, adding Long.MAX_VALUE can cause overflow.  That's
+     * expected and works fine, since in that case the subtraction of a
+     * future nanoTime() value from timeoutAt (in 
+     * {@link SolrQueryTimeoutImpl#shouldExit}) will result in underflow,
+     * and checking the sign of the result of that subtraction (via
+     * comparison to zero) will correctly indicate whether the future
+     * nanoTime() value has exceeded the timeoutAt value.
+     * <p> 
+     * See {@link System#nanoTime}
+     */
     @Override
     protected Long initialValue() {
       return nanoTime() + Long.MAX_VALUE;



Mime
View raw message