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

This reverts commit 94220a01e1.
This commit is contained in:
Mike Drob 2017-06-13 14:18:52 -07:00
parent 9a0d9e83f6
commit d1db5f7af9
4 changed files with 22 additions and 9 deletions

View File

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

View File

@ -125,9 +125,11 @@ public abstract class BaseSolrResource extends ServerResource {
SolrCore.preDecorateResponse(solrRequest, solrResponse);
// client application can set a timeout for update requests
String updateTimeoutSecsParam = getSolrRequest().getParams().get(UPDATE_TIMEOUT_SECS);
Object updateTimeoutSecsParam = getSolrRequest().getParams().get(UPDATE_TIMEOUT_SECS);
if (updateTimeoutSecsParam != null)
updateTimeoutSecs = Integer.parseInt(updateTimeoutSecsParam);
updateTimeoutSecs = (updateTimeoutSecsParam instanceof Number)
? ((Number) updateTimeoutSecsParam).intValue()
: Integer.parseInt(updateTimeoutSecsParam.toString());
}
}

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,13 +31,22 @@ public class MapSolrParams extends SolrParams {
@Override
public String get(String name) {
return map.get(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);
}
@Override
public String[] getParams(String name) {
String val = map.get(name);
return val==null ? null : new String[]{val};
Object val = map.get(name);
if (val instanceof String[]) return (String[]) val;
return val==null ? null : new String[]{String.valueOf(val)};
}
@Override