Jack Krupansky created SOLR-4427:
------------------------------------
Summary: Solr should complain with a readable warning if more than
one of a plugin type occurs in solrconfig.xml and only one is used
Key: SOLR-4427
URL: https://issues.apache.org/jira/browse/SOLR-4427
Project: Solr
Issue Type: Bug
Components: Schema and Analysis
Affects Versions: 4.0
Reporter: Jack Krupansky
While some Solr plugin types such as request handlers can have multiple entries
in solrconfig.xml, others such as <queryConverter> and <directoryFactory> can
syntactically have more than one, but only the first one will be used and the
other plugins of that type will be silently ignored. This is problematic when
someone "adds" a new plugin and is unaware of or forgets to remove or comment
out an existing plugin of that same type earlier in solrconfig.xml. The new
plugin has no effect and it is not obvious how to debug the problem.
Repro:
Add a second <directoryFactory> to the Solr example solrconfig.xml after the
existing one:
{code}
<directoryFactory name="DirectoryFactory"
class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}" />
<directoryFactory name="MyDirectoryFactory"
class="solr.NRTCachingDirectoryFactory">
<double name="maxMergeSizeMB">7.5</double>
<double name="maxCachedMB">37.25</double>
</directoryFactory>
{code}
Start Solr after deleting the data directory.
See that the default values of "maxMergeSizeMB" and "maxCachedMB" are being
used rather than the overrides specified above. In other words, the first
directory factory plugin is being used, and the second is silently ignored.
One possible fix, would be in SolrConfig#getPluginInfo to change:
{code}
public PluginInfo getPluginInfo(String type){
List<PluginInfo> result = pluginStore.get(type);
return result == null || result.isEmpty() ? null: result.get(0);
}
{code}
to
{code}
public PluginInfo getPluginInfo(String type){
List<PluginInfo> result = pluginStore.get(type);
if (result != null && result.size() > 1)
log.warn("Multiple plugins of type '" + type + "' found (" +
result.size() +
") - only the first will be used: name: " + result.get(0).name +
" class: " + result.get(0).className);
return result == null || result.isEmpty() ? null: result.get(0);
}
{code}
Another possibility is to throw an exception.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]