You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2018/01/03 20:54:29 UTC

lucene-solr:branch_7x: SOLR-11805: SolrJ's SolrResponse.getElaspedTime was sometimes a millisecond off

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x c775a80d5 -> e3f62c346


SOLR-11805: SolrJ's SolrResponse.getElaspedTime was sometimes a millisecond off

(cherry picked from commit 9586d12)


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/e3f62c34
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/e3f62c34
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/e3f62c34

Branch: refs/heads/branch_7x
Commit: e3f62c3461f57326c4f64d1e2f0dabae93140c0f
Parents: c775a80
Author: David Smiley <ds...@apache.org>
Authored: Wed Jan 3 15:47:32 2018 -0500
Committer: David Smiley <ds...@apache.org>
Committed: Wed Jan 3 15:54:24 2018 -0500

----------------------------------------------------------------------
 solr/CHANGES.txt                                               | 2 ++
 .../src/java/org/apache/solr/client/solrj/SolrRequest.java     | 6 +++---
 .../src/java/org/apache/solr/client/solrj/SolrResponse.java    | 2 ++
 3 files changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e3f62c34/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index e818828..1723692 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -85,6 +85,8 @@ Other Changes
 
 * SOLR-11748: Remove Autoscaling action throttle. (shalin)
 
+* SOLR-11805: SolrJ's SolrResponse.getElaspedTime was sometimes a millisecond off. (David Smiley)
+
 ==================  7.2.0 ==================
 
 Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e3f62c34/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java
index 37ce166..7dbaab9 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java
@@ -189,11 +189,11 @@ public abstract class SolrRequest<T extends SolrResponse> implements Serializabl
    * @throws IOException if there is a communication error
    */
   public final T process(SolrClient client, String collection) throws SolrServerException, IOException {
-    long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
+    long startNanos = System.nanoTime();
     T res = createResponse(client);
     res.setResponse(client.request(this, collection));
-    long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
-    res.setElapsedTime(endTime - startTime);
+    long endNanos = System.nanoTime();
+    res.setElapsedTime(TimeUnit.NANOSECONDS.toMillis(endNanos - startNanos));
     return res;
   }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e3f62c34/solr/solrj/src/java/org/apache/solr/client/solrj/SolrResponse.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrResponse.java b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrResponse.java
index 9987b96..d3da151 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrResponse.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrResponse.java
@@ -33,6 +33,8 @@ import java.io.Serializable;
  * @since solr 1.3
  */
 public abstract class SolrResponse implements Serializable {
+
+  /** Elapsed time in milliseconds for the request as seen from the client. */
   public abstract long getElapsedTime();
   
   public abstract void setResponse(NamedList<Object> rsp);