Skip to content

Apache Lucene open-source search software

SOLR-6476

Noble Paulc48f927d1073
diff --git a/solr/core/src/java/org/apache/solr/schema/SchemaManager.java b/solr/core/src/java/org/apache/solr/schema/SchemaManager.java
index 096031f2e37..6ca05e624f5 100644
--- a/solr/core/src/java/org/apache/solr/schema/SchemaManager.java
+++ b/solr/core/src/java/org/apache/solr/schema/SchemaManager.java
@@ -39,6 +39,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import static java.util.Collections.EMPTY_LIST;
import static java.util.Collections.EMPTY_MAP;
@@ -156,15 +157,13 @@ public class SchemaManager {
String collection = cd.getCollectionName();
if (collection != null) {
ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader) managedIndexSchema.getResourceLoader();
- long timeLeftSecs1 = timeout - ((System.nanoTime() - startTime) /1000000);
- int secsLeft = (int) (timeLeftSecs1 > 0 ? timeLeftSecs1 : -1);
- if(secsLeft<=0) throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Not enough time left to update replicas. However the schema is updated already");
- long timeLeftSecs = timeout - ((System.nanoTime() - startTime) /1000000);
+ long timeLeftSecs = timeout - TimeUnit.SECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS);
+ if(timeLeftSecs<=0) throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Not enough time left to update replicas. However the schema is updated already");
ManagedIndexSchema.waitForSchemaZkVersionAgreement(collection,
cd.getCloudDescriptor().getCoreNodeName(),
(managedIndexSchema).getSchemaZkVersion(),
zkLoader.getZkController(),
- (int) (timeLeftSecs > 0 ? timeLeftSecs : -1));
+ (int) timeLeftSecs);
}
}