SOLR-8392: Remove instanceof checks on return value of SolrParam::get

This commit is contained in:
Mike Drob 2017-06-12 15:15:54 -07:00
parent c51f6fae75
commit 94220a01e1
4 changed files with 9 additions and 22 deletions

View File

@ -256,6 +256,8 @@ Other Changes
* SOLR-10800: Factor out HttpShardHandler.transformReplicasToShardUrls from HttpShardHandler.prepDistributed.
(Domenico Fabio Marino, Christine Poerschke)
* SOLR-8392: Remove instanceof checks on return value of SolrParam::get (Mike Drob, Varun Thacker)
================== 6.7.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

View File

@ -138,11 +138,7 @@ public class SchemaHandler extends RequestHandlerBase implements SolrCoreAware,
break;
}
case "/schema/zkversion": {
int refreshIfBelowVersion = -1;
Object refreshParam = req.getParams().get("refreshIfBelowVersion");
if (refreshParam != null)
refreshIfBelowVersion = (refreshParam instanceof Number) ? ((Number) refreshParam).intValue()
: Integer.parseInt(refreshParam.toString());
int refreshIfBelowVersion = req.getParams().getInt("refreshIfBelowVersion", -1);
int zkVersion = -1;
IndexSchema schema = req.getSchema();
if (schema instanceof ManagedIndexSchema) {

View File

@ -125,11 +125,9 @@ public abstract class BaseSolrResource extends ServerResource {
SolrCore.preDecorateResponse(solrRequest, solrResponse);
// client application can set a timeout for update requests
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);
}
}

View File

@ -20,7 +20,7 @@ import java.util.Iterator;
import java.util.Map;
/**
*
* {@link SolrParams} implementation that can be built from and is backed by a {@link Map}.
*/
public class MapSolrParams extends SolrParams {
protected final Map<String,String> map;
@ -31,22 +31,13 @@ public class MapSolrParams extends SolrParams {
@Override
public String get(String name) {
Object o = map.get(name);
if(o == null) return null;
if (o instanceof String) return (String) o;
if (o instanceof String[]) {
String[] strings = (String[]) o;
if(strings.length == 0) return null;
return strings[0];
}
return String.valueOf(o);
return map.get(name);
}
@Override
public String[] getParams(String name) {
Object val = map.get(name);
if (val instanceof String[]) return (String[]) val;
return val==null ? null : new String[]{String.valueOf(val)};
String val = map.get(name);
return val==null ? null : new String[]{val};
}
@Override