Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-17285: Move RemoteExecutionException (#3631)

David Smiley20b82a95182b
diff --git a/solr/core/src/test/org/apache/solr/api/NodeConfigClusterPluginsSourceTest.java b/solr/core/src/test/org/apache/solr/api/NodeConfigClusterPluginsSourceTest.java
index c4da59ba64d..ad640ebb495 100644
--- a/solr/core/src/test/org/apache/solr/api/NodeConfigClusterPluginsSourceTest.java
+++ b/solr/core/src/test/org/apache/solr/api/NodeConfigClusterPluginsSourceTest.java
@@ -20,7 +20,7 @@ package org.apache.solr.api;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
+import org.apache.solr.client.solrj.impl.RemoteExecutionException;
import org.apache.solr.client.solrj.request.V2Request;
import org.apache.solr.client.solrj.request.beans.PluginMeta;
import org.apache.solr.client.solrj.response.V2Response;
@@ -125,7 +125,7 @@ public class NodeConfigClusterPluginsSourceTest extends SolrCloudTestCase {
try {
req.process(cluster.getSolrClient());
fail("Expected a 404 response code because the Edit Apis are not registered");
- } catch (BaseHttpSolrClient.RemoteExecutionException e) {
+ } catch (RemoteExecutionException e) {
assertEquals(
"Expected a HTTP 404 response code because the /cluster/plugin API should not be registered",
404,
diff --git a/solr/core/src/test/org/apache/solr/filestore/TestDistribFileStore.java b/solr/core/src/test/org/apache/solr/filestore/TestDistribFileStore.java
index 5957ea93e63..580abd12944 100644
--- a/solr/core/src/test/org/apache/solr/filestore/TestDistribFileStore.java
+++ b/solr/core/src/test/org/apache/solr/filestore/TestDistribFileStore.java
@@ -37,9 +37,9 @@ import org.apache.http.client.methods.HttpDelete;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteExecutionException;
import org.apache.solr.client.solrj.impl.HttpClientUtil;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.client.solrj.impl.RemoteExecutionException;
import org.apache.solr.client.solrj.request.FileStoreApi;
import org.apache.solr.client.solrj.request.V2Request;
import org.apache.solr.client.solrj.response.SimpleSolrResponse;
diff --git a/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java b/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java
index 6306c859449..7f913a513f8 100644
--- a/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java
@@ -40,7 +40,7 @@ import org.apache.solr.api.ConfigurablePlugin;
import org.apache.solr.api.ContainerPluginsRegistry;
import org.apache.solr.api.EndPoint;
import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteExecutionException;
+import org.apache.solr.client.solrj.impl.RemoteExecutionException;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.V2Request;
import org.apache.solr.client.solrj.request.beans.PackagePayload;
diff --git a/solr/core/src/test/org/apache/solr/pkg/TestPackages.java b/solr/core/src/test/org/apache/solr/pkg/TestPackages.java
index 973a3e6dc52..494ad8c530e 100644
--- a/solr/core/src/test/org/apache/solr/pkg/TestPackages.java
+++ b/solr/core/src/test/org/apache/solr/pkg/TestPackages.java
@@ -46,9 +46,9 @@ import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.HttpClientUtil;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.client.solrj.impl.RemoteExecutionException;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.GenericSolrRequest;
import org.apache.solr.client.solrj.request.RequestWriter;
@@ -877,7 +877,7 @@ public class TestPackages extends SolrCloudTestCase {
try {
req.process(client);
fail("should have failed with message : " + expectErrorMsg);
- } catch (BaseHttpSolrClient.RemoteExecutionException e) {
+ } catch (RemoteExecutionException e) {
String msg = Objects.requireNonNullElse(e.getMetaData()._getStr(errPath), "");
assertTrue(
"should have failed with message: " + expectErrorMsg + "actual message : " + msg,
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpSolrClient.java
index 5a9df769a99..e07b98ebfcf 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpSolrClient.java
@@ -17,44 +17,7 @@
package org.apache.solr.client.solrj.impl;
-import static org.apache.solr.common.util.Utils.getObjectByPath;
-
-import java.util.Collections;
import org.apache.solr.client.solrj.SolrClient;
-import org.apache.solr.common.util.NamedList;
-
-public abstract class BaseHttpSolrClient extends SolrClient {
-
- /**
- * This should be thrown when a server has an error in executing the request, and it sends a
- * proper payload back to the client
- */
- public static class RemoteExecutionException extends RemoteSolrException {
- private NamedList<?> meta;
-
- public RemoteExecutionException(String remoteHost, int code, String msg, NamedList<?> meta) {
- super(remoteHost, code, msg + (meta != null ? ": " + meta : ""), null);
- this.meta = meta;
- }
-
- public static RemoteExecutionException create(String host, NamedList<?> errResponse) {
- Object errObj = errResponse.get("error");
- if (errObj != null) {
- Number code = (Number) getObjectByPath(errObj, true, Collections.singletonList("code"));
- String msg = (String) getObjectByPath(errObj, true, Collections.singletonList("msg"));
- return new RemoteExecutionException(
- host,
- code == null ? ErrorCode.UNKNOWN.code : code.intValue(),
- msg == null ? "Unknown Error" : msg,
- errResponse);
-
- } else {
- throw new RuntimeException("No error");
- }
- }
- public NamedList<?> getMetaData() {
- return meta;
- }
- }
-}
+@Deprecated
+public abstract class BaseHttpSolrClient extends SolrClient {}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClientBase.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClientBase.java
index 73dbb45ce71..92cc3b79caf 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClientBase.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClientBase.java
@@ -220,7 +220,7 @@ public abstract class HttpSolrClientBase extends SolrClient {
if (error != null
&& (String.valueOf(getObjectByPath(error, true, errPath))
.endsWith("ExceptionWithErrObject"))) {
- throw BaseHttpSolrClient.RemoteExecutionException.create(urlExceptionMessage, rsp);
+ throw RemoteExecutionException.create(urlExceptionMessage, rsp);
}
if (httpStatus != 200 && !isV2Api) {
NamedList<String> metadata = null;
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttp2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttp2SolrClient.java
index 28039a574f9..89ffbd707a0 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttp2SolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttp2SolrClient.java
@@ -254,7 +254,7 @@ public class LBHttp2SolrClient<C extends HttpSolrClientBase> extends LBSolrClien
RetryListener listener) {
try {
throw (Exception) oe;
- } catch (BaseHttpSolrClient.RemoteExecutionException e) {
+ } catch (RemoteExecutionException e) {
listener.onFailure(e, false);
} catch (SolrException e) {
// we retry on 404 or 403 or 503 or 500
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java
index 85fadde4ac7..a0d13b7c7c4 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java
@@ -526,7 +526,7 @@ public abstract class LBSolrClient extends SolrClient {
if (isZombie) {
reviveZombieServer(baseUrl);
}
- } catch (BaseHttpSolrClient.RemoteExecutionException e) {
+ } catch (RemoteExecutionException e) {
throw e;
} catch (SolrException e) {
// we retry on 404 or 403 or 503 or 500
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/RemoteExecutionException.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/RemoteExecutionException.java
new file mode 100644
index 00000000000..18baf4f6756
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/RemoteExecutionException.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.client.solrj.impl;
+
+import static org.apache.solr.common.util.Utils.getObjectByPath;
+
+import java.util.Collections;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.common.util.NamedList;
+
+/**
+ * This should be thrown when a server has an error in executing the request, and it sends a proper
+ * payload back to the client
+ *
+ * <p>THIS IS INTERNAL AND MAY DISAPPEAR
+ */
+public class RemoteExecutionException extends SolrClient.RemoteSolrException {
+ private NamedList<?> meta;
+
+ public RemoteExecutionException(String remoteHost, int code, String msg, NamedList<?> meta) {
+ super(remoteHost, code, msg + (meta != null ? ": " + meta : ""), null);
+ this.meta = meta;
+ }
+
+ public static RemoteExecutionException create(String host, NamedList<?> errResponse) {
+ Object errObj = errResponse.get("error");
+ if (errObj != null) {
+ Number code = (Number) getObjectByPath(errObj, true, Collections.singletonList("code"));
+ String msg = (String) getObjectByPath(errObj, true, Collections.singletonList("msg"));
+ return new RemoteExecutionException(
+ host,
+ code == null ? ErrorCode.UNKNOWN.code : code.intValue(),
+ msg == null ? "Unknown Error" : msg,
+ errResponse);
+
+ } else {
+ throw new RuntimeException("No error");
+ }
+ }
+
+ public NamedList<?> getMetaData() {
+ return meta;
+ }
+}