You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Varun Thacker (JIRA)" <ji...@apache.org> on 2015/12/09 07:35:10 UTC

[jira] [Commented] (SOLR-8392) SolrParam.get(String) returns String and shouldn't be used in other instanceof checks

    [ https://issues.apache.org/jira/browse/SOLR-8392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15048141#comment-15048141 ] 

Varun Thacker commented on SOLR-8392:
-------------------------------------

Hi Mike,

Instead of this in your patch - 

{code}
-            Object updateTimeoutSecsParam = getSolrRequest().getParams().get(UPDATE_TIMEOUT_SECS);
+            String updateTimeoutSecsParam = getSolrRequest().getParams().get(UPDATE_TIMEOUT_SECS);
             if (updateTimeoutSecsParam != null)
-              updateTimeoutSecs = (updateTimeoutSecsParam instanceof Number)
-                  ? ((Number) updateTimeoutSecsParam).intValue()
-                  : Integer.parseInt(updateTimeoutSecsParam.toString());
+              updateTimeoutSecs = Integer.parseInt(updateTimeoutSecsParam);
{code}

It's okay if we just do {{updateTimeoutSecs = getSolrRequest().getParams().getInt(UPDATE_TIMEOUT_SECS);}} right? SchemaManager#doOperations deals with the case of updateTimeoutSecs being null .

On a side note, Why should MapSolrParams support the {{getParams}} method. We have {{MultiMapSolrParams}} if someone wants to have multiple values for a key. I tried playing around and have {{MapSolrParams#getParams}} throw a {{UnsupportedOperationException}} but looks like it will involve a fair amount of refactoring to get that working.

> SolrParam.get(String) returns String and shouldn't be used in other instanceof checks
> -------------------------------------------------------------------------------------
>
>                 Key: SOLR-8392
>                 URL: https://issues.apache.org/jira/browse/SOLR-8392
>             Project: Solr
>          Issue Type: Bug
>            Reporter: Mike Drob
>             Fix For: Trunk
>
>         Attachments: SOLR-8392.patch
>
>
> There's a couple of places where we declare the return type of solrParams.get() as an Object and then do instanceof checks for other types. Since we know it will be a String, we can simplify this logic in several places.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org