From 3c0146196aefd7fc05429650ea205a04bbb00524 Mon Sep 17 00:00:00 2001 From: Anshum Gupta Date: Thu, 23 Jan 2020 08:37:03 -0800 Subject: [PATCH] SOLR-14206: Annotate HttpSolrCall as thread-safe (#1203) * SOLR-14206: Annotate HttpSolrCall and V2HttpCall as thread-safe --- solr/core/src/java/org/apache/solr/api/V2HttpCall.java | 2 ++ .../src/java/org/apache/solr/servlet/HttpSolrCall.java | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/api/V2HttpCall.java b/solr/core/src/java/org/apache/solr/api/V2HttpCall.java index 8da3f319b3f..64ef8398a63 100644 --- a/solr/core/src/java/org/apache/solr/api/V2HttpCall.java +++ b/solr/core/src/java/org/apache/solr/api/V2HttpCall.java @@ -38,6 +38,7 @@ import javax.servlet.http.HttpServletResponse; import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.common.SolrException; +import org.apache.solr.common.annotation.SolrThreadSafe; import org.apache.solr.common.cloud.DocCollection; import org.apache.solr.common.cloud.ZkStateReader; import org.apache.solr.common.params.CommonParams; @@ -62,6 +63,7 @@ import org.slf4j.LoggerFactory; import com.google.common.collect.ImmutableSet; // class that handle the '/v2' path +@SolrThreadSafe public class V2HttpCall extends HttpSolrCall { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private Api api; diff --git a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java index 9c1d3575629..04e71b6329c 100644 --- a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java +++ b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java @@ -60,6 +60,7 @@ import org.apache.solr.client.solrj.impl.CloudSolrClient; import org.apache.solr.client.solrj.impl.HttpClientUtil; import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException.ErrorCode; +import org.apache.solr.common.annotation.SolrThreadSafe; import org.apache.solr.common.cloud.Aliases; import org.apache.solr.common.cloud.ClusterState; import org.apache.solr.common.cloud.DocCollection; @@ -134,6 +135,7 @@ import static org.apache.solr.servlet.SolrDispatchFilter.Action.RETURN; /** * This class represents a call made to Solr **/ +@SolrThreadSafe public class HttpSolrCall { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -414,14 +416,12 @@ public class HttpSolrCall { if (path.equals(req.getServletPath())) { // avoid endless loop - pass through to Restlet via webapp action = PASSTHROUGH; - SolrRequestInfo.getRequestInfo().setAction(action); - return; } else { // forward rewritten URI (without path prefix and core/collection name) to Restlet action = FORWARD; - SolrRequestInfo.getRequestInfo().setAction(action); - return; } + SolrRequestInfo.getRequestInfo().setAction(action); + return; } } @@ -1123,7 +1123,7 @@ public class HttpSolrCall { } @Override - public Enumeration getHeaderNames() { + public Enumeration getHeaderNames() { return getReq().getHeaderNames(); }