SOLR-5636: SolrRequestParsers does some xpath lookups on every request, which can cause concurrency issues.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1558688 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2014-01-16 03:46:34 +00:00
parent 330880c57e
commit c30f4ebd04
3 changed files with 60 additions and 16 deletions

View File

@ -204,6 +204,9 @@ Bug Fixes
* SOLR-4992: Solr eats OutOfMemoryError exceptions in many cases.
(Mark Miller, Daniel Collins)
* SOLR-5636: SolrRequestParsers does some xpath lookups on every request, which
can cause concurrency issues. (Mark Miller)
Optimizations
----------------------

View File

@ -79,6 +79,16 @@ public class SolrConfig extends Config {
// because of type determination
NOOP
}
private int multipartUploadLimitKB;
private int formUploadLimitKB;
private boolean enableRemoteStreams;
private boolean handleSelect;
private boolean addHttpRequestToContext;
/** Creates a default instance from the solrconfig.xml. */
public SolrConfig()
@ -258,6 +268,22 @@ public class SolrConfig extends Config {
REQUIRE_CLASS);
updateHandlerInfo = loadUpdatehandlerInfo();
multipartUploadLimitKB = getInt(
"requestDispatcher/requestParsers/@multipartUploadLimitInKB", 2048 );
formUploadLimitKB = getInt(
"requestDispatcher/requestParsers/@formdataUploadLimitInKB", 2048 );
enableRemoteStreams = getBool(
"requestDispatcher/requestParsers/@enableRemoteStreaming", false );
// Let this filter take care of /select?xxx format
handleSelect = getBool(
"requestDispatcher/@handleSelect", true );
addHttpRequestToContext = getBool(
"requestDispatcher/requestParsers/@addHttpRequestToContext", false );
Config.log.info("Loaded SolrConfig: " + name);
}
@ -531,4 +557,24 @@ public class SolrConfig extends Config {
loader.reloadLuceneSPI();
}
}
public int getMultipartUploadLimitKB() {
return multipartUploadLimitKB;
}
public int getFormUploadLimitKB() {
return formUploadLimitKB;
}
public boolean isHandleSelect() {
return handleSelect;
}
public boolean isAddHttpRequestToContext() {
return addHttpRequestToContext;
}
public boolean isEnableRemoteStreams() {
return enableRemoteStreams;
}
}

View File

@ -17,16 +17,16 @@
package org.apache.solr.servlet;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.ByteArrayOutputStream;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CodingErrorAction;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -36,8 +36,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
@ -53,10 +51,12 @@ import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.ContentStream;
import org.apache.solr.common.util.ContentStreamBase;
import org.apache.solr.common.util.FastInputStream;
import org.apache.solr.core.Config;
import org.apache.solr.core.SolrConfig;
import org.apache.solr.core.SolrCore;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrQueryRequestBase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SolrRequestParsers
@ -89,7 +89,7 @@ public class SolrRequestParsers
* Pass in an xml configuration. A null configuration will enable
* everything with maximum values.
*/
public SolrRequestParsers( Config globalConfig ) {
public SolrRequestParsers( SolrConfig globalConfig ) {
final int multipartUploadLimitKB, formUploadLimitKB;
if( globalConfig == null ) {
multipartUploadLimitKB = formUploadLimitKB = Integer.MAX_VALUE;
@ -97,21 +97,16 @@ public class SolrRequestParsers
handleSelect = true;
addHttpRequestToContext = false;
} else {
multipartUploadLimitKB = globalConfig.getInt(
"requestDispatcher/requestParsers/@multipartUploadLimitInKB", 2048 );
multipartUploadLimitKB = globalConfig.getMultipartUploadLimitKB();
formUploadLimitKB = globalConfig.getInt(
"requestDispatcher/requestParsers/@formdataUploadLimitInKB", 2048 );
formUploadLimitKB = globalConfig.getFormUploadLimitKB();
enableRemoteStreams = globalConfig.getBool(
"requestDispatcher/requestParsers/@enableRemoteStreaming", false );
enableRemoteStreams = globalConfig.isEnableRemoteStreams();
// Let this filter take care of /select?xxx format
handleSelect = globalConfig.getBool(
"requestDispatcher/@handleSelect", true );
handleSelect = globalConfig.isHandleSelect();
addHttpRequestToContext = globalConfig.getBool(
"requestDispatcher/requestParsers/@addHttpRequestToContext", false );
addHttpRequestToContext = globalConfig.isAddHttpRequestToContext();
}
init(multipartUploadLimitKB, formUploadLimitKB);
}