SOLR-5691: Sharing non thread safe WeakHashMap across thread can cause problems.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1565069 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2014-02-06 04:47:42 +00:00
parent 801c267066
commit 4ed5b93abf
3 changed files with 13 additions and 10 deletions

View File

@ -282,6 +282,9 @@ Bug Fixes
* SOLR-4072: Error message is incorrect for linkconfig in ZkCLI.
(Vamsee Yarlagadda, Adam Hahn, via Mark Miller)
* SOLR-5691: Sharing non thread safe WeakHashMap across thread can cause
problems. (Bojan Smid, Mark Miller)
Optimizations
----------------------

View File

@ -18,6 +18,7 @@
package org.apache.solr.core;
import static org.apache.solr.core.SolrConfig.PluginOpts.*;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.schema.IndexSchemaFactory;
@ -28,11 +29,11 @@ import org.apache.solr.handler.component.SearchComponent;
import org.apache.solr.request.SolrRequestHandler;
import org.apache.solr.response.QueryResponseWriter;
import org.apache.solr.response.transform.TransformerFactory;
import org.apache.solr.search.CacheConfig;
import org.apache.solr.search.FastLRUCache;
import org.apache.solr.search.QParserPlugin;
import org.apache.solr.search.ValueSourceParser;
import org.apache.solr.servlet.SolrRequestParsers;
import org.apache.solr.update.SolrIndexConfig;
import org.apache.solr.update.UpdateLog;
import org.apache.solr.update.processor.UpdateRequestProcessorChain;
@ -40,10 +41,8 @@ import org.apache.solr.spelling.QueryConverter;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.index.IndexDeletionPolicy;
import org.apache.lucene.util.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
@ -89,6 +88,8 @@ public class SolrConfig extends Config {
private boolean handleSelect;
private boolean addHttpRequestToContext;
private final SolrRequestParsers solrRequestParsers;
/** Creates a default instance from the solrconfig.xml. */
public SolrConfig()
@ -285,6 +286,7 @@ public class SolrConfig extends Config {
addHttpRequestToContext = getBool(
"requestDispatcher/requestParsers/@addHttpRequestToContext", false );
solrRequestParsers = new SolrRequestParsers(this);
Config.log.info("Loaded SolrConfig: " + name);
}
@ -324,6 +326,10 @@ public class SolrConfig extends Config {
}
return result;
}
public SolrRequestParsers getRequestParsers() {
return solrRequestParsers;
}
/* The set of materialized parameters: */
public final int booleanQueryMaxClauseCount;

View File

@ -103,7 +103,6 @@ public class SolrDispatchFilter implements Filter
protected String pathPrefix = null; // strip this from the beginning of a path
protected String abortErrorMessage = null;
protected final Map<SolrConfig, SolrRequestParsers> parsers = new WeakHashMap<SolrConfig, SolrRequestParsers>();
private static final Charset UTF8 = Charset.forName("UTF-8");
@ -348,12 +347,7 @@ public class SolrDispatchFilter implements Filter
if( core != null ) {
final SolrConfig config = core.getSolrConfig();
// get or create/cache the parser for the core
SolrRequestParsers parser = null;
parser = parsers.get(config);
if( parser == null ) {
parser = new SolrRequestParsers(config);
parsers.put(config, parser );
}
SolrRequestParsers parser = config.getRequestParsers();
// Handle /schema/* paths via Restlet
if( path.startsWith("/schema") ) {