SOLR-14344: remove deprecated HttpSolrClient's Remote*Exception

* All usages are replaced by BaseHttpSolrClient's Remote*Exception
This commit is contained in:
Munendra S N 2020-03-28 11:36:06 +05:30
parent 15330a8541
commit 132228d450
38 changed files with 153 additions and 164 deletions

View File

@ -40,8 +40,8 @@ import org.apache.solr.client.solrj.cloud.DistribStateManager;
import org.apache.solr.client.solrj.cloud.SolrCloudManager;
import org.apache.solr.client.solrj.cloud.autoscaling.AlreadyExistsException;
import org.apache.solr.client.solrj.cloud.autoscaling.BadVersionException;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.UpdateResponse;
@ -780,8 +780,8 @@ public class OverseerCollectionMessageHandler implements OverseerMessageHandler,
@SuppressWarnings("deprecation")
private void processResponse(NamedList<Object> results, Throwable e, String nodeName, SolrResponse solrResponse, String shard, Set<String> okayExceptions) {
String rootThrowable = null;
if (e instanceof RemoteSolrException) {
rootThrowable = ((RemoteSolrException) e).getRootThrowable();
if (e instanceof BaseHttpSolrClient.RemoteSolrException) {
rootThrowable = ((BaseHttpSolrClient.RemoteSolrException) e).getRootThrowable();
}
if (e != null && (rootThrowable == null || !okayExceptions.contains(rootThrowable))) {

View File

@ -38,7 +38,7 @@ import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.response.FacetField;
import org.apache.solr.client.solrj.response.FieldStatsInfo;
import org.apache.solr.client.solrj.response.QueryResponse;
@ -1057,7 +1057,7 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
"stats.field", tdate_a,
"stats.field", tdate_b,
"stats.calcdistinct", "true");
} catch (HttpSolrClient.RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
if (e.getMessage().startsWith("java.lang.NullPointerException")) {
fail("NullPointerException with stats request on empty index");
} else {

View File

@ -26,8 +26,8 @@ import java.util.Map;
import java.util.Set;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
@ -211,7 +211,7 @@ public class DistribJoinFromCollectionTest extends SolrCloudTestCase{
final QueryRequest qr = new QueryRequest(params("collection", toColl, "q", joinQ, "fl", "id,get_s,score"));
try {
cluster.getSolrClient().request(qr);
} catch (HttpSolrClient.RemoteSolrException ex) {
} catch (BaseHttpSolrClient.RemoteSolrException ex) {
assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, ex.code());
assertTrue(ex.getMessage().contains(wrongName));
}

View File

@ -23,6 +23,7 @@ import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrResponse;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.GenericSolrRequest;
@ -88,7 +89,7 @@ public class HealthCheckHandlerTest extends SolrCloudTestCase {
newJetty.getCoreContainer().getZkController().getZkClient().close();
// negative check of our (new) "broken" node that we deliberately put into an unhealth state
HttpSolrClient.RemoteSolrException e = expectThrows(HttpSolrClient.RemoteSolrException.class, () ->
BaseHttpSolrClient.RemoteSolrException e = expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () ->
{
req.process(httpSolrClient);
});
@ -165,7 +166,7 @@ public class HealthCheckHandlerTest extends SolrCloudTestCase {
newJetty.getCoreContainer().getZkController().getZkClient().close();
// negative check of our (new) "broken" node that we deliberately put into an unhealth state
HttpSolrClient.RemoteSolrException e = expectThrows(HttpSolrClient.RemoteSolrException.class, () ->
BaseHttpSolrClient.RemoteSolrException e = expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () ->
{
new V2Request.Builder("/node/health").build().process(httpSolrClient);
});

View File

@ -17,9 +17,6 @@
package org.apache.solr.cloud;
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.is;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
@ -27,12 +24,13 @@ import java.nio.file.NoSuchFileException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.LuceneTestCase.AwaitsFix;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteSolrException;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.common.SolrException;
@ -50,6 +48,9 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.is;
@AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/SOLR-13237")
public class LeaderTragicEventTest extends SolrCloudTestCase {

View File

@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
@ -93,7 +94,7 @@ public class MigrateRouteKeyTest extends SolrCloudTestCase {
CollectionAdminRequest.createCollection(targetCollection, "conf", 1, 1)
.process(cluster.getSolrClient());
HttpSolrClient.RemoteSolrException remoteSolrException = expectThrows(HttpSolrClient.RemoteSolrException.class,
BaseHttpSolrClient.RemoteSolrException remoteSolrException = expectThrows(BaseHttpSolrClient.RemoteSolrException.class,
"Expected an exception in case split.key is not specified", () -> {
CollectionAdminRequest.migrateData(sourceCollection, targetCollection, "")
.setForwardTimeout(45)

View File

@ -16,7 +16,7 @@
*/
package org.apache.solr.cloud;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.util.NamedList;
@ -59,7 +59,7 @@ public class OverseerStatusTest extends SolrCloudTestCase {
SimpleOrderedMap<Object> reload = (SimpleOrderedMap<Object>) collection_operations.get(CollectionParams.CollectionAction.RELOAD.toLower());
assertEquals("No stats for reload in OverseerCollectionProcessor", 1, reload.get("requests"));
HttpSolrClient.RemoteSolrException e = expectThrows(HttpSolrClient.RemoteSolrException.class,
BaseHttpSolrClient.RemoteSolrException e = expectThrows(BaseHttpSolrClient.RemoteSolrException.class,
"Split shard for non existent collection should have failed",
() -> CollectionAdminRequest
.splitShard("non_existent_collection")

View File

@ -29,8 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.UpdateResponse;
@ -93,7 +93,7 @@ public class SplitShardTest extends SolrCloudTestCase {
splitShard = CollectionAdminRequest.splitShard(COLLECTION_NAME).setShardName("shard2").setNumSubShards(10);
splitShard.process(cluster.getSolrClient());
fail("SplitShard should throw an exception when numSubShards > 8");
} catch (HttpSolrClient.RemoteSolrException ex) {
} catch (BaseHttpSolrClient.RemoteSolrException ex) {
assertTrue(ex.getMessage().contains("A shard can only be split into 2 to 8 subshards in one split request."));
}
@ -101,7 +101,7 @@ public class SplitShardTest extends SolrCloudTestCase {
splitShard = CollectionAdminRequest.splitShard(COLLECTION_NAME).setShardName("shard2").setNumSubShards(1);
splitShard.process(cluster.getSolrClient());
fail("SplitShard should throw an exception when numSubShards < 2");
} catch (HttpSolrClient.RemoteSolrException ex) {
} catch (BaseHttpSolrClient.RemoteSolrException ex) {
assertTrue(ex.getMessage().contains("A shard can only be split into 2 to 8 subshards in one split request. Provided numSubShards=1"));
}
}

View File

@ -27,9 +27,9 @@ import java.util.Map;
import org.apache.http.HttpRequestInterceptor;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpClientUtil;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.SolrHttpClientBuilder;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
@ -79,7 +79,7 @@ public class TestAuthenticationFramework extends SolrCloudTestCase {
// Should fail with 401
try {
HttpSolrClient.RemoteSolrException e = expectThrows(HttpSolrClient.RemoteSolrException.class,
BaseHttpSolrClient.RemoteSolrException e = expectThrows(BaseHttpSolrClient.RemoteSolrException.class,
this::collectionCreateSearchDeleteTwice);
assertTrue("Should've returned a 401 error", e.getMessage().contains("Error 401"));
} finally {

View File

@ -54,9 +54,9 @@ 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.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpClientUtil;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.ConfigSetAdminRequest;
import org.apache.solr.client.solrj.request.ConfigSetAdminRequest.Create;
import org.apache.solr.client.solrj.request.ConfigSetAdminRequest.Delete;
@ -349,7 +349,7 @@ public class TestConfigSetsAPI extends SolrTestCaseJ4 {
final String untrustedSuffix = "-untrusted";
uploadConfigSetWithAssertions("with-script-processor", untrustedSuffix, null, null);
// try to create a collection with the uploaded configset
Throwable thrown = expectThrows(HttpSolrClient.RemoteSolrException.class, () -> {
Throwable thrown = expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> {
createCollection("newcollection2", "with-script-processor" + untrustedSuffix,
1, 1, solrCluster.getSolrClient());
});
@ -375,7 +375,7 @@ public class TestConfigSetsAPI extends SolrTestCaseJ4 {
final String untrustedSuffix = "-untrusted";
uploadConfigSetWithAssertions("with-lib-directive", untrustedSuffix, null, null);
// try to create a collection with the uploaded configset
Throwable thrown = expectThrows(HttpSolrClient.RemoteSolrException.class, () -> {
Throwable thrown = expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> {
createCollection("newcollection3", "with-lib-directive" + untrustedSuffix,
1, 1, solrCluster.getSolrClient());
});

View File

@ -35,7 +35,7 @@ import org.apache.jute.OutputArchive;
import org.apache.jute.Record;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteSolrException;
import org.apache.solr.client.solrj.request.ConfigSetAdminRequest.Create;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.cloud.SolrZkClient;

View File

@ -16,15 +16,23 @@
*/
package org.apache.solr.cloud;
import java.lang.invoke.MethodHandles;
import java.util.Collections;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import org.apache.hadoop.util.Time;
import org.apache.http.HttpStatus;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.LBHttpSolrClient;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.LBHttpSolrClient;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest.ACTION;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.DelegationTokenRequest;
@ -33,26 +41,18 @@ import org.apache.solr.client.solrj.response.DelegationTokenResponse;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import static org.apache.solr.security.HttpParamDelegationTokenPlugin.USER_PARAM;
import org.apache.http.HttpStatus;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.security.HttpParamDelegationTokenPlugin;
import org.apache.solr.security.KerberosPlugin;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import java.lang.invoke.MethodHandles;
import java.util.Collections;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.apache.solr.security.HttpParamDelegationTokenPlugin.USER_PARAM;
/**
* Test the delegation token support in the {@link org.apache.solr.security.KerberosPlugin}.
*/
@ -134,7 +134,7 @@ public class TestSolrCloudWithDelegationTokens extends SolrTestCaseJ4 {
DelegationTokenResponse.Renew renewResponse = renew.process(client);
assertEquals(HttpStatus.SC_OK, expectedStatusCode);
return renewResponse.getExpirationTime();
} catch (HttpSolrClient.RemoteSolrException ex) {
} catch (BaseHttpSolrClient.RemoteSolrException ex) {
assertEquals(expectedStatusCode, ex.code());
return -1;
}
@ -146,7 +146,7 @@ public class TestSolrCloudWithDelegationTokens extends SolrTestCaseJ4 {
try {
cancel.process(client);
assertEquals(HttpStatus.SC_OK, expectedStatusCode);
} catch (HttpSolrClient.RemoteSolrException ex) {
} catch (BaseHttpSolrClient.RemoteSolrException ex) {
assertEquals(expectedStatusCode, ex.code());
}
}
@ -220,7 +220,7 @@ public class TestSolrCloudWithDelegationTokens extends SolrTestCaseJ4 {
try {
delegationTokenClient.request(req, null);
return HttpStatus.SC_OK;
} catch (HttpSolrClient.RemoteSolrException re) {
} catch (BaseHttpSolrClient.RemoteSolrException re) {
return re.code();
}
} finally {
@ -233,7 +233,7 @@ public class TestSolrCloudWithDelegationTokens extends SolrTestCaseJ4 {
try {
client.request(request);
assertEquals(HttpStatus.SC_OK, expectedStatusCode);
} catch (HttpSolrClient.RemoteSolrException ex) {
} catch (BaseHttpSolrClient.RemoteSolrException ex) {
assertEquals(expectedStatusCode, ex.code());
}
}
@ -243,7 +243,7 @@ public class TestSolrCloudWithDelegationTokens extends SolrTestCaseJ4 {
try {
client.request(request, collectionName);
assertEquals(HttpStatus.SC_OK, expectedStatusCode);
} catch (HttpSolrClient.RemoteSolrException ex) {
} catch (BaseHttpSolrClient.RemoteSolrException ex) {
assertEquals(expectedStatusCode, ex.code());
}
}

View File

@ -28,6 +28,7 @@ import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
@ -224,7 +225,7 @@ public class TestSolrCloudWithSecureImpersonation extends SolrTestCaseJ4 {
@Test
public void testProxyNoConfigGroups() throws Exception {
HttpSolrClient.RemoteSolrException e = expectThrows(HttpSolrClient.RemoteSolrException.class,
BaseHttpSolrClient.RemoteSolrException e = expectThrows(BaseHttpSolrClient.RemoteSolrException.class,
() -> solrClient.request(getProxyRequest("noGroups","bar"))
);
assertTrue(e.getMessage().contains(getExpectedGroupExMsg("noGroups", "bar")));
@ -232,7 +233,7 @@ public class TestSolrCloudWithSecureImpersonation extends SolrTestCaseJ4 {
@Test
public void testProxyWrongHost() throws Exception {
HttpSolrClient.RemoteSolrException e = expectThrows(HttpSolrClient.RemoteSolrException.class,
BaseHttpSolrClient.RemoteSolrException e = expectThrows(BaseHttpSolrClient.RemoteSolrException.class,
() -> solrClient.request(getProxyRequest("wrongHost","bar"))
);
assertTrue(e.getMessage().contains(getExpectedHostExMsg("wrongHost")));
@ -240,7 +241,7 @@ public class TestSolrCloudWithSecureImpersonation extends SolrTestCaseJ4 {
@Test
public void testProxyNoConfigHosts() throws Exception {
HttpSolrClient.RemoteSolrException e = expectThrows(HttpSolrClient.RemoteSolrException.class,
BaseHttpSolrClient.RemoteSolrException e = expectThrows(BaseHttpSolrClient.RemoteSolrException.class,
() -> solrClient.request(getProxyRequest("noHosts","bar"))
);
// FixMe: this should return an exception about the host being invalid,
@ -257,7 +258,7 @@ public class TestSolrCloudWithSecureImpersonation extends SolrTestCaseJ4 {
@Test
public void testProxyInvalidProxyUser() throws Exception {
// wrong direction, should fail
HttpSolrClient.RemoteSolrException e = expectThrows(HttpSolrClient.RemoteSolrException.class,
BaseHttpSolrClient.RemoteSolrException e = expectThrows(BaseHttpSolrClient.RemoteSolrException.class,
() -> solrClient.request(getProxyRequest("bar","anyHostAnyUser"))
);
assertTrue(e.getMessage().contains(getExpectedGroupExMsg("bar", "anyHostAnyUser")));
@ -279,7 +280,7 @@ public class TestSolrCloudWithSecureImpersonation extends SolrTestCaseJ4 {
@Test
public void testProxyUnknownRemote() throws Exception {
HttpSolrClient.RemoteSolrException e = expectThrows(HttpSolrClient.RemoteSolrException.class,
BaseHttpSolrClient.RemoteSolrException e = expectThrows(BaseHttpSolrClient.RemoteSolrException.class,
() -> {
// Use a reserved ip address
String nonProxyUserConfiguredIpAddress = "255.255.255.255";
@ -290,7 +291,7 @@ public class TestSolrCloudWithSecureImpersonation extends SolrTestCaseJ4 {
@Test
public void testProxyInvalidRemote() throws Exception {
HttpSolrClient.RemoteSolrException e = expectThrows(HttpSolrClient.RemoteSolrException.class,
BaseHttpSolrClient.RemoteSolrException e = expectThrows(BaseHttpSolrClient.RemoteSolrException.class,
() -> {
solrClient.request(getProxyRequest("localHostAnyGroup","bar", "[ff01::114]", DEAD_HOST_2));
});
@ -299,7 +300,7 @@ public class TestSolrCloudWithSecureImpersonation extends SolrTestCaseJ4 {
@Test
public void testProxyInvalidGroup() throws Exception {
HttpSolrClient.RemoteSolrException e = expectThrows(HttpSolrClient.RemoteSolrException.class,
BaseHttpSolrClient.RemoteSolrException e = expectThrows(BaseHttpSolrClient.RemoteSolrException.class,
() -> solrClient.request(getProxyRequest("bogusGroup","bar", null))
);
assertTrue(e.getMessage().contains(getExpectedGroupExMsg("bogusGroup", "bar")));
@ -307,7 +308,7 @@ public class TestSolrCloudWithSecureImpersonation extends SolrTestCaseJ4 {
@Test
public void testProxyNullProxyUser() throws Exception {
expectThrows(HttpSolrClient.RemoteSolrException.class,
expectThrows(BaseHttpSolrClient.RemoteSolrException.class,
() -> solrClient.request(getProxyRequest("","bar"))
);
}

View File

@ -17,8 +17,6 @@
package org.apache.solr.cloud;
import static org.apache.solr.common.params.CollectionAdminParams.WITH_COLLECTION;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.charset.StandardCharsets;
@ -31,8 +29,8 @@ import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.cloud.SolrCloudManager;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
import org.apache.solr.cloud.CloudTestUtils.AutoScalingRequest;
@ -54,6 +52,8 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.apache.solr.common.params.CollectionAdminParams.WITH_COLLECTION;
/**
* Tests for co-locating a collection with another collection such that any Collection API
* always ensures that the co-location is never broken.
@ -113,7 +113,7 @@ public class TestWithCollection extends SolrCloudTestCase {
CollectionAdminRequest.createCollection(xyz, 1, 1)
.setWithCollection(abc).process(solrClient);
} catch (HttpSolrClient.RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
assertTrue(e.getMessage().contains("The 'withCollection' does not exist"));
}
@ -122,7 +122,7 @@ public class TestWithCollection extends SolrCloudTestCase {
try {
CollectionAdminRequest.createCollection(xyz, 1, 1)
.setWithCollection(abc).process(solrClient);
} catch (HttpSolrClient.RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
assertTrue(e.getMessage().contains("The `withCollection` must have only one shard, found: 2"));
}
}
@ -175,7 +175,7 @@ public class TestWithCollection extends SolrCloudTestCase {
try {
CollectionAdminResponse response = CollectionAdminRequest.deleteCollection(abc).process(solrClient);
fail("Deleting collection: " + abc + " should have failed with an exception. Instead response was: " + response.getResponse());
} catch (HttpSolrClient.RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
assertTrue(e.getMessage().contains("is co-located with collection"));
}
@ -195,7 +195,7 @@ public class TestWithCollection extends SolrCloudTestCase {
try {
CollectionAdminResponse response = CollectionAdminRequest.deleteCollection(abc).process(solrClient);
fail("Deleting collection: " + abc + " should have failed with an exception. Instead response was: " + response.getResponse());
} catch (HttpSolrClient.RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
assertTrue(e.getMessage().contains("is co-located with collection"));
}
@ -380,7 +380,7 @@ public class TestWithCollection extends SolrCloudTestCase {
new CollectionAdminRequest.MoveReplica(abc, collection.getReplicas().iterator().next().getName(), otherNode)
.process(solrClient);
fail("Expected moving a replica of 'withCollection': " + abc + " to fail");
} catch (HttpSolrClient.RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
assertTrue(e.getMessage().contains("Collection: testMoveReplicaWithCollection_abc is co-located with collection: testMoveReplicaWithCollection_xyz"));
}
// zkClient().printLayoutToStdOut();

View File

@ -45,6 +45,7 @@ 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.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.CoreAdminRequest;
@ -283,7 +284,7 @@ public class CollectionsAPIDistributedZkTest extends SolrCloudTestCase {
String nn1 = cluster.getJettySolrRunner(0).getNodeName();
String nn2 = cluster.getJettySolrRunner(1).getNodeName();
expectThrows(HttpSolrClient.RemoteSolrException.class, () -> {
expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> {
CollectionAdminResponse resp = CollectionAdminRequest.createCollection("halfcollection", "conf", 2, 1)
.setCreateNodeSet(nn1 + "," + nn2)
.process(cluster.getSolrClient());

View File

@ -38,6 +38,7 @@ 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.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
@ -676,7 +677,7 @@ public class ShardSplitTest extends BasicDistributedZkTest {
try {
splitShard(AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1, subRanges, null, false);
fail("Shard splitting with just one custom hash range should not succeed");
} catch (HttpSolrClient.RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
log.info("Expected exception:", e);
}
subRanges.clear();
@ -687,7 +688,7 @@ public class ShardSplitTest extends BasicDistributedZkTest {
try {
splitShard(AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1, subRanges, null, false);
fail("Shard splitting with missing hashes in between given ranges should not succeed");
} catch (HttpSolrClient.RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
log.info("Expected exception:", e);
}
subRanges.clear();
@ -700,7 +701,7 @@ public class ShardSplitTest extends BasicDistributedZkTest {
try {
splitShard(AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1, subRanges, null, false);
fail("Shard splitting with overlapping ranges should not succeed");
} catch (HttpSolrClient.RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
log.info("Expected exception:", e);
}
subRanges.clear();
@ -772,7 +773,7 @@ public class ShardSplitTest extends BasicDistributedZkTest {
log.info("Layout after split: \n");
printLayout();
break;
} catch (HttpSolrClient.RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
if (e.code() != 500) {
throw e;
}
@ -937,7 +938,7 @@ public class ShardSplitTest extends BasicDistributedZkTest {
try {
splitShard(collectionName, shardId, null, splitKey, false);
break;
} catch (HttpSolrClient.RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
if (e.code() != 500) {
throw e;
}

View File

@ -25,18 +25,17 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import com.google.common.collect.Lists;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteSolrException;
import org.apache.solr.cloud.ZkTestServer;
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.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
import org.apache.solr.client.solrj.request.V2Request;
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.cloud.ZkTestServer;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.cloud.ClusterState;
@ -121,7 +120,7 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {
try {
client.request(request);
fail("A collection creation request with too many shards than allowed by maxShardsPerNode should not have succeeded");
} catch (RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
final String errorMessage = e.getMessage();
assertTrue(errorMessage.contains("Cannot create collection"));
assertTrue(errorMessage.contains("This requires 10 shards to be created (higher than the allowed number)"));
@ -186,7 +185,7 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {
try {
client.request(request);
fail("Trying to unset an unknown property should have failed");
} catch (RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
// expected
assertTrue(e.getMessage().contains("no supported values provided"));
}
@ -208,7 +207,7 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {
try {
client.request(request);
fail();
} catch (RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
final String errorMessage = e.getMessage();
assertTrue(errorMessage.contains("Cannot specify both replicationFactor and nrtReplicas as they mean the same thing"));
}
@ -935,7 +934,7 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {
try {
client.request(request);
fail();
} catch (RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
final String errorMessage = e.getMessage();
assertTrue(errorMessage.contains("Invalid collection"));
assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
@ -958,7 +957,7 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {
try {
client.request(request);
fail();
} catch (RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
final String errorMessage = e.getMessage();
assertTrue(errorMessage.contains("Invalid shard"));
assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
@ -979,7 +978,7 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {
try {
client.request(request);
fail();
} catch (RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
final String errorMessage = e.getMessage();
assertTrue(errorMessage.contains("Invalid alias"));
assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
@ -1012,7 +1011,7 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {
try {
client.request(request);
fail();
} catch (RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
final String errorMessage = e.getMessage();
assertTrue(errorMessage.contains("Invalid shard"));
assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
@ -1069,7 +1068,7 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {
try (CloudSolrClient client = createCloudClient(null)) {
// first, try creating a collection with badconf
HttpSolrClient.RemoteSolrException rse = expectThrows(HttpSolrClient.RemoteSolrException.class, () -> {
BaseHttpSolrClient.RemoteSolrException rse = expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> {
CollectionAdminResponse rsp = CollectionAdminRequest.createCollection
("testcollection", "badconf", 1, 2).process(client);
});

View File

@ -31,8 +31,8 @@ import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.cloud.autoscaling.Policy;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
import org.apache.solr.cloud.CloudTestUtils.AutoScalingRequest;
@ -407,7 +407,7 @@ public class AutoScalingHandlerTest extends SolrCloudTestCase {
try {
solrClient.request(req);
fail("expected exception");
} catch (HttpSolrClient.RemoteExecutionException e) {
} catch (BaseHttpSolrClient.RemoteExecutionException e) {
// expected
assertTrue(String.valueOf(getObjectByPath(e.getMetaData(),
false, "error/details[0]/errorMessages[0]")).contains("Cannot remove trigger: node_lost_trigger because it has active listeners: ["));
@ -455,9 +455,9 @@ public class AutoScalingHandlerTest extends SolrCloudTestCase {
try {
solrClient.request(req);
fail("should have thrown Exception");
} catch (HttpSolrClient.RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
// expected
assertTrue(String.valueOf(getObjectByPath(((HttpSolrClient.RemoteExecutionException) e).getMetaData(),
assertTrue(String.valueOf(getObjectByPath(((BaseHttpSolrClient.RemoteExecutionException) e).getMetaData(),
false, "error/details[0]/errorMessages[0]")).contains("A trigger with the name node_lost_trigger does not exist"));
}
}
@ -477,7 +477,7 @@ public class AutoScalingHandlerTest extends SolrCloudTestCase {
SolrRequest req = AutoScalingRequest.create(SolrRequest.METHOD.POST, setClusterPolicyCommand);
solrClient.request(req);
fail("expect exception");
} catch (HttpSolrClient.RemoteExecutionException e) {
} catch (BaseHttpSolrClient.RemoteExecutionException e) {
String message = String.valueOf(getObjectByPath(e.getMetaData(), true, "error/details[0]/errorMessages[0]"));
assertTrue(message.contains("replica is required in"));
}
@ -506,9 +506,9 @@ public class AutoScalingHandlerTest extends SolrCloudTestCase {
try {
solrClient.request(req);
fail("should have thrown Exception");
} catch (HttpSolrClient.RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
// expected
assertTrue(String.valueOf(getObjectByPath(((HttpSolrClient.RemoteExecutionException) e).getMetaData(),
assertTrue(String.valueOf(getObjectByPath(((BaseHttpSolrClient.RemoteExecutionException) e).getMetaData(),
false, "error/details[0]/errorMessages[0]")).contains("foo=unknown property"));
}
@ -530,9 +530,9 @@ public class AutoScalingHandlerTest extends SolrCloudTestCase {
try {
solrClient.request(req);
fail("should have thrown Exception");
} catch (HttpSolrClient.RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
// expected
assertTrue(String.valueOf(getObjectByPath(((HttpSolrClient.RemoteExecutionException) e).getMetaData(),
assertTrue(String.valueOf(getObjectByPath(((BaseHttpSolrClient.RemoteExecutionException) e).getMetaData(),
false, "error/details[0]/errorMessages[0]")).contains("aboveRate=Invalid configuration value: 'foo'"));
}
@ -554,9 +554,9 @@ public class AutoScalingHandlerTest extends SolrCloudTestCase {
try {
solrClient.request(req);
fail("should have thrown Exception");
} catch (HttpSolrClient.RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
// expected
assertTrue(String.valueOf(getObjectByPath(((HttpSolrClient.RemoteExecutionException) e).getMetaData(),
assertTrue(String.valueOf(getObjectByPath(((BaseHttpSolrClient.RemoteExecutionException) e).getMetaData(),
false, "error/details[0]/errorMessages[0]")).contains("foo=unknown property"));
}
@ -593,9 +593,9 @@ public class AutoScalingHandlerTest extends SolrCloudTestCase {
try {
solrClient.request(req);
fail("should have thrown Exception");
} catch (HttpSolrClient.RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
// expected
assertTrue(String.valueOf(getObjectByPath(((HttpSolrClient.RemoteExecutionException) e).getMetaData(),
assertTrue(String.valueOf(getObjectByPath(((BaseHttpSolrClient.RemoteExecutionException) e).getMetaData(),
false, "error/details[0]/errorMessages[0]")).contains("foo=unknown property"));
}
}
@ -619,7 +619,7 @@ public class AutoScalingHandlerTest extends SolrCloudTestCase {
try {
solrClient.request(req);
fail("Adding a policy with 'cores' attribute should not have succeeded.");
} catch (HttpSolrClient.RemoteExecutionException e) {
} catch (BaseHttpSolrClient.RemoteExecutionException e) {
String message = e.getMetaData()._getStr("error/details[0]/errorMessages[0]",null);
// expected
@ -981,7 +981,7 @@ public class AutoScalingHandlerTest extends SolrCloudTestCase {
try {
solrClient.request(AutoScalingRequest.create(SolrRequest.METHOD.POST, removePolicyCommand));
fail("should have failed");
} catch (HttpSolrClient.RemoteExecutionException e) {
} catch (BaseHttpSolrClient.RemoteExecutionException e) {
assertTrue(String.valueOf(getObjectByPath(e.getMetaData(), true, "error/details[0]/errorMessages[0]"))
.contains("is being used by collection"));
} catch (Exception e) {

View File

@ -40,8 +40,8 @@ import org.apache.solr.client.solrj.cloud.autoscaling.ReplicaInfo;
import org.apache.solr.client.solrj.cloud.autoscaling.Row;
import org.apache.solr.client.solrj.cloud.autoscaling.Variable.Type;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.SolrClientCloudManager;
import org.apache.solr.client.solrj.impl.SolrClientNodeStateProvider;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
@ -91,7 +91,7 @@ public class TestPolicyCloud extends SolrCloudTestCase {
String commands = "{ set-cluster-policy: [ {cores: '0', node: '#ANY'} ] }"; // disallow replica placement anywhere
cluster.getSolrClient().request(AutoScalingRequest.create(SolrRequest.METHOD.POST, commands));
String collectionName = "testCreateCollection";
HttpSolrClient.RemoteSolrException exp = expectThrows(HttpSolrClient.RemoteSolrException.class,
BaseHttpSolrClient.RemoteSolrException exp = expectThrows(BaseHttpSolrClient.RemoteSolrException.class,
() -> CollectionAdminRequest.createCollection(collectionName, "conf", 2, 1).process(cluster.getSolrClient()));
assertTrue(exp.getMessage().contains("No node can satisfy the rules"));
@ -345,7 +345,7 @@ public class TestPolicyCloud extends SolrCloudTestCase {
try {
solrClient.request(req);
fail("expected exception");
} catch (HttpSolrClient.RemoteExecutionException e) {
} catch (BaseHttpSolrClient.RemoteExecutionException e) {
// expected
assertTrue(String.valueOf(getObjectByPath(e.getMetaData(),
false, "error/details[0]/errorMessages[0]")).contains("Invalid metrics: param in"));

View File

@ -30,7 +30,7 @@ import org.apache.lucene.util.LuceneTestCase;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.GenericSolrRequest;
import org.apache.solr.client.solrj.response.SimpleSolrResponse;
@ -152,7 +152,7 @@ public class RulesTest extends SolrCloudTestCase {
// adding an additional replica should fail since our rule says at most one replica
// per node, and we know every node already has one replica
expectedException.expect(HttpSolrClient.RemoteSolrException.class);
expectedException.expect(BaseHttpSolrClient.RemoteSolrException.class);
expectedException.expectMessage(containsString("current number of eligible live nodes 0"));
CollectionAdminRequest.addReplicaToShard(rulesColl, "shard2").process(cluster.getSolrClient());
@ -297,7 +297,7 @@ public class RulesTest extends SolrCloudTestCase {
String ip_1 = ipFragments[ipFragments.length - 1];
String ip_2 = ipFragments[ipFragments.length - 2];
expectedException.expect(HttpSolrClient.RemoteSolrException.class);
expectedException.expect(BaseHttpSolrClient.RemoteSolrException.class);
expectedException.expectMessage(containsString("ip_1"));
CollectionAdminRequest.createCollectionWithImplicitRouter(rulesColl, "conf", "shard1", 2)

View File

@ -26,9 +26,9 @@ import java.util.Map;
import org.apache.solr.client.solrj.ResponseParser;
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.BinaryResponseParser;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.NoOpResponseParser;
import org.apache.solr.client.solrj.impl.XMLResponseParser;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
@ -71,7 +71,7 @@ public class V2ApiIntegrationTest extends SolrCloudTestCase {
.withPayload(payload)
.build();
v2Request.setResponseParser(responseParser);
HttpSolrClient.RemoteSolrException ex = expectThrows(HttpSolrClient.RemoteSolrException.class,
BaseHttpSolrClient.RemoteSolrException ex = expectThrows(BaseHttpSolrClient.RemoteSolrException.class,
() -> v2Request.process(cluster.getSolrClient()));
assertEquals(expectedCode, ex.code());
}

View File

@ -19,8 +19,8 @@ package org.apache.solr.schema;
import java.util.concurrent.TimeUnit;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.schema.SchemaRequest;
import org.apache.solr.client.solrj.response.schema.SchemaResponse;
@ -52,7 +52,7 @@ public class SchemaApiFailureTest extends SolrCloudTestCase {
(Utils.makeMap("name","myfield", "type","string"));
SchemaResponse.UpdateResponse updateResponse = fieldAddition.process(client, COLLECTION);
HttpSolrClient.RemoteExecutionException ex = expectThrows(HttpSolrClient.RemoteExecutionException.class,
BaseHttpSolrClient.RemoteExecutionException ex = expectThrows(BaseHttpSolrClient.RemoteExecutionException.class,
() -> fieldAddition.process(client, COLLECTION));
assertTrue("expected error message 'Field 'myfield' already exists'.",Utils.getObjectByPath(ex.getMetaData(), false, "error/details[0]/errorMessages[0]").toString().contains("Field 'myfield' already exists.") );

View File

@ -39,6 +39,7 @@ 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.embedded.JettySolrRunner;
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.request.CollectionAdminRequest;
@ -150,7 +151,7 @@ public class BasicAuthIntegrationTest extends SolrCloudAuthTestCase {
cluster.getSolrClient().getHttpClient().getConnectionManager().closeExpiredConnections();
cluster.getSolrClient().getHttpClient().getConnectionManager().closeIdleConnections(1, TimeUnit.MILLISECONDS);
HttpSolrClient.RemoteSolrException exp = expectThrows(HttpSolrClient.RemoteSolrException.class, () -> {
BaseHttpSolrClient.RemoteSolrException exp = expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> {
cluster.getSolrClient().request(genericReq);
});
assertEquals(401, exp.code());
@ -202,14 +203,14 @@ public class BasicAuthIntegrationTest extends SolrCloudAuthTestCase {
CollectionAdminRequest.Reload reload = CollectionAdminRequest.reloadCollection(COLLECTION);
try (HttpSolrClient solrClient = getHttpSolrClient(baseUrl)) {
expectThrows(HttpSolrClient.RemoteSolrException.class, () -> solrClient.request(reload));
expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> solrClient.request(reload));
reload.setMethod(SolrRequest.METHOD.POST);
expectThrows(HttpSolrClient.RemoteSolrException.class, () -> solrClient.request(reload));
expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> solrClient.request(reload));
}
cluster.getSolrClient().request(CollectionAdminRequest.reloadCollection(COLLECTION)
.setBasicAuthCredentials("harry", "HarryIsUberCool"));
expectThrows(HttpSolrClient.RemoteSolrException.class, () -> {
expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> {
cluster.getSolrClient().request(CollectionAdminRequest.reloadCollection(COLLECTION)
.setBasicAuthCredentials("harry", "Cool12345"));
});
@ -231,7 +232,7 @@ public class BasicAuthIntegrationTest extends SolrCloudAuthTestCase {
delQuery.setBasicAuthCredentials("harry","HarryIsUberCool");
delQuery.process(aNewClient, COLLECTION);//this should succeed
try {
HttpSolrClient.RemoteSolrException e = expectThrows(HttpSolrClient.RemoteSolrException.class, () -> {
BaseHttpSolrClient.RemoteSolrException e = expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> {
new UpdateRequest().deleteByQuery("*:*").process(aNewClient, COLLECTION);
});
assertTrue(e.getMessage(), e.getMessage().contains("Authentication failed"));
@ -267,7 +268,7 @@ public class BasicAuthIntegrationTest extends SolrCloudAuthTestCase {
SolrParams params = new MapSolrParams(Collections.singletonMap("q", "*:*"));
// Query that fails due to missing credentials
exp = expectThrows(HttpSolrClient.RemoteSolrException.class, () -> {
exp = expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> {
cluster.getSolrClient().query(COLLECTION, params);
});
assertEquals(401, exp.code());

View File

@ -27,6 +27,7 @@ import org.apache.http.HttpStatus;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.LBHttpSolrClient;
@ -115,7 +116,7 @@ public class TestDelegationWithHadoopAuth extends SolrCloudTestCase {
DelegationTokenResponse.Renew renewResponse = renew.process(client);
assertEquals(HttpStatus.SC_OK, expectedStatusCode);
return renewResponse.getExpirationTime();
} catch (HttpSolrClient.RemoteSolrException ex) {
} catch (BaseHttpSolrClient.RemoteSolrException ex) {
assertEquals(expectedStatusCode, ex.code());
return -1;
}
@ -127,7 +128,7 @@ public class TestDelegationWithHadoopAuth extends SolrCloudTestCase {
try {
cancel.process(client);
assertEquals(HttpStatus.SC_OK, expectedStatusCode);
} catch (HttpSolrClient.RemoteSolrException ex) {
} catch (BaseHttpSolrClient.RemoteSolrException ex) {
assertEquals(expectedStatusCode, ex.code());
}
}
@ -191,7 +192,7 @@ public class TestDelegationWithHadoopAuth extends SolrCloudTestCase {
try {
delegationTokenClient.request(req, null);
return HttpStatus.SC_OK;
} catch (HttpSolrClient.RemoteSolrException re) {
} catch (BaseHttpSolrClient.RemoteSolrException re) {
return re.code();
}
} finally {
@ -204,7 +205,7 @@ public class TestDelegationWithHadoopAuth extends SolrCloudTestCase {
try {
client.request(request);
assertEquals(HttpStatus.SC_OK, expectedStatusCode);
} catch (HttpSolrClient.RemoteSolrException ex) {
} catch (BaseHttpSolrClient.RemoteSolrException ex) {
assertEquals(expectedStatusCode, ex.code());
}
}

View File

@ -25,6 +25,7 @@ import java.util.Map;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.cloud.SolrCloudTestCase;
@ -99,7 +100,7 @@ public class TestImpersonationWithHadoopAuth extends SolrCloudTestCase {
@Test
public void testProxyNoConfigGroups() throws Exception {
try (SolrClient solrClient = newSolrClient()) {
HttpSolrClient.RemoteSolrException ex = expectThrows(HttpSolrClient.RemoteSolrException.class,
BaseHttpSolrClient.RemoteSolrException ex = expectThrows(BaseHttpSolrClient.RemoteSolrException.class,
() -> solrClient.request(getProxyRequest("noGroups","bar")));
assertTrue(ex.getLocalizedMessage(), ex.getMessage().contains(getExpectedGroupExMsg("noGroups", "bar")));
}
@ -108,7 +109,7 @@ public class TestImpersonationWithHadoopAuth extends SolrCloudTestCase {
@Test
public void testProxyWrongHost() throws Exception {
try (SolrClient solrClient = newSolrClient()) {
HttpSolrClient.RemoteSolrException ex = expectThrows(HttpSolrClient.RemoteSolrException.class,
BaseHttpSolrClient.RemoteSolrException ex = expectThrows(BaseHttpSolrClient.RemoteSolrException.class,
() -> solrClient.request(getProxyRequest("wrongHost","bar")));
assertTrue(ex.getMessage().contains(getExpectedHostExMsg("wrongHost")));
}
@ -117,7 +118,7 @@ public class TestImpersonationWithHadoopAuth extends SolrCloudTestCase {
@Test
public void testProxyNoConfigHosts() throws Exception {
try (SolrClient solrClient = newSolrClient()) {
HttpSolrClient.RemoteSolrException ex = expectThrows(HttpSolrClient.RemoteSolrException.class,
BaseHttpSolrClient.RemoteSolrException ex = expectThrows(BaseHttpSolrClient.RemoteSolrException.class,
() -> solrClient.request(getProxyRequest("noHosts","bar")));
assertTrue(ex.getMessage().contains(getExpectedHostExMsg("noHosts")));
}
@ -135,7 +136,7 @@ public class TestImpersonationWithHadoopAuth extends SolrCloudTestCase {
public void testProxyInvalidProxyUser() throws Exception {
try (SolrClient solrClient = newSolrClient()) {
// wrong direction, should fail
HttpSolrClient.RemoteSolrException ex = expectThrows(HttpSolrClient.RemoteSolrException.class,
BaseHttpSolrClient.RemoteSolrException ex = expectThrows(BaseHttpSolrClient.RemoteSolrException.class,
() -> solrClient.request(getProxyRequest("bar","anyHostAnyUser")));
assertTrue(ex.getMessage().contains(getExpectedGroupExMsg("bar", "anyHostAnyUser")));
}
@ -160,7 +161,7 @@ public class TestImpersonationWithHadoopAuth extends SolrCloudTestCase {
@Test
public void testProxyInvalidGroup() throws Exception {
try (SolrClient solrClient = newSolrClient()) {
HttpSolrClient.RemoteSolrException ex = expectThrows(HttpSolrClient.RemoteSolrException.class,
BaseHttpSolrClient.RemoteSolrException ex = expectThrows(BaseHttpSolrClient.RemoteSolrException.class,
() -> solrClient.request(getProxyRequest("bogusGroup","bar")));
assertTrue(ex.getMessage().contains(getExpectedGroupExMsg("bogusGroup", "bar")));
}
@ -169,7 +170,7 @@ public class TestImpersonationWithHadoopAuth extends SolrCloudTestCase {
@Test
public void testProxyNullProxyUser() throws Exception {
try (SolrClient solrClient = newSolrClient()) {
expectThrows(HttpSolrClient.RemoteSolrException.class, () -> solrClient.request(getProxyRequest("","bar")));
expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> solrClient.request(getProxyRequest("","bar")));
}
}

View File

@ -96,6 +96,10 @@ _(raw; not yet edited)_
* SOLR-14012: unique and hll aggregations always returns long value irrespective of standalone or solcloud
(Munendra S N, hossman)
* SOLR-14344: Remove Deprecated HttpSolrClient.RemoteSolrException and HttpSolrClient.RemoteExcecutionException.
All the usages are replaced by BaseHttpSolrClient.RemoteSolrException and BaseHttpSolrClient.RemoteExcecutionException.
(Munendra S N)
=== Upgrade Prerequisites in Solr 9

View File

@ -259,7 +259,7 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
String baseUrl = Utils.getBaseUrlForNodeName(nodeName, urlScheme);
try (SolrClient client = getSolrClient(baseUrl)) {
return fetchClusterState(client, null, null);
} catch (SolrServerException | HttpSolrClient.RemoteSolrException | IOException e) {
} catch (SolrServerException | BaseHttpSolrClient.RemoteSolrException | IOException e) {
log.warn("Attempt to fetch cluster state from {} failed.", baseUrl, e);
} catch (NotACollectionException e) {
// not possible! (we passed in null for collection so it can't be an alias)
@ -282,7 +282,7 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
Map<String, Object> clusterProperties = new HashMap<>();
fetchClusterState(client, null, clusterProperties);
return clusterProperties;
} catch (SolrServerException | HttpSolrClient.RemoteSolrException | IOException e) {
} catch (SolrServerException | BaseHttpSolrClient.RemoteSolrException | IOException e) {
log.warn("Attempt to fetch cluster state from {} failed.", baseUrl, e);
} catch (NotACollectionException e) {
// not possible! (we passed in null for collection so it can't be an alias)

View File

@ -48,7 +48,7 @@ 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 HttpSolrClient.RemoteSolrException {
public static class RemoteExecutionException extends RemoteSolrException {
private NamedList meta;
public RemoteExecutionException(String remoteHost, int code, String msg, NamedList meta) {
@ -57,12 +57,12 @@ public abstract class BaseHttpSolrClient extends SolrClient {
}
public static HttpSolrClient.RemoteExecutionException create(String host, NamedList errResponse) {
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 HttpSolrClient.RemoteExecutionException(host, code == null ? ErrorCode.UNKNOWN.code : code.intValue(),
return new RemoteExecutionException(host, code == null ? ErrorCode.UNKNOWN.code : code.intValue(),
msg == null ? "Unknown Error" : msg, errResponse);
} else {

View File

@ -271,7 +271,7 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
// don't want to fail to report error if parsing the response fails
log.warn("Failed to parse error response from " + basePath + " due to: " + exc);
} finally {
solrExc = new HttpSolrClient.RemoteSolrException(basePath , statusCode, msg.toString(), null);
solrExc = new BaseHttpSolrClient.RemoteSolrException(basePath , statusCode, msg.toString(), null);
if (metadata != null) {
solrExc.setMetadata(metadata);
}

View File

@ -389,7 +389,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
// don't want to fail to report error if parsing the response fails
log.warn("Failed to parse error response from " + client.getBaseURL() + " due to: " + exc);
} finally {
solrExc = new HttpSolrClient.RemoteSolrException(client.getBaseURL(), statusCode, msg.toString(), null);
solrExc = new BaseHttpSolrClient.RemoteSolrException(client.getBaseURL(), statusCode, msg.toString(), null);
if (metadata != null) {
solrExc.setMetadata(metadata);
}

View File

@ -813,29 +813,6 @@ s * @deprecated since 7.0 Use {@link Builder} methods instead.
this.useMultiPartPost = useMultiPartPost;
}
/**
* @deprecated since 8.0, catch {@link BaseHttpSolrClient.RemoteSolrException} instead
*/
@Deprecated
public static class RemoteSolrException extends BaseHttpSolrClient.RemoteSolrException {
public RemoteSolrException(String remoteHost, int code, String msg, Throwable th) {
super(remoteHost, code, msg, th);
}
}
/**
* @deprecated since 8.0, catch {@link BaseHttpSolrClient.RemoteExecutionException} instead
*/
@Deprecated
public static class RemoteExecutionException extends BaseHttpSolrClient.RemoteExecutionException {
public RemoteExecutionException(String remoteHost, int code, String msg, NamedList meta) {
super(remoteHost, code, msg, meta);
}
}
/**
* Constructs {@link HttpSolrClient} instances from provided configuration.
*/

View File

@ -369,7 +369,7 @@ public abstract class LBSolrClient extends SolrClient {
if (isZombie) {
zombieServers.remove(baseUrl);
}
} catch (HttpSolrClient.RemoteExecutionException e){
} catch (BaseHttpSolrClient.RemoteExecutionException e){
throw e;
} catch(SolrException e) {
// we retry on 404 or 403 or 503 or 500

View File

@ -42,7 +42,7 @@ import org.apache.solr.client.solrj.embedded.SolrExampleStreamingHttp2Test;
import org.apache.solr.client.solrj.embedded.SolrExampleStreamingTest.ErrorTrackingConcurrentUpdateSolrClient;
import org.apache.solr.client.solrj.impl.BinaryResponseParser;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient.RemoteSolrException;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteSolrException;
import org.apache.solr.client.solrj.impl.NoOpResponseParser;
import org.apache.solr.client.solrj.impl.XMLResponseParser;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;

View File

@ -17,7 +17,6 @@
package org.apache.solr.client.solrj;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -39,6 +38,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.io.IOUtils;
import org.apache.solr.SolrJettyTestBase;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.BinaryRequestWriter;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.RequestWriter;
@ -205,7 +205,7 @@ public class TestSolrJErrorHandling extends SolrJettyTestBase {
try {
client.add(manyDocs(threadNum*1000000, 1000));
}
catch (HttpSolrClient.RemoteSolrException e) {
catch (BaseHttpSolrClient.RemoteSolrException e) {
String msg = e.getMessage();
assertTrue(msg, msg.contains("field_does_not_exist"));
}

View File

@ -694,7 +694,7 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {
Replica r = coll.getSlices().iterator().next().getReplicas().iterator().next();
SolrQuery q = new SolrQuery().setQuery("*:*");
HttpSolrClient.RemoteSolrException sse = null;
BaseHttpSolrClient.RemoteSolrException sse = null;
final String url = r.getStr(ZkStateReader.BASE_URL_PROP) + "/" + COLLECTION;
try (HttpSolrClient solrClient = getHttpSolrClient(url)) {
@ -741,7 +741,7 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {
try {
QueryResponse rsp = solrClient.query(q);
log.info("error was expected");
} catch (HttpSolrClient.RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
sse = e;
}
assertNotNull(sse);

View File

@ -680,7 +680,7 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
Replica r = coll.getSlices().iterator().next().getReplicas().iterator().next();
SolrQuery q = new SolrQuery().setQuery("*:*");
HttpSolrClient.RemoteSolrException sse = null;
BaseHttpSolrClient.RemoteSolrException sse = null;
final String url = r.getStr(ZkStateReader.BASE_URL_PROP) + "/" + COLLECTION;
try (HttpSolrClient solrClient = getHttpSolrClient(url)) {
@ -727,7 +727,7 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
try {
QueryResponse rsp = solrClient.query(q);
log.info("error was expected");
} catch (HttpSolrClient.RemoteSolrException e) {
} catch (BaseHttpSolrClient.RemoteSolrException e) {
sse = e;
}
assertNotNull(sse);

View File

@ -16,10 +16,6 @@
*/
package org.apache.solr.client.solrj.request;
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
@ -33,7 +29,7 @@ import java.util.TreeMap;
import org.apache.commons.io.FileUtils;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.request.schema.AnalyzerDefinition;
import org.apache.solr.client.solrj.request.schema.FieldTypeDefinition;
import org.apache.solr.client.solrj.request.schema.SchemaRequest;
@ -51,6 +47,10 @@ import org.junit.Before;
import org.junit.Test;
import org.restlet.ext.servlet.ServerServlet;
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
/**
* Test the functionality (accuracy and failure) of the methods exposed by the classes
* {@link SchemaRequest} and {@link SchemaResponse}.
@ -62,7 +62,7 @@ public class SchemaTest extends RestTestBase {
}
private static void assertFailedSchemaResponse(ThrowingRunnable runnable, String expectedErrorMessage) {
HttpSolrClient.RemoteExecutionException e = expectThrows(HttpSolrClient.RemoteExecutionException.class, runnable);
BaseHttpSolrClient.RemoteExecutionException e = expectThrows(BaseHttpSolrClient.RemoteExecutionException.class, runnable);
SimpleOrderedMap errorMap = (SimpleOrderedMap)e.getMetaData().get("error");
assertEquals("org.apache.solr.api.ApiBag$ExceptionWithErrObject",
((NamedList)errorMap.get("metadata")).get("error-class"));

View File

@ -135,7 +135,7 @@ public class TestV2Request extends SolrCloudTestCase {
" }" +
"}" + ", 'something':'bogus'").build());
assertFalse("The request failed", res1.get("responseHeader").toString().contains("status=0"));
}catch(BaseHttpSolrClient.RemoteExecutionException itsOk) {
} catch(BaseHttpSolrClient.RemoteExecutionException itsOk) {
}
}