diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index bac9c16ec23..6142cbb9e9e 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -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 --------------------- diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/CollectionHandlingUtils.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/CollectionHandlingUtils.java index dbd82f905da..1816d96f5d7 100644 --- a/solr/core/src/java/org/apache/solr/cloud/api/collections/CollectionHandlingUtils.java +++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/CollectionHandlingUtils.java @@ -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; @@ -447,8 +446,8 @@ static void processResponse( String shard, Set 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))) { diff --git a/solr/core/src/test/org/apache/solr/TestDistributedSearch.java b/solr/core/src/test/org/apache/solr/TestDistributedSearch.java index fb3a1137734..375f0cc479f 100644 --- a/solr/core/src/test/org/apache/solr/TestDistributedSearch.java +++ b/solr/core/src/test/org/apache/solr/TestDistributedSearch.java @@ -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; @@ -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 { diff --git a/solr/core/src/test/org/apache/solr/cloud/CreateCollectionCleanupTest.java b/solr/core/src/test/org/apache/solr/cloud/CreateCollectionCleanupTest.java index fcc77078a11..ac31461d509 100644 --- a/solr/core/src/test/org/apache/solr/cloud/CreateCollectionCleanupTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/CreateCollectionCleanupTest.java @@ -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; @@ -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); }); diff --git a/solr/core/src/test/org/apache/solr/cloud/DistribJoinFromCollectionTest.java b/solr/core/src/test/org/apache/solr/cloud/DistribJoinFromCollectionTest.java index 0a772a5609b..e22770d4222 100644 --- a/solr/core/src/test/org/apache/solr/cloud/DistribJoinFromCollectionTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/DistribJoinFromCollectionTest.java @@ -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; @@ -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)); } diff --git a/solr/core/src/test/org/apache/solr/cloud/LeaderTragicEventTest.java b/solr/core/src/test/org/apache/solr/cloud/LeaderTragicEventTest.java index a40adaa5046..4fba87d940b 100644 --- a/solr/core/src/test/org/apache/solr/cloud/LeaderTragicEventTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/LeaderTragicEventTest.java @@ -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; diff --git a/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java b/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java index dc0750fb7f0..fcbec76bfbb 100644 --- a/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/MigrateRouteKeyTest.java @@ -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; @@ -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, "") diff --git a/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java b/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java index a3c5b152cb6..e67fa4f280e 100644 --- a/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/MultiThreadedOCPTest.java @@ -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; @@ -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) diff --git a/solr/core/src/test/org/apache/solr/cloud/OverseerStatusTest.java b/solr/core/src/test/org/apache/solr/cloud/OverseerStatusTest.java index 625af5cd595..8e99d751854 100644 --- a/solr/core/src/test/org/apache/solr/cloud/OverseerStatusTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/OverseerStatusTest.java @@ -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; @@ -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") diff --git a/solr/core/src/test/org/apache/solr/cloud/SplitShardTest.java b/solr/core/src/test/org/apache/solr/cloud/SplitShardTest.java index a213af89c6e..132dfcfaaa2 100644 --- a/solr/core/src/test/org/apache/solr/cloud/SplitShardTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/SplitShardTest.java @@ -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; @@ -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.")); @@ -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( diff --git a/solr/core/src/test/org/apache/solr/cloud/TestAuthenticationFramework.java b/solr/core/src/test/org/apache/solr/cloud/TestAuthenticationFramework.java index 3b9bdf1b434..c8577302c8d 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestAuthenticationFramework.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestAuthenticationFramework.java @@ -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; @@ -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; diff --git a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java index f57c2db82c3..b41d698ac4c 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPI.java @@ -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; @@ -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", @@ -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", diff --git a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIZkFailure.java b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIZkFailure.java index 368d33d0098..3afb80e9e03 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIZkFailure.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestConfigSetsAPIZkFailure.java @@ -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; @@ -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()); diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIAsyncDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIAsyncDistributedZkTest.java index 20bcabbfaf7..ff64f01014f 100644 --- a/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIAsyncDistributedZkTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/CollectionsAPIAsyncDistributedZkTest.java @@ -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; @@ -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); } diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/ShardSplitTest.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/ShardSplitTest.java index c53636c63f5..43f3367f489 100644 --- a/solr/core/src/test/org/apache/solr/cloud/api/collections/ShardSplitTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/ShardSplitTest.java @@ -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; @@ -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(); @@ -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(); @@ -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(); @@ -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; } @@ -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; } diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java index 259131938fe..760bf0bfe93 100644 --- a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java +++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java @@ -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; @@ -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")); } @@ -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( @@ -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")); @@ -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")); @@ -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")); @@ -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")); @@ -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); diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestRequestStatusCollectionAPI.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestRequestStatusCollectionAPI.java index 3a9f736c440..8cf5dca2cc7 100644 --- a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestRequestStatusCollectionAPI.java +++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestRequestStatusCollectionAPI.java @@ -25,7 +25,6 @@ import java.util.concurrent.TimeUnit; 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.HttpSolrClient; import org.apache.solr.client.solrj.request.QueryRequest; import org.apache.solr.client.solrj.response.RequestStatusState; @@ -171,9 +170,9 @@ public void test() { duplicateRequestIdParams.set("collection.configName", "conf1"); duplicateRequestIdParams.set(CommonAdminParams.ASYNC, "1002"); - final BaseHttpSolrClient.RemoteSolrException thrown = + final SolrClient.RemoteSolrException thrown = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> { sendRequest(duplicateRequestIdParams); }); diff --git a/solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.java b/solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.java index 284f268acc2..651d4a8ed93 100644 --- a/solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.java +++ b/solr/core/src/test/org/apache/solr/handler/V2ApiIntegrationTest.java @@ -23,9 +23,9 @@ import java.util.List; import java.util.Map; import org.apache.solr.client.solrj.ResponseParser; +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; import org.apache.solr.client.solrj.impl.BinaryResponseParser; import org.apache.solr.client.solrj.impl.CloudSolrClient; import org.apache.solr.client.solrj.impl.JsonMapResponseParser; @@ -74,9 +74,9 @@ private void testException( .withPayload(payload) .build(); v2Request.setResponseParser(responseParser); - BaseHttpSolrClient.RemoteSolrException ex = + SolrClient.RemoteSolrException ex = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> { v2Request.process(cluster.getSolrClient()); }); diff --git a/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java index 2dd9fce1224..3f7ec3080d5 100644 --- a/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminHandlerTest.java @@ -34,7 +34,6 @@ import org.apache.solr.SolrTestCaseJ4; 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.HttpSolrClient; import org.apache.solr.client.solrj.request.CoreAdminRequest; import org.apache.solr.client.solrj.request.CoreStatus; @@ -419,9 +418,9 @@ public void testUnloadForever() throws Exception { req.process(client); } - BaseHttpSolrClient.RemoteSolrException rse = + SolrClient.RemoteSolrException rse = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> { try (SolrClient client = new HttpSolrClient.Builder(runner.getBaseUrl().toString()) diff --git a/solr/core/src/test/org/apache/solr/handler/admin/HealthCheckHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/HealthCheckHandlerTest.java index a843f5b9360..6955b994f7a 100644 --- a/solr/core/src/test/org/apache/solr/handler/admin/HealthCheckHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/admin/HealthCheckHandlerTest.java @@ -26,7 +26,6 @@ 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; import org.apache.solr.client.solrj.request.CollectionAdminRequest; import org.apache.solr.client.solrj.request.GenericSolrRequest; import org.apache.solr.client.solrj.request.HealthCheckRequest; @@ -102,9 +101,9 @@ public void testHealthCheckHandler() throws Exception { newJetty.getCoreContainer().getZkController().getZkClient().close(); // negative check of our (new) "broken" node that we deliberately put into an unhealthy state - BaseHttpSolrClient.RemoteSolrException e = + SolrClient.RemoteSolrException e = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> { runHealthcheckWithClient(solrClient); }); @@ -164,9 +163,9 @@ public void testHealthCheckV2Api() throws Exception { newJetty.getCoreContainer().getZkController().getZkClient().close(); // negative check of our (new) "broken" node that we deliberately put into an unhealthy state - BaseHttpSolrClient.RemoteSolrException e = + SolrClient.RemoteSolrException e = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> { new V2Request.Builder("/node/health").build().process(solrClient); }); diff --git a/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java index 8f4c542d8e8..dca5193941d 100644 --- a/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java @@ -24,7 +24,6 @@ import org.apache.solr.client.solrj.ResponseParser; 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.NoOpResponseParser; import org.apache.solr.client.solrj.request.QueryRequest; import org.apache.solr.client.solrj.response.QueryResponse; @@ -170,7 +169,7 @@ public void testEscapeConfDir() { request.setPath("/admin/file"); request.setResponseParser(new NoOpResponseParser()); var ex = expectThrows(SolrException.class, () -> client.request(request)); - assertTrue(ex instanceof BaseHttpSolrClient.RemoteSolrException); + assertTrue(ex instanceof SolrClient.RemoteSolrException); } public void testPathTraversalFilename() { diff --git a/solr/core/src/test/org/apache/solr/security/BasicAuthIntegrationTest.java b/solr/core/src/test/org/apache/solr/security/BasicAuthIntegrationTest.java index 1c960c07e1f..281c6475611 100644 --- a/solr/core/src/test/org/apache/solr/security/BasicAuthIntegrationTest.java +++ b/solr/core/src/test/org/apache/solr/security/BasicAuthIntegrationTest.java @@ -41,7 +41,6 @@ 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; import org.apache.solr.client.solrj.impl.CloudLegacySolrClient; import org.apache.solr.client.solrj.impl.HttpClientUtil; import org.apache.solr.client.solrj.request.CollectionAdminRequest; @@ -154,9 +153,9 @@ public void testBasicAuth() throws Exception { httpClient.getConnectionManager().closeExpiredConnections(); httpClient.getConnectionManager().closeIdleConnections(1, TimeUnit.MILLISECONDS); - BaseHttpSolrClient.RemoteSolrException exp = + SolrClient.RemoteSolrException exp = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> { cluster.getSolrClient().request(genericReq); }); @@ -223,11 +222,9 @@ public void testBasicAuth() throws Exception { CollectionAdminRequest.Reload reload = CollectionAdminRequest.reloadCollection(COLLECTION); try (SolrClient solrClient = getHttpSolrClient(baseUrl)) { - expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, () -> solrClient.request(reload)); + expectThrows(SolrClient.RemoteSolrException.class, () -> solrClient.request(reload)); reload.setMethod(SolrRequest.METHOD.POST); - expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, () -> solrClient.request(reload)); + expectThrows(SolrClient.RemoteSolrException.class, () -> solrClient.request(reload)); } cluster .getSolrClient() @@ -236,7 +233,7 @@ public void testBasicAuth() throws Exception { .setBasicAuthCredentials("harry", "HarryIsUberCool")); expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> { cluster .getSolrClient() @@ -267,9 +264,9 @@ public void testBasicAuth() throws Exception { delQuery.setBasicAuthCredentials("harry", "HarryIsUberCool"); delQuery.process(aNewClient, COLLECTION); // this should succeed try { - BaseHttpSolrClient.RemoteSolrException e = + SolrClient.RemoteSolrException e = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> { new UpdateRequest().deleteByQuery("*:*").process(aNewClient, COLLECTION); }); @@ -321,7 +318,7 @@ public void testBasicAuth() throws Exception { // Query that fails due to missing credentials exp = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> { cluster.getSolrClient().query(COLLECTION, params); }); diff --git a/solr/core/src/test/org/apache/solr/servlet/TestRequestRateLimiter.java b/solr/core/src/test/org/apache/solr/servlet/TestRequestRateLimiter.java index 84c3a81d125..cbe18c8431c 100644 --- a/solr/core/src/test/org/apache/solr/servlet/TestRequestRateLimiter.java +++ b/solr/core/src/test/org/apache/solr/servlet/TestRequestRateLimiter.java @@ -41,7 +41,6 @@ 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.impl.BaseHttpSolrClient.RemoteSolrException; import org.apache.solr.client.solrj.impl.CloudSolrClient; import org.apache.solr.client.solrj.request.CollectionAdminRequest; import org.apache.solr.client.solrj.response.QueryResponse; @@ -392,8 +391,9 @@ private void processTest(SolrClient client, int numDocuments, int numQueries) th try { assertNotNull(future.get()); } catch (ExecutionException e) { - assertThat(e.getCause().getCause(), instanceOf(RemoteSolrException.class)); - RemoteSolrException rse = (RemoteSolrException) e.getCause().getCause(); + assertThat(e.getCause().getCause(), instanceOf(SolrClient.RemoteSolrException.class)); + SolrClient.RemoteSolrException rse = + (SolrClient.RemoteSolrException) e.getCause().getCause(); assertEquals(SolrException.ErrorCode.TOO_MANY_REQUESTS.code, rse.code()); assertThat( rse.getMessage(), containsString("non ok status: 429, message:Too Many Requests")); diff --git a/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestDelegationWithHadoopAuth.java b/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestDelegationWithHadoopAuth.java index 0fd49a52314..207a91ba6d6 100644 --- a/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestDelegationWithHadoopAuth.java +++ b/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestDelegationWithHadoopAuth.java @@ -26,7 +26,6 @@ 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.impl.BaseHttpSolrClient; import org.apache.solr.client.solrj.impl.CloudLegacySolrClient; import org.apache.solr.client.solrj.impl.HttpSolrClient; import org.apache.solr.client.solrj.impl.LBHttpSolrClient; @@ -118,7 +117,7 @@ public Set getQueryParams() { DelegationTokenResponse.Renew renewResponse = renew.process(client); assertEquals(HttpStatus.SC_OK, expectedStatusCode); return renewResponse.getExpirationTime(); - } catch (BaseHttpSolrClient.RemoteSolrException ex) { + } catch (SolrClient.RemoteSolrException ex) { assertEquals(expectedStatusCode, ex.code()); return -1; } @@ -130,7 +129,7 @@ private void cancelDelegationToken(String token, int expectedStatusCode, SolrCli try { cancel.process(client); assertEquals(HttpStatus.SC_OK, expectedStatusCode); - } catch (BaseHttpSolrClient.RemoteSolrException ex) { + } catch (SolrClient.RemoteSolrException ex) { assertEquals(expectedStatusCode, ex.code()); } } @@ -199,7 +198,7 @@ private int getStatusCode(String token, final String user, final String op, Http try { delegationTokenClient.request(req, null); return HttpStatus.SC_OK; - } catch (BaseHttpSolrClient.RemoteSolrException re) { + } catch (SolrClient.RemoteSolrException re) { return re.code(); } } finally { @@ -212,7 +211,7 @@ private void doSolrRequest(SolrClient client, SolrRequest request, int expect try { client.request(request); assertEquals(HttpStatus.SC_OK, expectedStatusCode); - } catch (BaseHttpSolrClient.RemoteSolrException ex) { + } catch (SolrClient.RemoteSolrException ex) { assertEquals(expectedStatusCode, ex.code()); } } diff --git a/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestImpersonationWithHadoopAuth.java b/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestImpersonationWithHadoopAuth.java index a1eb218d609..8679b2788ea 100644 --- a/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestImpersonationWithHadoopAuth.java +++ b/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestImpersonationWithHadoopAuth.java @@ -28,7 +28,6 @@ import java.util.HashMap; import java.util.Map; import org.apache.solr.client.solrj.SolrClient; -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; @@ -108,9 +107,9 @@ private SolrClient newSolrClient() { @Test public void testProxyNoConfigGroups() throws Exception { try (SolrClient solrClient = newSolrClient()) { - BaseHttpSolrClient.RemoteSolrException ex = + SolrClient.RemoteSolrException ex = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> solrClient.request(getProxyRequest("noGroups", "bar"))); assertTrue( ex.getLocalizedMessage(), @@ -121,9 +120,9 @@ public void testProxyNoConfigGroups() throws Exception { @Test public void testProxyWrongHost() throws Exception { try (SolrClient solrClient = newSolrClient()) { - BaseHttpSolrClient.RemoteSolrException ex = + SolrClient.RemoteSolrException ex = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> solrClient.request(getProxyRequest("wrongHost", "bar"))); assertTrue(ex.getMessage().contains(getExpectedHostExMsg("wrongHost"))); } @@ -132,9 +131,9 @@ public void testProxyWrongHost() throws Exception { @Test public void testProxyNoConfigHosts() throws Exception { try (SolrClient solrClient = newSolrClient()) { - BaseHttpSolrClient.RemoteSolrException ex = + SolrClient.RemoteSolrException ex = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> solrClient.request(getProxyRequest("noHosts", "bar"))); assertTrue(ex.getMessage().contains(getExpectedHostExMsg("noHosts"))); } @@ -152,9 +151,9 @@ public void testProxyValidateAnyHostAnyUser() throws Exception { public void testProxyInvalidProxyUser() throws Exception { try (SolrClient solrClient = newSolrClient()) { // wrong direction, should fail - BaseHttpSolrClient.RemoteSolrException ex = + SolrClient.RemoteSolrException ex = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> solrClient.request(getProxyRequest("bar", "anyHostAnyUser"))); assertTrue(ex.getMessage().contains(getExpectedGroupExMsg("bar", "anyHostAnyUser"))); } @@ -179,9 +178,9 @@ public void testProxyValidateGroup() throws Exception { @Test public void testProxyInvalidGroup() throws Exception { try (SolrClient solrClient = newSolrClient()) { - BaseHttpSolrClient.RemoteSolrException ex = + SolrClient.RemoteSolrException ex = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> solrClient.request(getProxyRequest("bogusGroup", "bar"))); assertTrue(ex.getMessage().contains(getExpectedGroupExMsg("bogusGroup", "bar"))); } @@ -191,7 +190,7 @@ public void testProxyInvalidGroup() throws Exception { public void testProxyNullProxyUser() throws Exception { try (SolrClient solrClient = newSolrClient()) { expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> solrClient.request(getProxyRequest("", "bar"))); } } diff --git a/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestRuleBasedAuthorizationWithKerberos.java b/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestRuleBasedAuthorizationWithKerberos.java index 1b6b545d8e0..a6bdd61155c 100644 --- a/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestRuleBasedAuthorizationWithKerberos.java +++ b/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestRuleBasedAuthorizationWithKerberos.java @@ -17,8 +17,8 @@ package org.apache.solr.security.hadoop; import org.apache.lucene.util.Constants; +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.Http2SolrClient; import org.apache.solr.client.solrj.impl.Krb5HttpClientUtils; @@ -94,10 +94,9 @@ public void testReadsAltUser() throws Exception { try (Http2SolrClient client = new Http2SolrClient.Builder(baseUrl).build()) { Krb5HttpClientUtils.setup(client, "solr_alt"); assertEquals(0, client.query(authorizedColl, q).getStatus()); - BaseHttpSolrClient.RemoteSolrException e = + SolrClient.RemoteSolrException e = assertThrows( - BaseHttpSolrClient.RemoteSolrException.class, - () -> client.query(collectionName, q)); + SolrClient.RemoteSolrException.class, () -> client.query(collectionName, q)); assertEquals(403, e.code()); } } diff --git a/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithDelegationTokens.java b/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithDelegationTokens.java index 5ecbbe57250..dfd2d58ed5b 100644 --- a/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithDelegationTokens.java +++ b/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithDelegationTokens.java @@ -29,7 +29,6 @@ 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.impl.BaseHttpSolrClient; import org.apache.solr.client.solrj.impl.CloudLegacySolrClient; import org.apache.solr.client.solrj.impl.HttpSolrClient; import org.apache.solr.client.solrj.impl.LBHttpSolrClient; @@ -134,7 +133,7 @@ public Set getQueryParams() { DelegationTokenResponse.Renew renewResponse = renew.process(client); assertEquals(HttpStatus.SC_OK, expectedStatusCode); return renewResponse.getExpirationTime(); - } catch (BaseHttpSolrClient.RemoteSolrException ex) { + } catch (SolrClient.RemoteSolrException ex) { assertEquals(expectedStatusCode, ex.code()); return -1; } @@ -146,7 +145,7 @@ private void cancelDelegationToken(String token, int expectedStatusCode, HttpSol try { cancel.process(client); assertEquals(HttpStatus.SC_OK, expectedStatusCode); - } catch (BaseHttpSolrClient.RemoteSolrException ex) { + } catch (SolrClient.RemoteSolrException ex) { assertEquals(expectedStatusCode, ex.code()); } } @@ -227,7 +226,7 @@ private int getStatusCode(String token, final String user, final String op, Http try { delegationTokenClient.request(req, null); return HttpStatus.SC_OK; - } catch (BaseHttpSolrClient.RemoteSolrException re) { + } catch (SolrClient.RemoteSolrException re) { return re.code(); } } finally { @@ -240,7 +239,7 @@ private void doSolrRequest(HttpSolrClient client, SolrRequest request, int ex try { client.request(request); assertEquals(HttpStatus.SC_OK, expectedStatusCode); - } catch (BaseHttpSolrClient.RemoteSolrException ex) { + } catch (SolrClient.RemoteSolrException ex) { assertEquals(expectedStatusCode, ex.code()); } } @@ -251,7 +250,7 @@ private void doSolrRequest( try { client.request(request, collectionName); assertEquals(HttpStatus.SC_OK, expectedStatusCode); - } catch (BaseHttpSolrClient.RemoteSolrException ex) { + } catch (SolrClient.RemoteSolrException ex) { assertEquals(expectedStatusCode, ex.code()); } } diff --git a/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithSecureImpersonation.java b/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithSecureImpersonation.java index 834c422ca30..2155965e3b6 100644 --- a/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithSecureImpersonation.java +++ b/solr/modules/hadoop-auth/src/test/org/apache/solr/security/hadoop/TestSolrCloudWithSecureImpersonation.java @@ -30,7 +30,6 @@ 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.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; @@ -233,27 +232,27 @@ private String getExpectedHostExMsg(String user) { @Test public void testProxyNoConfigGroups() { - BaseHttpSolrClient.RemoteSolrException e = + SolrClient.RemoteSolrException e = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> solrClient.request(getProxyRequest("noGroups", "bar"))); assertTrue(e.getMessage().contains(getExpectedGroupExMsg("noGroups", "bar"))); } @Test public void testProxyWrongHost() { - BaseHttpSolrClient.RemoteSolrException e = + SolrClient.RemoteSolrException e = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> solrClient.request(getProxyRequest("wrongHost", "bar"))); assertTrue(e.getMessage().contains(getExpectedHostExMsg("wrongHost"))); } @Test public void testProxyNoConfigHosts() { - BaseHttpSolrClient.RemoteSolrException e = + SolrClient.RemoteSolrException e = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> solrClient.request(getProxyRequest("noHosts", "bar"))); assertTrue(e.getMessage().contains(getExpectedHostExMsg("noHosts"))); } @@ -267,9 +266,9 @@ public void testProxyValidateAnyHostAnyUser() throws Exception { @Test public void testProxyInvalidProxyUser() { // wrong direction, should fail - BaseHttpSolrClient.RemoteSolrException e = + SolrClient.RemoteSolrException e = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> solrClient.request(getProxyRequest("bar", "anyHostAnyUser"))); assertTrue(e.getMessage().contains(getExpectedGroupExMsg("bar", "anyHostAnyUser"))); } @@ -289,9 +288,9 @@ public void testProxyValidateGroup() throws Exception { @Test public void testProxyUnknownRemote() { - BaseHttpSolrClient.RemoteSolrException e = + SolrClient.RemoteSolrException e = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> { // Use a reserved ip address String nonProxyUserConfiguredIpAddress = "255.255.255.255"; @@ -307,9 +306,9 @@ public void testProxyUnknownRemote() { @Test public void testProxyInvalidRemote() { - BaseHttpSolrClient.RemoteSolrException e = + SolrClient.RemoteSolrException e = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> { solrClient.request( getProxyRequest("localHostAnyGroup", "bar", "[ff01::114]", "[::1]")); @@ -319,9 +318,9 @@ public void testProxyInvalidRemote() { @Test public void testProxyInvalidGroup() { - BaseHttpSolrClient.RemoteSolrException e = + SolrClient.RemoteSolrException e = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> solrClient.request(getProxyRequest("bogusGroup", "bar", null))); assertTrue(e.getMessage().contains(getExpectedGroupExMsg("bogusGroup", "bar"))); } @@ -329,8 +328,7 @@ public void testProxyInvalidGroup() { @Test public void testProxyNullProxyUser() { expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, - () -> solrClient.request(getProxyRequest("", "bar"))); + SolrClient.RemoteSolrException.class, () -> solrClient.request(getProxyRequest("", "bar"))); } @Test diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java index 7bdd6b27ca6..240f9750ed3 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java @@ -35,6 +35,7 @@ import org.apache.solr.client.solrj.response.UpdateResponse; import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrDocumentList; +import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.ModifiableSolrParams; @@ -1225,4 +1226,20 @@ public SolrRequest.SolrClientContext getContext() { public String getDefaultCollection() { return defaultCollection; } + + /** + * Subclass of SolrException that allows us to capture an arbitrary HTTP status code that may have + * been returned by the remote server or a proxy along the way. + */ + public static class RemoteSolrException extends SolrException { + /** + * @param remoteHost the host the error was received from + * @param code Arbitrary HTTP status code + * @param msg Exception Message + * @param th Throwable to wrap with this Exception + */ + public RemoteSolrException(String remoteHost, int code, String msg, Throwable th) { + super(code, "Error from server at " + remoteHost + ": " + msg, th); + } + } } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java index 75c50167d2b..7691f25e702 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java @@ -17,7 +17,7 @@ package org.apache.solr.client.solrj.impl; -import static org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteSolrException; +import static org.apache.solr.client.solrj.SolrClient.RemoteSolrException; import java.io.IOException; import java.lang.invoke.MethodHandles; @@ -347,7 +347,7 @@ public ClusterState getClusterState() { String baseUrl = Utils.getBaseUrlForNodeName(nodeName, urlScheme); try (SolrClient client = getSolrClient(baseUrl)) { return fetchClusterState(client, null, null); - } catch (SolrServerException | BaseHttpSolrClient.RemoteSolrException | IOException e) { + } catch (SolrServerException | SolrClient.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) @@ -376,7 +376,7 @@ public Map getClusterProperties() { SimpleOrderedMap cluster = submitClusterStateRequest(client, null, ClusterStateRequestType.FETCH_CLUSTER_PROP); return (Map) cluster.get("properties"); - } catch (SolrServerException | BaseHttpSolrClient.RemoteSolrException | IOException e) { + } catch (SolrServerException | SolrClient.RemoteSolrException | IOException e) { log.warn("Attempt to fetch cluster state from {} failed.", baseUrl, e); } } 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 c1da336d7d5..5a9df769a99 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 @@ -21,27 +21,10 @@ import java.util.Collections; import org.apache.solr.client.solrj.SolrClient; -import org.apache.solr.common.SolrException; import org.apache.solr.common.util.NamedList; public abstract class BaseHttpSolrClient extends SolrClient { - /** - * Subclass of SolrException that allows us to capture an arbitrary HTTP status code that may have - * been returned by the remote server or a proxy along the way. - */ - public static class RemoteSolrException extends SolrException { - /** - * @param remoteHost the host the error was received from - * @param code Arbitrary HTTP status code - * @param msg Exception Message - * @param th Throwable to wrap with this Exception - */ - public RemoteSolrException(String remoteHost, int code, String msg, Throwable th) { - super(code, "Error from server at " + remoteHost + ": " + msg, th); - } - } - /** * This should be thrown when a server has an error in executing the request, and it sends a * proper payload back to the client diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java index f485a75ef5f..28e595e21ec 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java @@ -279,8 +279,7 @@ void sendUpdateStream() throws Exception { log.warn("Failed to parse error response from {} due to: ", basePath, exc); } finally { solrExc = - new BaseHttpSolrClient.RemoteSolrException( - basePath, statusCode, msg.toString(), null); + new SolrClient.RemoteSolrException(basePath, statusCode, msg.toString(), null); if (metadata != null) { solrExc.setMetadata(metadata); } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java index 3896f1e8e87..f48ba05a0c8 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java @@ -387,7 +387,7 @@ public void writeTo(OutputStream out) throws IOException { log.warn("Failed to parse error response from {} due to: ", client.getBaseURL(), exc); } finally { solrExc = - new BaseHttpSolrClient.RemoteSolrException( + new SolrClient.RemoteSolrException( client.getBaseURL(), statusCode, msg.toString(), null); if (metadata != null) { solrExc.setMetadata(metadata); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java index f3de7a75727..9795cf4ebdc 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java @@ -40,10 +40,10 @@ import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; import org.apache.solr.client.solrj.ResponseParser; +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.SSLConfig; -import org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteSolrException; import org.apache.solr.client.solrj.impl.HttpListenerFactory.RequestResponseListener; import org.apache.solr.client.solrj.request.RequestWriter; import org.apache.solr.client.solrj.request.UpdateRequest; @@ -453,7 +453,7 @@ public void onHeaders(Response response) { mdcCopyHelper.onBegin(null); log.debug("response processing success"); future.complete(body); - } catch (RemoteSolrException | SolrServerException e) { + } catch (SolrClient.RemoteSolrException | SolrServerException e) { mdcCopyHelper.onBegin(null); log.debug("response processing failed", e); future.completeExceptionally(e); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java index 86f8b932f37..3977316abc1 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java @@ -72,6 +72,7 @@ import org.apache.http.message.BasicHeader; import org.apache.http.message.BasicNameValuePair; import org.apache.solr.client.solrj.ResponseParser; +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.request.RequestWriter; @@ -605,7 +606,7 @@ protected NamedList executeMethod( break; default: if (processor == null || contentType == null) { - throw new RemoteSolrException( + throw new SolrClient.RemoteSolrException( baseUrl, httpStatus, "non ok status: " @@ -635,7 +636,7 @@ protected NamedList executeMethod( .collect(Collectors.toSet()); if (!processorMimeTypes.contains(mimeType)) { if (isUnmatchedErrorCode(mimeType, httpStatus)) { - throw new RemoteSolrException( + throw new SolrClient.RemoteSolrException( baseUrl, httpStatus, "non ok status: " @@ -653,10 +654,10 @@ protected NamedList executeMethod( try { ByteArrayOutputStream body = new ByteArrayOutputStream(); respBody.transferTo(body); - throw new RemoteSolrException( + throw new SolrClient.RemoteSolrException( baseUrl, httpStatus, prefix + body.toString(exceptionCharset), null); } catch (IOException e) { - throw new RemoteSolrException( + throw new SolrClient.RemoteSolrException( baseUrl, httpStatus, "Could not parse response with encoding " + exceptionCharset, @@ -669,7 +670,7 @@ protected NamedList executeMethod( try { rsp = processor.processResponse(respBody, charsetName); } catch (Exception e) { - throw new RemoteSolrException(baseUrl, httpStatus, e.getMessage(), e); + throw new SolrClient.RemoteSolrException(baseUrl, httpStatus, e.getMessage(), e); } Object error = rsp == null ? null : rsp.get("error"); if (error != null @@ -713,7 +714,8 @@ protected NamedList executeMethod( .append(method.getURI()); reason = java.net.URLDecoder.decode(msg.toString(), FALLBACK_CHARSET); } - RemoteSolrException rss = new RemoteSolrException(baseUrl, httpStatus, reason, null); + SolrClient.RemoteSolrException rss = + new SolrClient.RemoteSolrException(baseUrl, httpStatus, reason, null); if (metadata != null) rss.setMetadata(metadata); throw rss; } 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 3debb681378..244fcb4c7b9 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 @@ -204,7 +204,7 @@ protected NamedList processErrorsAndResponse( break; default: if (processor == null || mimeType == null) { - throw new BaseHttpSolrClient.RemoteSolrException( + throw new SolrClient.RemoteSolrException( urlExceptionMessage, httpStatus, "non ok status: " + httpStatus + ", message:" + responseReason, @@ -228,7 +228,7 @@ protected NamedList processErrorsAndResponse( try { rsp = processor.processResponse(is, encoding); } catch (Exception e) { - throw new BaseHttpSolrClient.RemoteSolrException( + throw new SolrClient.RemoteSolrException( urlExceptionMessage, httpStatus, e.getMessage(), e); } @@ -277,9 +277,8 @@ protected NamedList processErrorsAndResponse( } reason = java.net.URLDecoder.decode(msg.toString(), FALLBACK_CHARSET); } - BaseHttpSolrClient.RemoteSolrException rss = - new BaseHttpSolrClient.RemoteSolrException( - urlExceptionMessage, httpStatus, reason, null); + SolrClient.RemoteSolrException rss = + new SolrClient.RemoteSolrException(urlExceptionMessage, httpStatus, reason, null); if (metadata != null) rss.setMetadata(metadata); throw rss; } @@ -335,10 +334,10 @@ private void checkContentType( try { ByteArrayOutputStream body = new ByteArrayOutputStream(); is.transferTo(body); - throw new BaseHttpSolrClient.RemoteSolrException( + throw new SolrClient.RemoteSolrException( urlExceptionMessage, httpStatus, prefix + body.toString(exceptionEncoding), null); } catch (IOException e) { - throw new BaseHttpSolrClient.RemoteSolrException( + throw new SolrClient.RemoteSolrException( urlExceptionMessage, httpStatus, "Could not parse response with encoding " + exceptionEncoding, diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java index 66154e7c6ec..2fdadedd953 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java @@ -42,7 +42,6 @@ import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; import org.apache.solr.client.solrj.embedded.SolrExampleStreamingHttp2Test; import org.apache.solr.client.solrj.embedded.SolrExampleStreamingTest.ErrorTrackingConcurrentUpdateSolrClient; -import org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteSolrException; import org.apache.solr.client.solrj.impl.BinaryResponseParser; import org.apache.solr.client.solrj.impl.HttpSolrClient; import org.apache.solr.client.solrj.impl.NoOpResponseParser; @@ -751,7 +750,7 @@ public void testErrorHandling() throws Exception { assertNotNull("Should throw exception!", concurrentClient.lastError); assertEquals( "Unexpected exception type", - RemoteSolrException.class, + SolrClient.RemoteSolrException.class, concurrentClient.lastError.getClass()); assertTrue( "Unexpected exception message: " + concurrentClient.lastError.getMessage(), diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/TestSolrJErrorHandling.java b/solr/solrj/src/test/org/apache/solr/client/solrj/TestSolrJErrorHandling.java index 68ba3e42606..fb146d47a75 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/TestSolrJErrorHandling.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/TestSolrJErrorHandling.java @@ -37,7 +37,6 @@ import java.util.concurrent.atomic.AtomicInteger; 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; @@ -216,7 +215,7 @@ void doIt(SolrClient client) throws Exception { void doSingle(SolrClient client, int threadNum) { try { client.add(manyDocs(threadNum * 1000000, 1000)); - } catch (BaseHttpSolrClient.RemoteSolrException e) { + } catch (SolrClient.RemoteSolrException e) { String msg = e.getMessage(); assertTrue(msg, msg.contains("field_does_not_exist")); } catch (Throwable e) { diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java index bf0e3ad00bf..30299f0b572 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java @@ -254,8 +254,7 @@ public void testQuery() throws Exception { queryRequest.setPath(debugPath); try (HttpSolrClient client = getHttpSolrClient(getBaseUrl())) { - expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, () -> queryRequest.process(client)); + expectThrows(SolrClient.RemoteSolrException.class, () -> queryRequest.process(client)); // default method assertEquals("get", DebugServlet.lastMethod); @@ -285,8 +284,7 @@ public void testQuery() throws Exception { // POST DebugServlet.clear(); queryRequest.setMethod(METHOD.POST); - expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, () -> queryRequest.process(client)); + expectThrows(SolrClient.RemoteSolrException.class, () -> queryRequest.process(client)); assertEquals("post", DebugServlet.lastMethod); assertEquals( @@ -310,8 +308,7 @@ public void testQuery() throws Exception { // PUT DebugServlet.clear(); queryRequest.setMethod(METHOD.PUT); - expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, () -> queryRequest.process(client)); + expectThrows(SolrClient.RemoteSolrException.class, () -> queryRequest.process(client)); assertEquals("put", DebugServlet.lastMethod); assertEquals( @@ -341,8 +338,7 @@ public void testQuery() throws Exception { // XML/GET DebugServlet.clear(); queryRequest.setMethod(METHOD.GET); // Reset to the default here after using 'PUT' above - expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, () -> queryRequest.process(client)); + expectThrows(SolrClient.RemoteSolrException.class, () -> queryRequest.process(client)); assertEquals("get", DebugServlet.lastMethod); assertEquals( @@ -363,8 +359,7 @@ public void testQuery() throws Exception { // XML/POST DebugServlet.clear(); queryRequest.setMethod(METHOD.POST); - expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, () -> queryRequest.process(client)); + expectThrows(SolrClient.RemoteSolrException.class, () -> queryRequest.process(client)); assertEquals("post", DebugServlet.lastMethod); assertEquals( @@ -387,8 +382,7 @@ public void testQuery() throws Exception { DebugServlet.clear(); queryRequest.setMethod(METHOD.PUT); - expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, () -> queryRequest.process(client)); + expectThrows(SolrClient.RemoteSolrException.class, () -> queryRequest.process(client)); assertEquals("put", DebugServlet.lastMethod); assertEquals( @@ -420,7 +414,7 @@ public void testDelete() throws Exception { final UpdateRequest deleteById = new UpdateRequest(); deleteById.deleteById("id"); deleteById.setPath(debugPath + deleteById.getPath()); - expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> deleteById.process(client)); + expectThrows(SolrClient.RemoteSolrException.class, () -> deleteById.process(client)); // default method assertEquals("post", DebugServlet.lastMethod); @@ -453,7 +447,7 @@ public void testDelete() throws Exception { deleteByQueryRequest.deleteByQuery("*:*"); deleteByQueryRequest.setCommitWithin(-1); expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, () -> deleteByQueryRequest.process(client)); + SolrClient.RemoteSolrException.class, () -> deleteByQueryRequest.process(client)); assertEquals("post", DebugServlet.lastMethod); assertEquals( @@ -476,11 +470,10 @@ public void testGetById() throws Exception { DebugServlet.clear(); try (SolrClient client = getHttpSolrClient(getBaseUrl() + "/debug/foo")) { Collection ids = Collections.singletonList("a"); - expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> client.getById("a")); - expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> client.getById(ids, null)); - expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> client.getById("foo", "a")); - expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, () -> client.getById("foo", ids, null)); + expectThrows(SolrClient.RemoteSolrException.class, () -> client.getById("a")); + expectThrows(SolrClient.RemoteSolrException.class, () -> client.getById(ids, null)); + expectThrows(SolrClient.RemoteSolrException.class, () -> client.getById("foo", "a")); + expectThrows(SolrClient.RemoteSolrException.class, () -> client.getById("foo", ids, null)); } } @@ -494,7 +487,7 @@ public void testUpdate() throws Exception { req.add(new SolrInputDocument()); req.setPath(debugPath + req.getPath()); req.setParam("a", "\u1234"); - expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> req.process(client)); + expectThrows(SolrClient.RemoteSolrException.class, () -> req.process(client)); // default method assertEquals("post", DebugServlet.lastMethod); @@ -527,7 +520,7 @@ public void testUpdate() throws Exception { req.setPath(debugPath + req.getPath()); req.setParam("a", "\u1234"); - expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> client.request(req)); + expectThrows(SolrClient.RemoteSolrException.class, () -> client.request(req)); assertEquals("post", DebugServlet.lastMethod); assertEquals( @@ -554,7 +547,7 @@ public void testUpdate() throws Exception { req.setPath(debugPath + req.getPath()); req.setParam("a", "\u1234"); - expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> client.request(req)); + expectThrows(SolrClient.RemoteSolrException.class, () -> client.request(req)); assertEquals("post", DebugServlet.lastMethod); assertEquals( @@ -610,8 +603,7 @@ public void testCompression() throws Exception { try (SolrClient client = getHttpSolrClient(getBaseUrl())) { // verify request header gets set DebugServlet.clear(); - expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, () -> queryRequest.process(client)); + expectThrows(SolrClient.RemoteSolrException.class, () -> queryRequest.process(client)); assertNull(DebugServlet.headers.toString(), DebugServlet.headers.get("Accept-Encoding")); } @@ -619,7 +611,7 @@ public void testCompression() throws Exception { new HttpSolrClient.Builder(getBaseUrl()).allowCompression(true).build()) { try { queryRequest.process(client); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } assertNotNull(DebugServlet.headers.get("Accept-Encoding")); } @@ -628,7 +620,7 @@ public void testCompression() throws Exception { new HttpSolrClient.Builder(getBaseUrl()).allowCompression(false).build()) { try { queryRequest.process(client); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } } assertNull(DebugServlet.headers.get("Accept-Encoding")); @@ -838,7 +830,7 @@ public void testQueryString() throws Exception { UpdateRequest req = new UpdateRequest(); req.setPath(debugPath + req.getPath()); setReqParamsOf(req, "serverOnly", "notServer"); - expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> client.request(req)); + expectThrows(SolrClient.RemoteSolrException.class, () -> client.request(req)); verifyServletState(client, req); } try (HttpSolrClient client = builder.withTheseParamNamesInTheUrl(Set.of()).build()) { @@ -848,7 +840,7 @@ public void testQueryString() throws Exception { req2.setPath(debugPath + req2.getPath()); req2.setQueryParams(Set.of("requestOnly")); setReqParamsOf(req2, "requestOnly", "notRequest"); - expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> client.request(req2)); + expectThrows(SolrClient.RemoteSolrException.class, () -> client.request(req2)); verifyServletState(client, req2); } try (HttpSolrClient client = @@ -859,7 +851,7 @@ public void testQueryString() throws Exception { req3.setPath(debugPath + req3.getPath()); req3.setQueryParams(Set.of("requestOnly", "both")); setReqParamsOf(req3, "serverOnly", "requestOnly", "both", "neither"); - expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> client.request(req3)); + expectThrows(SolrClient.RemoteSolrException.class, () -> client.request(req3)); verifyServletState(client, req3); } try (HttpSolrClient client = @@ -871,7 +863,7 @@ public void testQueryString() throws Exception { req4.add(new SolrInputDocument()); req4.setQueryParams(Set.of("requestOnly", "both")); setReqParamsOf(req4, "serverOnly", "requestOnly", "both", "neither"); - expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> client.request(req4)); + expectThrows(SolrClient.RemoteSolrException.class, () -> client.request(req4)); // NOTE: single stream requests send all the params // as part of the query string. So add "neither" to the request, // so it passes the verification step. diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java index adc259460c1..47c3a6c5086 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java @@ -821,7 +821,7 @@ public void stateVersionParamTest() throws Exception { Replica r = coll.getSlices().iterator().next().getReplicas().iterator().next(); SolrQuery q = new SolrQuery().setQuery("*:*"); - BaseHttpSolrClient.RemoteSolrException sse = null; + SolrClient.RemoteSolrException sse = null; try (SolrClient solrClient = getHttpSolrClient(r.getBaseUrl(), COLLECTION)) { @@ -875,7 +875,7 @@ public void stateVersionParamTest() throws Exception { try { QueryResponse rsp = solrClient.query(q); log.info("error was expected"); - } catch (BaseHttpSolrClient.RemoteSolrException e) { + } catch (SolrClient.RemoteSolrException e) { sse = e; } assertNotNull(sse); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java index ad718210e91..e6160bc8421 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java @@ -760,7 +760,7 @@ public void stateVersionParamTest() throws Exception { Replica r = coll.getSlices().iterator().next().getReplicas().iterator().next(); SolrQuery q = new SolrQuery().setQuery("*:*"); - BaseHttpSolrClient.RemoteSolrException sse = null; + SolrClient.RemoteSolrException sse = null; try (SolrClient solrClient = getHttpSolrClient(r.getBaseUrl(), COLLECTION)) { @@ -814,7 +814,7 @@ public void stateVersionParamTest() throws Exception { try { QueryResponse rsp = solrClient.query(q); log.info("error was expected"); - } catch (BaseHttpSolrClient.RemoteSolrException e) { + } catch (SolrClient.RemoteSolrException e) { sse = e; } assertNotNull(sse); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientCompatibilityTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientCompatibilityTest.java index 65c240a8e5f..d1074b99531 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientCompatibilityTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientCompatibilityTest.java @@ -19,6 +19,7 @@ import org.apache.solr.SolrJettyTestBase; import org.apache.solr.SolrTestCaseJ4; +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; @@ -57,7 +58,7 @@ public void testConnectToOldNodesUsingHttp1() throws Exception { assertTrue(client.getHttpClient().getTransport() instanceof HttpClientTransportOverHTTP); try { client.query(new SolrQuery("*:*"), SolrRequest.METHOD.GET); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } } finally { solrClientTestRule.reset(); @@ -78,7 +79,7 @@ public void testConnectToNewNodesUsingHttp1() throws Exception { assertTrue(client.getHttpClient().getTransport() instanceof HttpClientTransportOverHTTP); try { client.query(new SolrQuery("*:*"), SolrRequest.METHOD.GET); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } } finally { solrClientTestRule.reset(); @@ -104,7 +105,7 @@ public void testConnectToOldNodesUsingHttp2() throws Exception { try { client.query(new SolrQuery("*:*"), SolrRequest.METHOD.GET); fail("Jetty client with HTTP2 transport should not be able to connect to HTTP1 only nodes"); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { fail("Jetty client with HTTP2 transport should not be able to connect to HTTP1 only nodes"); } catch (SolrServerException e) { // expected diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientTest.java index 384908a0547..64de4199f01 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientTest.java @@ -79,7 +79,7 @@ public void test0IdleTimeout() throws Exception { .build()) { try { client.query(q, SolrRequest.METHOD.GET); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } } } @@ -140,7 +140,7 @@ protected void testQuerySetup(SolrRequest.METHOD method, ResponseParser rp) thro client.query(q, method); assertEquals( client.getParser().getVersion(), DebugServlet.parameters.get(CommonParams.VERSION)[0]); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } } @@ -188,7 +188,7 @@ public void testDelete() throws Exception { new Http2SolrClient.Builder(url).withDefaultCollection(DEFAULT_CORE).build()) { try { client.deleteById("id"); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } assertEquals( client.getParser().getVersion(), DebugServlet.parameters.get(CommonParams.VERSION)[0]); @@ -208,7 +208,7 @@ public void testDeleteXml() throws Exception { .build()) { try { client.deleteByQuery("*:*"); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } assertEquals( client.getParser().getVersion(), DebugServlet.parameters.get(CommonParams.VERSION)[0]); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpJdkSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpJdkSolrClientTest.java index 9821a8ec849..bd5c411fdbf 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpJdkSolrClientTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpJdkSolrClientTest.java @@ -39,6 +39,7 @@ import org.apache.lucene.util.NamedThreadFactory; import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.client.solrj.ResponseParser; +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; @@ -133,7 +134,7 @@ public void testDelete() throws Exception { try (HttpJdkSolrClient client = builder(url).build()) { try { client.deleteById("id"); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } assertEquals( client.getParser().getVersion(), DebugServlet.parameters.get(CommonParams.VERSION)[0]); @@ -150,7 +151,7 @@ public void testDeleteXml() throws Exception { builder(url).withResponseParser(new XMLResponseParser()).build()) { try { client.deleteByQuery("*:*"); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } assertEquals( client.getParser().getVersion(), DebugServlet.parameters.get(CommonParams.VERSION)[0]); @@ -227,7 +228,7 @@ public void test0IdleTimeout() throws Exception { builder(getBaseUrl() + DEBUG_SERVLET_PATH, DEFAULT_CONNECTION_TIMEOUT, 0).build()) { try { client.query(q, SolrRequest.METHOD.GET); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } } } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java index d9f3a5544b4..9f5c915f5bf 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientTestBase.java @@ -37,6 +37,7 @@ import java.util.concurrent.TimeUnit; import org.apache.solr.SolrJettyTestBase; import org.apache.solr.client.solrj.ResponseParser; +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; @@ -208,22 +209,22 @@ public void testGetById(HttpSolrClientBase client) throws Exception { Collection ids = Collections.singletonList("a"); try { client.getById("a"); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } try { client.getById(ids, null); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } try { client.getById("foo", "a"); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } try { client.getById("foo", ids, null); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } } @@ -294,7 +295,7 @@ protected void testUpdate(HttpSolrClientBase client, WT wt, String contentType, try { client.request(req); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } assertEquals("post", DebugServlet.lastMethod); @@ -390,7 +391,7 @@ protected void testQueryString() throws Exception { try { client.request(req); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } verifyServletState(client, req); @@ -406,7 +407,7 @@ protected void testQueryString() throws Exception { setReqParamsOf(req, "requestOnly", "notRequest"); try { client.request(req); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } verifyServletState(client, req); @@ -422,7 +423,7 @@ protected void testQueryString() throws Exception { setReqParamsOf(req, "serverOnly", "requestOnly", "both", "neither"); try { client.request(req); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } verifyServletState(client, req); } @@ -439,7 +440,7 @@ protected void testQueryString() throws Exception { setReqParamsOf(req, "serverOnly", "requestOnly", "both", "neither"); try { client.request(req); - } catch (BaseHttpSolrClient.RemoteSolrException ignored) { + } catch (SolrClient.RemoteSolrException ignored) { } // NOTE: single stream requests send all the params // as part of the query string. So add "neither" to the request, @@ -655,7 +656,7 @@ protected void testAsyncExceptionBase() throws Exception { ee = ee1; } assertTrue(future.isCompletedExceptionally()); - assertTrue(ee.getCause() instanceof BaseHttpSolrClient.RemoteSolrException); + assertTrue(ee.getCause() instanceof SolrClient.RemoteSolrException); assertTrue(ee.getMessage(), ee.getMessage().contains("mime type")); } } diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.java index a414eb5fdbe..d0e250e59c7 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractCollectionsAPIDistributedZkTestBase.java @@ -43,7 +43,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.request.CollectionAdminRequest; import org.apache.solr.client.solrj.request.CoreAdminRequest; import org.apache.solr.client.solrj.request.CoreStatus; @@ -290,7 +289,7 @@ public void testCreateShouldFailOnExistingCore() throws Exception { .isSuccess()); expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> { CollectionAdminRequest.createCollection("halfcollection", "conf", 1, 1) .setCreateNodeSet(nn1 + "," + nn2) diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractInstallShardTest.java b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractInstallShardTest.java index 1cd954966ab..b12f579bf3f 100644 --- a/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractInstallShardTest.java +++ b/solr/test-framework/src/java/org/apache/solr/cloud/api/collections/AbstractInstallShardTest.java @@ -36,7 +36,6 @@ import org.apache.lucene.store.Directory; 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.request.CollectionAdminRequest; import org.apache.solr.client.solrj.response.RequestStatusState; @@ -149,9 +148,9 @@ public void testInstallFailsIfCollectionIsNotInReadOnlyMode() throws Exception { deleteAfterTest(collectionName); final String singleShardLocation = singleShard1Uri.toString(); - final BaseHttpSolrClient.RemoteSolrException rse = + final SolrClient.RemoteSolrException rse = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> { CollectionAdminRequest.installDataToShard( collectionName, "shard1", singleShardLocation, BACKUP_REPO_NAME) @@ -188,7 +187,7 @@ public void testInstallReportsErrorsAppropriately() throws Exception { { // Test synchronous request error reporting final var expectedException = expectThrows( - BaseHttpSolrClient.RemoteSolrException.class, + SolrClient.RemoteSolrException.class, () -> { CollectionAdminRequest.installDataToShard( collectionName, "shard1", nonExistentLocation, BACKUP_REPO_NAME)