SOLR-8126: update-<component-name> does not work if the component is only

present in solrconfig.xml

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1711943 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Noble Paul 2015-11-02 12:22:14 +00:00
parent 7f8b3db927
commit 07202b9a42
5 changed files with 41 additions and 8 deletions

View File

@ -304,6 +304,9 @@ Bug Fixes
* SOLR-8206: JSON Facet API limit:0 did not always work correctly. (yonik)
* SOLR-8126: update-<component-name> does not work if the component is only
present in solrconfig.xml (noble)
Optimizations
----------------------

View File

@ -444,7 +444,7 @@ public class SolrConfigHandler extends RequestHandlerBase {
op.getMap(PluginInfo.APPENDS, null);
if (op.hasError()) return overlay;
if (!verifyClass(op, clz, info.clazz)) return overlay;
if (overlay.getNamedPlugins(info.getCleanTag()).containsKey(name)) {
if (pluginExists(info, overlay, name)) {
if (isCeate) {
op.addError(formatString(" ''{0}'' already exists . Do an ''{1}'' , if you want to change it ", name, "update-" + info.getTagCleanLower()));
return overlay;
@ -461,6 +461,12 @@ public class SolrConfigHandler extends RequestHandlerBase {
}
}
private boolean pluginExists(SolrConfig.SolrPluginInfo info, ConfigOverlay overlay, String name) {
List<PluginInfo> l = req.getCore().getSolrConfig().getPluginInfos(info.clazz.getName());
for (PluginInfo pluginInfo : l) if(name.equals( pluginInfo.name)) return true;
return overlay.getNamedPlugins(info.getCleanTag()).containsKey(name);
}
private boolean verifyClass(CommandOperation op, String clz, Class expected) {
if (clz == null) return true;
if (!"true".equals(String.valueOf(op.getStr("runtimeLib", null)))) {

View File

@ -108,6 +108,13 @@
<str name="replacement">x_x</str>
</processor>
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>
</updateRequestProcessorChain>
<requestHandler name="/dump" class="DumpRequestHandler" initParams="a">
<lst name="defaults">
<str name="a">A</str>
<str name="b">B</str>
</lst>
</requestHandler>
</config>

View File

@ -49,6 +49,7 @@ import org.restlet.ext.servlet.ServerServlet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.apache.solr.BaseDistributedSearchTestCase.log;
import static org.apache.solr.common.util.Utils.getObjectByPath;
import static org.apache.solr.handler.TestBlobHandler.getAsString;
@ -201,6 +202,22 @@ public class TestSolrConfigHandler extends RestTestBase {
"b",
10);
payload = "{\n" +
"'update-requesthandler' : { 'name' : '/dump', " +
"'initParams': 'a'," +
"'class': 'org.apache.solr.handler.DumpRequestHandler' ," +
" 'defaults': {'a':'A','b':'B','c':'C'}}\n" +
"}";
runConfigCommand(writeHarness, "/config?wt=json", payload);
testForResponseElement(writeHarness,
testServerBaseUrl,
"/config/overlay?wt=json",
cloudSolrClient,
Arrays.asList("overlay", "requestHandler", "/dump", "defaults", "c" ),
"C",
10);
testForResponseElement(writeHarness,
testServerBaseUrl,
"/x?wt=json&getdefaults=true&json.nl=map",
@ -473,7 +490,7 @@ public class TestSolrConfigHandler extends RestTestBase {
10);
payload = "{\n" +
"'create-requesthandler' : { 'name' : '/dump', 'class': 'org.apache.solr.handler.DumpRequestHandler' }\n" +
"'create-requesthandler' : { 'name' : '/d', 'class': 'org.apache.solr.handler.DumpRequestHandler' }\n" +
"}";
TestSolrConfigHandler.runConfigCommand(harness, "/config?wt=json", payload);
@ -483,20 +500,20 @@ public class TestSolrConfigHandler extends RestTestBase {
null,
"/config/overlay?wt=json",
null,
Arrays.asList("overlay", "requestHandler", "/dump", "name"),
"/dump",
Arrays.asList("overlay", "requestHandler", "/d", "name"),
"/d",
10);
TestSolrConfigHandler.testForResponseElement(harness,
null,
"/dump?wt=json&useParams=x",
"/d?wt=json&useParams=x",
null,
Arrays.asList("params", "a"),
"A val",
5);
TestSolrConfigHandler.testForResponseElement(harness,
null,
"/dump?wt=json&useParams=x&a=fomrequest",
"/d?wt=json&useParams=x&a=fomrequest",
null,
Arrays.asList("params", "a"),
"fomrequest",

View File

@ -146,7 +146,7 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase {
compareValues(result, "B val", asList("response", "params", "x", "b"));
payload = "{\n" +
"'create-requesthandler' : { 'name' : '/dump', 'class': 'org.apache.solr.handler.DumpRequestHandler' }\n" +
"'update-requesthandler' : { 'name' : '/dump', 'class': 'org.apache.solr.handler.DumpRequestHandler' }\n" +
"}";
TestSolrConfigHandler.runConfigCommand(writeHarness, "/config?wt=json", payload);