You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2015/01/15 17:15:39 UTC

svn commit: r1652159 - in /lucene/dev/branches/lucene_solr_5_0/solr: ./ core/ core/src/java/org/apache/solr/util/SolrPluginUtils.java core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java

Author: noble
Date: Thu Jan 15 16:15:38 2015
New Revision: 1652159

URL: http://svn.apache.org/r1652159
Log:
SOLR-6770 mask the useParams after expanding it

Modified:
    lucene/dev/branches/lucene_solr_5_0/solr/   (props changed)
    lucene/dev/branches/lucene_solr_5_0/solr/core/   (props changed)
    lucene/dev/branches/lucene_solr_5_0/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
    lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java?rev=1652159&r1=1652158&r2=1652159&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java Thu Jan 15 16:15:38 2015
@@ -31,6 +31,7 @@ import java.util.Set;
 import java.util.TreeMap;
 import java.util.regex.Pattern;
 
+import com.google.common.collect.ImmutableMap;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.index.IndexableField;
 import org.apache.lucene.search.BooleanClause;
@@ -115,6 +116,10 @@ public class SolrPluginUtils {
       purposes = Collections.unmodifiableMap(map);
   }
 
+  private static final MapSolrParams maskUseParams = new MapSolrParams(ImmutableMap.<String, String>builder()
+      .put(RequestParams.USEPARAM, "")
+      .build());
+
   /**
    * Set default-ish params on a SolrQueryRequest.
    *
@@ -131,8 +136,18 @@ public class SolrPluginUtils {
 
     List<String> paramNames =null;
     String useParams = req.getParams().get(RequestParams.USEPARAM);
+    if(useParams!=null && !useParams.isEmpty()){
+      // now that we have expanded the request macro useParams with the actual values
+      // it makes no sense to keep it visible now on.
+      // distrib request sends all params to the nodes down the line and
+      // if it sends the useParams to other nodes , they will expand them as well.
+      // which is not desirable. At the same time, because we send the useParams
+      // value as an empty string to other nodes we get the desired benefit of
+      // overriding the useParams specified in the requestHandler directly
+      req.setParams(SolrParams.wrapDefaults(maskUseParams,req.getParams()));
+    }
     if(useParams == null) useParams = (String) req.getContext().get(RequestParams.USEPARAM);
-    if(useParams !=null) paramNames = StrUtils.splitSmart(useParams, ',');
+    if(useParams !=null && !useParams.isEmpty()) paramNames = StrUtils.splitSmart(useParams, ',');
     if(paramNames != null){
         for (String name : paramNames) {
           SolrParams requestParams = req.getCore().getSolrConfig().getRequestParams().getParams(name);

Modified: lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java?rev=1652159&r1=1652158&r2=1652159&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java (original)
+++ lucene/dev/branches/lucene_solr_5_0/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java Thu Jan 15 16:15:38 2015
@@ -33,6 +33,7 @@ import org.apache.solr.common.cloud.Repl
 import org.apache.solr.common.cloud.Slice;
 import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.core.ConfigOverlay;
+import org.apache.solr.core.RequestParams;
 import org.apache.solr.core.TestSolrConfigHandler;
 import org.apache.solr.util.RESTfulServerProvider;
 import org.apache.solr.util.RestTestHarness;
@@ -129,13 +130,15 @@ public class TestSolrConfigHandlerCloud
         "/dump",
         10);
 
-    TestSolrConfigHandler.testForResponseElement(null,
+    result = TestSolrConfigHandler.testForResponseElement(null,
         urls.get(random().nextInt(urls.size())),
         "/dump?wt=json&useParams=x",
         cloudClient,
         asList("params", "a"),
         "A val",
         5);
+    compareValues(result, "", asList( "params", RequestParams.USEPARAM));
+
     TestSolrConfigHandler.testForResponseElement(null,
         urls.get(random().nextInt(urls.size())),
         "/dump?wt=json&useParams=x&a=fomrequest",