dsmiley commented on code in PR #3270:
URL: https://github.com/apache/solr/pull/3270#discussion_r2006358760


##########
solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java:
##########
@@ -256,12 +257,15 @@ public RequestWriter.ContentWriter 
getContentWriter(String expectedType) {
   public final T process(SolrClient client, String collection)
       throws SolrServerException, IOException {
     long startNanos = System.nanoTime();
-    T res = createResponse(client);
     var namedList = client.request(this, collection);
-    res.setResponse(namedList);
     long endNanos = System.nanoTime();
-    res.setElapsedTime(TimeUnit.NANOSECONDS.toMillis(endNanos - startNanos));
-    return res;
+    final T typedResponse = createResponse(namedList);
+    // SolrResponse is pre-V2 API
+    if (typedResponse instanceof SolrResponse res) {
+      res.setResponse(namedList); // TODO insist createResponse does this ?
+      res.setElapsedTime(TimeUnit.NANOSECONDS.toMillis(endNanos - startNanos));
+    }

Review Comment:
   At the start, I considered maybe the V2 API's responses should subclass 
SolrResponse.  One stumbling block is that those responses are in the "api" 
module, which doesn't have a backwards dependency on SolrJ where SolrResponse 
is.  Instead of tackling that, I questioned do we really want it anyway.  I 
think we don't.  I like the open-ended flexibility allowed in this PR.  We 
could have a custom request that wants to return an Integer and it'd return 
exactly that; not obscured in some other layer to obtain it out of. 
   
   The only extra/contextual info here is the elapsed time.  If you think 
there's something else then please share what that is.  So on the time... I 
dunno.  Yeah it's nice to have I guess.... but honestly I don't use it.  I care 
about the time in observability (logs, metrics, tracing), not actually in the 
API.  Obviously the user/caller could easily measure the time if they wanted to.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to