Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOLR-17285: Move RemoteSolrException to SolrClient in v10 #2587

Merged
merged 4 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ Other Changes

* SOLR-17279: Introduce SecurityJson.java file to Test Framework to consolidate setting up authentication in tests. (Rudy Seitz via Eric Pugh)

* SOLR-17285: SolrJ RemoteSolrException moved to SolrClient. (@samuelrivascoding)

================== 9.8.0 ==================
New Features
---------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrResponse;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
Expand Down Expand Up @@ -447,8 +446,8 @@ static void processResponse(
String shard,
Set<String> okayExceptions) {
String rootThrowable = null;
if (e instanceof BaseHttpSolrClient.RemoteSolrException) {
rootThrowable = ((BaseHttpSolrClient.RemoteSolrException) e).getRootThrowable();
if (e instanceof SolrClient.RemoteSolrException) {
rootThrowable = ((SolrClient.RemoteSolrException) e).getRootThrowable();
}

if (e != null && (rootThrowable == null || !okayExceptions.contains(rootThrowable))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
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.response.FacetField;
import org.apache.solr.client.solrj.response.FieldStatsInfo;
import org.apache.solr.client.solrj.response.QueryResponse;
Expand Down Expand Up @@ -1710,7 +1709,7 @@ public void test() throws Exception {
tdate_b,
"stats.calcdistinct",
"true");
} catch (BaseHttpSolrClient.RemoteSolrException e) {
} catch (SolrClient.RemoteSolrException e) {
if (e.getMessage().startsWith("java.lang.NullPointerException")) {
fail("NullPointerException with stats request on empty index");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Properties;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.response.RequestStatusState;
Expand Down Expand Up @@ -87,7 +87,7 @@ public void testCreateCollectionCleanup() throws Exception {
properties.put(CoreAdminParams.DATA_DIR, tmpDir.toString());
create.setProperties(properties);
expectThrows(
BaseHttpSolrClient.RemoteSolrException.class,
SolrClient.RemoteSolrException.class,
() -> {
create.process(cloudClient);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.solr.client.solrj.SolrClient;
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.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
Expand Down Expand Up @@ -224,10 +224,9 @@ private void checkAbsentFromIndex(String fromColl, String toColl, boolean isScor
+ " to=join_s}match_s:c";
final QueryRequest qr =
new QueryRequest(params("collection", toColl, "q", joinQ, "fl", "id,get_s,score"));
BaseHttpSolrClient.RemoteSolrException ex =
SolrClient.RemoteSolrException ex =
assertThrows(
BaseHttpSolrClient.RemoteSolrException.class,
() -> cluster.getSolrClient().request(qr));
SolrClient.RemoteSolrException.class, () -> cluster.getSolrClient().request(qr));
assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, ex.code());
assertTrue(ex.getMessage().contains(wrongName));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import java.lang.invoke.MethodHandles;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrClient.RemoteSolrException;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteSolrException;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
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.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.response.QueryResponse;
Expand Down Expand Up @@ -88,9 +87,9 @@ public void testMissingSplitKey() throws Exception {
CollectionAdminRequest.createCollection(targetCollection, "conf", 1, 1)
.process(cluster.getSolrClient());

BaseHttpSolrClient.RemoteSolrException remoteSolrException =
SolrClient.RemoteSolrException remoteSolrException =
expectThrows(
BaseHttpSolrClient.RemoteSolrException.class,
SolrClient.RemoteSolrException.class,
"Expected an exception in case split.key is not specified",
() -> {
CollectionAdminRequest.migrateData(sourceCollection, targetCollection, "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.Random;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.CollectionAdminRequest.Create;
import org.apache.solr.client.solrj.request.CollectionAdminRequest.SplitShard;
Expand Down Expand Up @@ -261,7 +260,7 @@ public void testDeduplicationOfSubmittedTasks() throws IOException, SolrServerEx
// Now submit another task with the same id. At this time, hopefully the previous 3002 should
// still be in the queue.
expectThrows(
BaseHttpSolrClient.RemoteSolrException.class,
SolrClient.RemoteSolrException.class,
() -> {
CollectionAdminRequest.splitShard("ocptest_shardsplit2")
.setShardName(SHARD1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.solr.cloud;

import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.util.NamedList;
Expand Down Expand Up @@ -89,9 +89,9 @@ public void test() throws Exception {
collection_operations.get(CollectionParams.CollectionAction.RELOAD.toLower());
assertEquals("No stats for reload in OverseerCollectionProcessor", 1, reload.get("requests"));

BaseHttpSolrClient.RemoteSolrException e =
SolrClient.RemoteSolrException e =
expectThrows(
BaseHttpSolrClient.RemoteSolrException.class,
SolrClient.RemoteSolrException.class,
"Split shard for non existent collection should have failed",
() ->
CollectionAdminRequest.splitShard("non_existent_collection")
Expand Down
5 changes: 2 additions & 3 deletions solr/core/src/test/org/apache/solr/cloud/SplitShardTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
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.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
Expand Down Expand Up @@ -107,7 +106,7 @@ public void doTest() throws IOException, SolrServerException {
.setNumSubShards(10);
splitShard.process(cluster.getSolrClient());
fail("SplitShard should throw an exception when numSubShards > 8");
} catch (BaseHttpSolrClient.RemoteSolrException ex) {
} catch (SolrClient.RemoteSolrException ex) {
assertTrue(
ex.getMessage()
.contains("A shard can only be split into 2 to 8 subshards in one split request."));
Expand All @@ -120,7 +119,7 @@ public void doTest() throws IOException, SolrServerException {
.setNumSubShards(1);
splitShard.process(cluster.getSolrClient());
fail("SplitShard should throw an exception when numSubShards < 2");
} catch (BaseHttpSolrClient.RemoteSolrException ex) {
} catch (SolrClient.RemoteSolrException ex) {
assertTrue(
ex.getMessage()
.contains(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.http.HttpRequestInterceptor;
import org.apache.solr.client.solrj.SolrClient;
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.SolrHttpClientBuilder;
Expand Down Expand Up @@ -73,10 +73,9 @@ public void testBasics() throws Exception {

// Should fail with 401
try {
BaseHttpSolrClient.RemoteSolrException e =
SolrClient.RemoteSolrException e =
expectThrows(
BaseHttpSolrClient.RemoteSolrException.class,
this::collectionCreateSearchDeleteTwice);
SolrClient.RemoteSolrException.class, this::collectionCreateSearchDeleteTwice);
assertTrue("Should've returned a 401 error", e.getMessage().contains("Error 401"));
} finally {
MockAuthenticationPlugin.expectedUsername = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
import org.apache.solr.api.AnnotatedApi;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.CloudLegacySolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.request.ConfigSetAdminRequest;
Expand Down Expand Up @@ -1395,7 +1394,7 @@ public void testUploadWithScriptUpdateProcessor() throws Exception {
ignoreException("uploaded without any authentication in place");
Throwable thrown =
expectThrows(
BaseHttpSolrClient.RemoteSolrException.class,
SolrClient.RemoteSolrException.class,
() -> {
createCollection(
"newcollection2",
Expand Down Expand Up @@ -1430,7 +1429,7 @@ public void testUploadWithLibDirective() throws Exception {
ignoreException("without any authentication in place");
Throwable thrown =
expectThrows(
BaseHttpSolrClient.RemoteSolrException.class,
SolrClient.RemoteSolrException.class,
() -> {
createCollection(
"newcollection3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.apache.jute.Record;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrClient;
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;
Expand Down Expand Up @@ -128,8 +127,8 @@ public void testCreateZkFailure() throws Exception {

Create create = new Create();
create.setBaseConfigSetName(BASE_CONFIGSET_NAME).setConfigSetName(CONFIGSET_NAME);
RemoteSolrException se =
expectThrows(RemoteSolrException.class, () -> create.process(solrClient));
SolrClient.RemoteSolrException se =
expectThrows(SolrClient.RemoteSolrException.class, () -> create.process(solrClient));
// partial creation should have been cleaned up
assertFalse(configSetService.checkConfigExists(CONFIGSET_NAME));
assertEquals(SolrException.ErrorCode.SERVER_ERROR.code, se.code());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
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;
Expand Down Expand Up @@ -277,7 +276,7 @@ public void run() {
reloadCollectionRequest.processAsync(
"repeatedId", clients[random().nextInt(clients.length)]);
numSuccess.incrementAndGet();
} catch (SolrServerException | BaseHttpSolrClient.RemoteSolrException e) {
} catch (SolrServerException | SolrClient.RemoteSolrException e) {
if (log.isInfoEnabled()) {
log.info("Exception during collection reloading, we were waiting for one: ", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
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.CloudLegacySolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
Expand Down Expand Up @@ -798,7 +797,7 @@ private void incompleteOrOverlappingCustomRangeTest() throws Exception {
try {
splitShard(AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1, subRanges, null, false);
fail("Shard splitting with just one custom hash range should not succeed");
} catch (BaseHttpSolrClient.RemoteSolrException e) {
} catch (SolrClient.RemoteSolrException e) {
log.info("Expected exception:", e);
}
subRanges.clear();
Expand All @@ -809,7 +808,7 @@ private void incompleteOrOverlappingCustomRangeTest() throws Exception {
try {
splitShard(AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1, subRanges, null, false);
fail("Shard splitting with missing hashes in between given ranges should not succeed");
} catch (BaseHttpSolrClient.RemoteSolrException e) {
} catch (SolrClient.RemoteSolrException e) {
log.info("Expected exception:", e);
}
subRanges.clear();
Expand All @@ -822,7 +821,7 @@ private void incompleteOrOverlappingCustomRangeTest() throws Exception {
try {
splitShard(AbstractDistribZkTestBase.DEFAULT_COLLECTION, SHARD1, subRanges, null, false);
fail("Shard splitting with overlapping ranges should not succeed");
} catch (BaseHttpSolrClient.RemoteSolrException e) {
} catch (SolrClient.RemoteSolrException e) {
log.info("Expected exception:", e);
}
subRanges.clear();
Expand Down Expand Up @@ -914,7 +913,7 @@ private void splitByUniqueKeyTest() throws Exception {
log.info("Layout after split: \n");
printLayout();
break;
} catch (BaseHttpSolrClient.RemoteSolrException e) {
} catch (SolrClient.RemoteSolrException e) {
if (e.code() != 500) {
throw e;
}
Expand Down Expand Up @@ -1133,7 +1132,7 @@ private void trySplit(String collectionName, String splitKey, String shardId, in
try {
splitShard(collectionName, shardId, null, splitKey, false);
break;
} catch (BaseHttpSolrClient.RemoteSolrException e) {
} catch (SolrClient.RemoteSolrException e) {
if (e.code() != 500) {
throw e;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.LongAdder;
import org.apache.solr.client.solrj.SolrClient;
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.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
Expand Down Expand Up @@ -166,7 +166,7 @@ private void testModifyCollection() throws Exception {
try {
client.request(request);
fail("Trying to unset an unknown property should have failed");
} catch (BaseHttpSolrClient.RemoteSolrException e) {
} catch (SolrClient.RemoteSolrException e) {
// expected
assertTrue(e.getMessage().contains("no supported values provided"));
}
Expand All @@ -188,7 +188,7 @@ private void testReplicationFactorValidaton() throws Exception {
try {
client.request(request);
fail();
} catch (BaseHttpSolrClient.RemoteSolrException e) {
} catch (SolrClient.RemoteSolrException e) {
final String errorMessage = e.getMessage();
assertTrue(
errorMessage.contains(
Expand Down Expand Up @@ -1112,7 +1112,7 @@ private void testCollectionCreationCollectionNameValidation() throws Exception {
try {
client.request(request);
fail();
} catch (BaseHttpSolrClient.RemoteSolrException e) {
} catch (SolrClient.RemoteSolrException e) {
final String errorMessage = e.getMessage();
assertTrue(errorMessage.contains("Invalid collection"));
assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
Expand All @@ -1135,7 +1135,7 @@ private void testCollectionCreationShardNameValidation() throws Exception {
try {
client.request(request);
fail();
} catch (BaseHttpSolrClient.RemoteSolrException e) {
} catch (SolrClient.RemoteSolrException e) {
final String errorMessage = e.getMessage();
assertTrue(errorMessage.contains("Invalid shard"));
assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
Expand All @@ -1156,7 +1156,7 @@ private void testAliasCreationNameValidation() throws Exception {
try {
client.request(request);
fail();
} catch (BaseHttpSolrClient.RemoteSolrException e) {
} catch (SolrClient.RemoteSolrException e) {
final String errorMessage = e.getMessage();
assertTrue(errorMessage.contains("Invalid alias"));
assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
Expand Down Expand Up @@ -1189,7 +1189,7 @@ private void testShardCreationNameValidation() throws Exception {
try {
client.request(request);
fail();
} catch (BaseHttpSolrClient.RemoteSolrException e) {
} catch (SolrClient.RemoteSolrException e) {
final String errorMessage = e.getMessage();
assertTrue(errorMessage.contains("Invalid shard"));
assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
Expand Down Expand Up @@ -1261,9 +1261,9 @@ public void testRecreateCollectionAfterFailure() throws Exception {

try (CloudSolrClient client = createCloudClient(null)) {
// first, try creating a collection with badconf
BaseHttpSolrClient.RemoteSolrException rse =
SolrClient.RemoteSolrException rse =
expectThrows(
BaseHttpSolrClient.RemoteSolrException.class,
SolrClient.RemoteSolrException.class,
() -> {
CollectionAdminRequest.createCollection("testcollection", "badconf", 1, 2)
.process(client);
Expand Down
Loading
Loading