lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From md...@apache.org
Subject lucene-solr:master: Revert "SOLR-8392: Remove instanceof checks on return value of SolrParam::get"
Date Tue, 13 Jun 2017 21:19:30 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master 9a0d9e83f -> d1db5f7af


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

This reverts commit 94220a01e14f53e0632bfbc1678661ad9c67320a.


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

Branch: refs/heads/master
Commit: d1db5f7af9edb2125583c6c63fa322380ee57cf7
Parents: 9a0d9e8
Author: Mike Drob <mdrob@apache.org>
Authored: Tue Jun 13 14:18:52 2017 -0700
Committer: Mike Drob <mdrob@apache.org>
Committed: Tue Jun 13 14:19:05 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, 22 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d1db5f7a/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 7810c81..a07b68f 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -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.

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

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

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d1db5f7a/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 53eff87..5454fca 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,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


Mime
View raw message