@@ -67,22 +67,14 @@ public class SolrRequestParsers {
6767
6868 private static final Logger log = LoggerFactory .getLogger (MethodHandles .lookup ().lookupClass ());
6969
70- // Should these constants be in a more public place?
71- public static final String MULTIPART = "multipart" ;
72- public static final String FORMDATA = "formdata" ;
73- public static final String RAW = "raw" ;
74- public static final String SIMPLE = "simple" ;
75- public static final String STANDARD = "standard" ;
76-
7770 private static final Charset CHARSET_US_ASCII = StandardCharsets .US_ASCII ;
7871
7972 public static final String INPUT_ENCODING_KEY = "ie" ;
8073 private static final byte [] INPUT_ENCODING_BYTES = INPUT_ENCODING_KEY .getBytes (CHARSET_US_ASCII );
8174
8275 public static final String REQUEST_TIMER_SERVLET_ATTRIBUTE = "org.apache.solr.RequestTimer" ;
8376
84- private final HashMap <String , SolrRequestParser > parsers = new HashMap <>();
85- private StandardRequestParser standard ;
77+ private StandardRequestParser parser ;
8678
8779 /**
8880 * Default instance for e.g. admin requests. Limits to 2 MB uploads and does not allow remote
@@ -91,7 +83,7 @@ public class SolrRequestParsers {
9183 public static final SolrRequestParsers DEFAULT = new SolrRequestParsers ();
9284
9385 /**
94- * Pass in an xml configuration. A null configuration will enable everything with maximum values.
86+ * Pass in a xml configuration. A null configuration will enable everything with maximum values.
9587 */
9688 public SolrRequestParsers (SolrConfig globalConfig ) {
9789 final int multipartUploadLimitKB , formUploadLimitKB ;
@@ -116,21 +108,12 @@ private void init(int multipartUploadLimitKB, int formUploadLimitKB) {
116108 MultipartRequestParser multi = new MultipartRequestParser (multipartUploadLimitKB );
117109 RawRequestParser raw = new RawRequestParser ();
118110 FormDataRequestParser formdata = new FormDataRequestParser (formUploadLimitKB );
119- standard = new StandardRequestParser (multi , raw , formdata );
120-
121- // I don't see a need to have this publicly configured just yet
122- // adding it is trivial
123- parsers .put (MULTIPART , multi );
124- parsers .put (FORMDATA , formdata );
125- parsers .put (RAW , raw );
126- parsers .put (SIMPLE , new SimpleRequestParser ());
127- parsers .put (STANDARD , standard );
128- parsers .put ("" , standard );
111+ parser = new StandardRequestParser (multi , raw , formdata );
129112 }
130113
131114 private static RTimerTree getRequestTimer (HttpServletRequest req ) {
132115 final Object reqTimer = req .getAttribute (REQUEST_TIMER_SERVLET_ATTRIBUTE );
133- if (reqTimer != null && reqTimer instanceof RTimerTree ) {
116+ if (reqTimer instanceof RTimerTree ) {
134117 return ((RTimerTree ) reqTimer );
135118 }
136119
@@ -139,7 +122,6 @@ private static RTimerTree getRequestTimer(HttpServletRequest req) {
139122
140123 public SolrQueryRequest parse (SolrCore core , String path , HttpServletRequest req )
141124 throws Exception {
142- SolrRequestParser parser = standard ;
143125
144126 // TODO -- in the future, we could pick a different parser based on the request
145127
@@ -164,13 +146,12 @@ public SolrQueryRequest parse(SolrCore core, String path, HttpServletRequest req
164146
165147 /** For embedded Solr use; not related to HTTP. */
166148 public SolrQueryRequest buildRequestFrom (
167- SolrCore core , SolrParams params , Collection <ContentStream > streams ) throws Exception {
149+ SolrCore core , SolrParams params , Collection <ContentStream > streams ) {
168150 return buildRequestFrom (core , params , streams , new RTimerTree (), null , null );
169151 }
170152
171153 public SolrQueryRequest buildRequestFrom (
172- SolrCore core , SolrParams params , Collection <ContentStream > streams , Principal principal )
173- throws Exception {
154+ SolrCore core , SolrParams params , Collection <ContentStream > streams , Principal principal ) {
174155 return buildRequestFrom (core , params , streams , new RTimerTree (), null , principal );
175156 }
176157
@@ -181,7 +162,7 @@ private SolrQueryRequest buildRequestFrom(
181162 RTimerTree requestTimer ,
182163 final HttpServletRequest req ,
183164 final Principal principal ) // from req, if req was provided, otherwise from elsewhere
184- throws Exception {
165+ {
185166 // ensure streams is non-null and mutable so we can easily add to it
186167 if (streams == null ) {
187168 streams = new ArrayList <>();
@@ -213,7 +194,7 @@ public List<CommandOperation> getCommands(boolean validateInput) {
213194
214195 @ Override
215196 public Map <String , String > getPathTemplateValues () {
216- if (httpSolrCall != null && httpSolrCall instanceof V2HttpCall ) {
197+ if (httpSolrCall instanceof V2HttpCall ) {
217198 return ((V2HttpCall ) httpSolrCall ).getUrlParts ();
218199 }
219200 return super .getPathTemplateValues ();
@@ -337,9 +318,9 @@ static long parseFormDataContent(
337318 // we have no charset decoder until now, buffer the keys / values for later
338319 // processing:
339320 buffer .add (keyBytes );
340- buffer .add (Long . valueOf ( keyPos ) );
321+ buffer .add (keyPos );
341322 buffer .add (valueBytes );
342- buffer .add (Long . valueOf ( valuePos ) );
323+ buffer .add (valuePos );
343324 } else {
344325 // we already have a charsetDecoder, so we can directly decode without buffering:
345326 final String key = decodeChars (keyBytes , keyPos , charsetDecoder ),
@@ -457,7 +438,7 @@ private static int digit16(int b) {
457438 // -----------------------------------------------------------------
458439 // -----------------------------------------------------------------
459440
460- // I guess we don't really even need the interface, but i 'll keep it here just for kicks
441+ // I guess we don't really even need the interface, but I 'll keep it here just for kicks
461442 interface SolrRequestParser {
462443 public SolrParams parseParamsAndFillStreams (
463444 final HttpServletRequest req , ArrayList <ContentStream > streams ) throws Exception ;
@@ -466,15 +447,6 @@ public SolrParams parseParamsAndFillStreams(
466447 // -----------------------------------------------------------------
467448 // -----------------------------------------------------------------
468449
469- /** The simple parser just uses the params directly, does not support POST URL-encoded forms */
470- static class SimpleRequestParser implements SolrRequestParser {
471- @ Override
472- public SolrParams parseParamsAndFillStreams (
473- final HttpServletRequest req , ArrayList <ContentStream > streams ) throws Exception {
474- return parseQueryString (req .getQueryString ());
475- }
476- }
477-
478450 /** Wrap an HttpServletRequest as a ContentStream */
479451 static class HttpRequestContentStream extends ContentStreamBase {
480452 private final InputStream inputStream ;
@@ -515,7 +487,7 @@ public SolrParams parseParamsAndFillStreams(
515487 || req .getHeader ("Transfer-Encoding" ) != null
516488 || !NO_BODY_METHODS .contains (req .getMethod ())) {
517489 // If Content-Length > 0 OR Transfer-Encoding exists OR
518- // it's a method that can have a body (POST/PUT/PATCH etc)
490+ // it's a method that can have a body (POST/PUT/PATCH etc. )
519491 streams .add (new HttpRequestContentStream (req , req .getInputStream ()));
520492 }
521493
@@ -543,7 +515,7 @@ public SolrParams parseParamsAndFillStreams(
543515 throw new SolrException (
544516 ErrorCode .BAD_REQUEST , "Not multipart content! " + req .getContentType ());
545517 }
546- // Magic way to tell Jetty dynamically we want multi-part processing.
518+ // Magic way to tell Jetty dynamically we want multipart processing.
547519 // This is taken from:
548520 // https://github.com/eclipse/jetty.project/blob/jetty-10.0.12/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java#L144
549521 req .setAttribute ("org.eclipse.jetty.multipartConfig" , multipartConfigElement );
@@ -735,7 +707,7 @@ static class StandardRequestParser implements SolrRequestParser {
735707 public SolrParams parseParamsAndFillStreams (
736708 final HttpServletRequest req , ArrayList <ContentStream > streams ) throws Exception {
737709 String contentType = req .getContentType ();
738- String method = req .getMethod (); // No need to uppercase... HTTP verbs are case sensitive
710+ String method = req .getMethod (); // No need to uppercase... HTTP verbs are case- sensitive
739711 String uri = req .getRequestURI ();
740712 boolean isV2 = getHttpSolrCall (req ) instanceof V2HttpCall ;
741713 boolean isPost = "POST" .equals (method );
0 commit comments