[
https://issues.apache.org/jira/browse/SOLR-6547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14184481#comment-14184481
]
Anurag Sharma commented on SOLR-6547:
-------------------------------------
QTime is saved as long after truncating nano second part of time. This is
equivalent to capturing the time in milliseconds. Here is the code snippet of
what's happening in the CloudSolrServer.
{code}
long start = System.nanoTime();
.
.
long end = System.nanoTime();
RouteResponse rr = condenseResponse(shardResponses, (long)((end -
start)/1000000));
{code}
condenseResponse function
{code}
public RouteResponse condenseResponse(NamedList response, long timeMillis) {
.
.
cheader.add("QTime", timeMillis);
.
.
}
{code}
Since the time in seconds can be captured with Integer, there are two ways to
fix the issue:
# In CloudSolrServer, truncate the milliseconds part as well and save QTime in
Integer. This way getQTime won't throw Long to Integer ClassCastException as
the object coming to it already Integer.
# In SolrResponseBase.getQTime function, check the instanceOf Object and get
integer from it as shown in the code snippet below
{code}
int qtime = 0;
if(obj instanceof Long) {
qtime = (int)(((Long) obj).longValue()/1000);
} else if (obj instanceof Integer) {
qtime = (Integer)obj;
} else if (obj instanceof String) {
qtime = Integer.parseInt((String) obj);
}
return qtime;
{code}
Please vote for proceeding the best approach. Also like to get opinion on
writing unit test in CloudSolrServerTest class.
> CloudSolrServer query getqtime Exception
> ----------------------------------------
>
> Key: SOLR-6547
> URL: https://issues.apache.org/jira/browse/SOLR-6547
> Project: Solr
> Issue Type: Bug
> Components: SolrJ
> Affects Versions: 4.10
> Reporter: kevin
>
> We are using CloudSolrServer to query ,but solrj throw Exception ;
> java.lang.ClassCastException: java.lang.Long cannot be cast to
> java.lang.Integer at
> org.apache.solr.client.solrj.response.SolrResponseBase.getQTime(SolrResponseBase.java:76)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]