lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From md...@apache.org
Subject lucene-solr:master: SOLR-8392: Remove instanceof checks on return value of SolrParam::get
Date Mon, 12 Jun 2017 22:32:48 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master c51f6fae7 -> 94220a01e


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


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/94220a01
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/94220a01
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/94220a01

Branch: refs/heads/master
Commit: 94220a01e14f53e0632bfbc1678661ad9c67320a
Parents: c51f6fa
Author: Mike Drob <mdrob@apache.org>
Authored: Mon Jun 12 15:15:54 2017 -0700
Committer: Mike Drob <mdrob@apache.org>
Committed: Mon Jun 12 15:15:54 2017 -0700

----------------------------------------------------------------------
 solr/CHANGES.txt                                   |  2 ++
 .../org/apache/solr/handler/SchemaHandler.java     |  6 +-----
 .../org/apache/solr/rest/BaseSolrResource.java     |  6 ++----
 .../apache/solr/common/params/MapSolrParams.java   | 17 ++++-------------
 4 files changed, 9 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/94220a01/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 9135cfa..51d2d53 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -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.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/94220a01/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java b/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java
index e3e292b..626f655 100644
--- a/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/SchemaHandler.java
@@ -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) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/94220a01/solr/core/src/java/org/apache/solr/rest/BaseSolrResource.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/rest/BaseSolrResource.java b/solr/core/src/java/org/apache/solr/rest/BaseSolrResource.java
index 5a9310d..cc1eeb2 100644
--- a/solr/core/src/java/org/apache/solr/rest/BaseSolrResource.java
+++ b/solr/core/src/java/org/apache/solr/rest/BaseSolrResource.java
@@ -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);
 
           }
         }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/94220a01/solr/solrj/src/java/org/apache/solr/common/params/MapSolrParams.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/params/MapSolrParams.java b/solr/solrj/src/java/org/apache/solr/common/params/MapSolrParams.java
index 5454fca..53eff87 100644
--- a/solr/solrj/src/java/org/apache/solr/common/params/MapSolrParams.java
+++ b/solr/solrj/src/java/org/apache/solr/common/params/MapSolrParams.java
@@ -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


Mime
View raw message