This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch branch_10x
in repository https://gitbox.apache.org/repos/asf/solr.git

commit 1b437a844187c593362ea3c3d841e049179052c2
Author: Xinyao Zhang <[email protected]>
AuthorDate: Thu Sep 3 20:16:18 2026 -0400

    SOLR-18343: SolrJ now uses POST for suitable v1 admin requests (#4861)
    
    SolrJ v1 admin requests now use appropriate HTTP verbs -- mostly POST, some 
GET.
    Observability note: hurts since useful request params are no longer in the 
URL.  Addressing separately.
    
    Backport note: deprecation should be: since = "10.1"
    
    (cherry picked from commit 22620db37328e1f8794574daad661542ed0ab98d)
---
 .../solr-18343-explicit-admin-methods.yml          |   8 +
 .../solr/opentelemetry/TestDistributedTracing.java |   8 +-
 .../solrj/request/CollectionAdminRequest.java      | 200 ++++++++++++++-------
 .../solrj/request/ConfigSetAdminRequest.java       |  37 +++-
 .../client/solrj/request/CoreAdminRequest.java     |  42 +++--
 .../solrj/request/TestCollectionAdminRequest.java  |  20 +++
 .../solrj/request/TestConfigSetAdminRequest.java   |   9 +
 .../solr/client/solrj/request/TestCoreAdmin.java   |   8 +
 8 files changed, 253 insertions(+), 79 deletions(-)

diff --git a/changelog/unreleased/solr-18343-explicit-admin-methods.yml 
b/changelog/unreleased/solr-18343-explicit-admin-methods.yml
new file mode 100644
index 00000000000..3f88523466e
--- /dev/null
+++ b/changelog/unreleased/solr-18343-explicit-admin-methods.yml
@@ -0,0 +1,8 @@
+title: >
+  SolrJ v1 admin requests now use appropriate HTTP verbs -- mostly POST, some 
GET
+type: changed
+authors:
+  - name: Xinyao Zhang
+links:
+  - name: SOLR-18343
+    url: https://issues.apache.org/jira/browse/SOLR-18343
diff --git 
a/solr/modules/opentelemetry/src/test/org/apache/solr/opentelemetry/TestDistributedTracing.java
 
b/solr/modules/opentelemetry/src/test/org/apache/solr/opentelemetry/TestDistributedTracing.java
index f73d4706003..72f478590d2 100644
--- 
a/solr/modules/opentelemetry/src/test/org/apache/solr/opentelemetry/TestDistributedTracing.java
+++ 
b/solr/modules/opentelemetry/src/test/org/apache/solr/opentelemetry/TestDistributedTracing.java
@@ -195,7 +195,7 @@ public class TestDistributedTracing extends 
SolrCloudTestCase {
     assertEquals(0, r1.getStatus());
 
     // Expecting 8 spans:
-    // 1. api call "name=create:/admin/collections". 
db.instance=testInternalCollectionApiCommands
+    // 1. api call "name=post:/admin/collections". 
db.instance=testInternalCollectionApiCommands
     // - unique traceId unrelated to the internal trace id generated for the 
operation
     // 2. internal CollectionApiCommand "name=CreateCollectionCmd"
     // db.instance=testInternalCollectionApiCommands
@@ -222,7 +222,7 @@ public class TestDistributedTracing extends 
SolrCloudTestCase {
     var finishedSpans = getAndClearSpans(1);
     var s0 = finishedSpans.remove(0);
     assertCollectionName(s0, collection);
-    assertEquals("create:/admin/collections", s0.getName());
+    assertEquals("post:/admin/collections", s0.getName());
 
     Map<String, Integer> ops = new HashMap<>();
     assertEquals(11, finishedSpans.size());
@@ -248,7 +248,7 @@ public class TestDistributedTracing extends 
SolrCloudTestCase {
     assertEquals(0, r1.getStatus());
 
     // Expecting 6 spans:
-    // 1. api call "name=delete:/admin/collections". 
db.instance=testInternalCollectionApiCommands
+    // 1. api call "name=post:/admin/collections". 
db.instance=testInternalCollectionApiCommands
     // - unique traceId unrelated to the internal trace id generated for the 
operation
     // 2. internal CollectionApiCommand "name=DeleteCollectionCmd"
     // db.instance=testInternalCollectionApiCommands
@@ -263,7 +263,7 @@ public class TestDistributedTracing extends 
SolrCloudTestCase {
     var finishedSpans = getAndClearSpans(1);
     var s0 = finishedSpans.remove(0);
     assertCollectionName(s0, collection);
-    assertEquals("delete:/admin/collections", s0.getName());
+    assertEquals("post:/admin/collections", s0.getName());
 
     Map<String, Integer> ops = new HashMap<>();
     assertEquals(5, finishedSpans.size());
diff --git 
a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
 
b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
index 71c5230ff92..3e818d95991 100644
--- 
a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
+++ 
b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
@@ -79,13 +79,29 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
 
   @Deprecated public static String PROPERTY_PREFIX = 
CollectionAdminParams.PROPERTY_PREFIX;
 
+  public CollectionAdminRequest(METHOD method, CollectionAction action) {
+    this(method, "/admin/collections", action);
+  }
+
+  public CollectionAdminRequest(METHOD method, String path, CollectionAction 
action) {
+    super(method, path, SolrRequestType.ADMIN);
+    this.action = checkNotNull(CoreAdminParams.ACTION, action);
+  }
+
+  /**
+   * @deprecated Use {@link #CollectionAdminRequest(METHOD, CollectionAction)}.
+   */
+  @Deprecated(since = "10.1")
   public CollectionAdminRequest(CollectionAction action) {
-    this("/admin/collections", action);
+    this(METHOD.POST, action);
   }
 
+  /**
+   * @deprecated Use {@link #CollectionAdminRequest(METHOD, String, 
CollectionAction)}.
+   */
+  @Deprecated(since = "10.1")
   public CollectionAdminRequest(String path, CollectionAction action) {
-    super(METHOD.GET, path, SolrRequestType.ADMIN);
-    this.action = checkNotNull(CoreAdminParams.ACTION, action);
+    this(METHOD.POST, path, action);
   }
 
   @Override
@@ -149,8 +165,16 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected String asyncId = null;
     protected boolean waitForFinalState = false;
 
+    public AsyncCollectionAdminRequest(METHOD method, CollectionAction action) 
{
+      super(method, action);
+    }
+
+    /**
+     * @deprecated Use {@link #AsyncCollectionAdminRequest(METHOD, 
CollectionAction)}.
+     */
+    @Deprecated(since = "10.1")
     public AsyncCollectionAdminRequest(CollectionAction action) {
-      super(action);
+      this(METHOD.POST, action);
     }
 
     @Override
@@ -256,11 +280,21 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected String collection;
     protected Boolean followAliases;
 
-    public AsyncCollectionSpecificAdminRequest(CollectionAction action, String 
collection) {
-      super(action);
+    public AsyncCollectionSpecificAdminRequest(
+        METHOD method, CollectionAction action, String collection) {
+      super(method, action);
       this.collection = checkNotNull(CoreAdminParams.COLLECTION, collection);
     }
 
+    /**
+     * @deprecated Use {@link #AsyncCollectionSpecificAdminRequest(METHOD, 
CollectionAction,
+     *     String)}.
+     */
+    @Deprecated(since = "10.1")
+    public AsyncCollectionSpecificAdminRequest(CollectionAction action, String 
collection) {
+      this(METHOD.POST, action, collection);
+    }
+
     public String getCollectionName() {
       return collection;
     }
@@ -285,12 +319,22 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected String shard;
 
     public AsyncShardSpecificAdminRequest(
-        CollectionAction action, String collection, String shard) {
-      super(action);
+        METHOD method, CollectionAction action, String collection, String 
shard) {
+      super(method, action);
       this.collection = checkNotNull(CoreAdminParams.COLLECTION, collection);
       this.shard = checkNotNull(CoreAdminParams.SHARD, shard);
     }
 
+    /**
+     * @deprecated Use {@link #AsyncShardSpecificAdminRequest(METHOD, 
CollectionAction, String,
+     *     String)}.
+     */
+    @Deprecated(since = "10.1")
+    public AsyncShardSpecificAdminRequest(
+        CollectionAction action, String collection, String shard) {
+      this(METHOD.POST, action, collection, shard);
+    }
+
     @Override
     public SolrParams getParams() {
       ModifiableSolrParams params = new 
ModifiableSolrParams(super.getParams());
@@ -306,12 +350,21 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected String collection;
     protected String shard;
 
-    public ShardSpecificAdminRequest(CollectionAction action, String 
collection, String shard) {
-      super(action);
+    public ShardSpecificAdminRequest(
+        METHOD method, CollectionAction action, String collection, String 
shard) {
+      super(method, action);
       this.collection = checkNotNull(CoreAdminParams.COLLECTION, collection);
       this.shard = checkNotNull(CoreAdminParams.SHARD, shard);
     }
 
+    /**
+     * @deprecated Use {@link #ShardSpecificAdminRequest(METHOD, 
CollectionAction, String, String)}.
+     */
+    @Deprecated(since = "10.1")
+    public ShardSpecificAdminRequest(CollectionAction action, String 
collection, String shard) {
+      this(METHOD.POST, action, collection, shard);
+    }
+
     @Override
     public SolrParams getParams() {
       ModifiableSolrParams params = new 
ModifiableSolrParams(super.getParams());
@@ -335,12 +388,22 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected String node;
     protected String role;
 
-    public CollectionAdminRoleRequest(CollectionAction action, String node, 
String role) {
-      super(action);
+    public CollectionAdminRoleRequest(
+        METHOD method, CollectionAction action, String node, String role) {
+      super(method, action);
       this.role = checkNotNull(CollectionAdminParams.ROLE, role);
       this.node = checkNotNull(CoreAdminParams.NODE, node);
     }
 
+    /**
+     * @deprecated Use {@link #CollectionAdminRoleRequest(METHOD, 
CollectionAction, String,
+     *     String)}.
+     */
+    @Deprecated(since = "10.1")
+    public CollectionAdminRoleRequest(CollectionAction action, String node, 
String role) {
+      this(METHOD.POST, action, node, role);
+    }
+
     public String getNode() {
       return this.node;
     }
@@ -519,7 +582,10 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
         Integer numShards,
         String shards,
         ReplicaCount numReplicas) {
-      super(CollectionAction.CREATE, 
SolrIdentifierValidator.validateCollectionName(collection));
+      super(
+          METHOD.POST,
+          CollectionAction.CREATE,
+          SolrIdentifierValidator.validateCollectionName(collection));
       // NOTE: there's very little we can assert about the args because 
nothing but "collection" is
       // required by the server
       if ((null != shards) && (null != numShards)) {
@@ -711,7 +777,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
   public static class Reload extends AsyncCollectionSpecificAdminRequest {
 
     private Reload(String collection) {
-      super(CollectionAction.RELOAD, collection);
+      super(METHOD.POST, CollectionAction.RELOAD, collection);
     }
   }
 
@@ -723,7 +789,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     String target;
 
     public Rename(String collection, String target) {
-      super(CollectionAction.RENAME, collection);
+      super(METHOD.POST, CollectionAction.RENAME, collection);
       this.target = target;
     }
 
@@ -747,7 +813,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
      * @param node The node to be deleted
      */
     public DeleteNode(String node) {
-      super(CollectionAction.DELETENODE);
+      super(METHOD.POST, CollectionAction.DELETENODE);
       this.node = checkNotNull("node", node);
     }
 
@@ -768,7 +834,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
      * @param target node where the new replicas are to be created
      */
     public ReplaceNode(String source, String target) {
-      super(CollectionAction.REPLACENODE);
+      super(METHOD.POST, CollectionAction.REPLACENODE);
       this.sourceNode = checkNotNull(CollectionParams.SOURCE_NODE, source);
       this.targetNode = target;
     }
@@ -802,7 +868,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected int timeout = -1;
 
     public MoveReplica(String collection, String replica, String targetNode) {
-      super(CollectionAction.MOVEREPLICA);
+      super(METHOD.POST, CollectionAction.MOVEREPLICA);
       this.collection = checkNotNull(CoreAdminParams.COLLECTION, collection);
       this.replica = checkNotNull(CoreAdminParams.REPLICA, replica);
       this.targetNode = checkNotNull(CollectionParams.TARGET_NODE, targetNode);
@@ -810,7 +876,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     }
 
     public MoveReplica(String collection, String shard, String sourceNode, 
String targetNode) {
-      super(CollectionAction.MOVEREPLICA);
+      super(METHOD.POST, CollectionAction.MOVEREPLICA);
       this.collection = checkNotNull(CoreAdminParams.COLLECTION, collection);
       this.shard = checkNotNull(CoreAdminParams.SHARD, shard);
       this.sourceNode = checkNotNull(CollectionParams.SOURCE_NODE, sourceNode);
@@ -877,7 +943,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     }
 
     public RebalanceLeaders(String collection) {
-      super(CollectionAction.REBALANCELEADERS);
+      super(METHOD.POST, CollectionAction.REBALANCELEADERS);
       this.collection = checkNotNull(CoreAdminParams.COLLECTION, collection);
     }
 
@@ -918,7 +984,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     Map<String, Object> collectionParams = new HashMap<>();
 
     private ReindexCollection(String collection) {
-      super(CollectionAction.REINDEXCOLLECTION, collection);
+      super(METHOD.POST, CollectionAction.REINDEXCOLLECTION, collection);
     }
 
     /** Target collection name (null if the same). */
@@ -1011,12 +1077,12 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected Float rawSizeSamplingPercent = null;
 
     private ColStatus(String collection) {
-      super(CollectionAction.COLSTATUS);
+      super(METHOD.GET, CollectionAction.COLSTATUS);
       this.collection = collection;
     }
 
     private ColStatus() {
-      super(CollectionAction.COLSTATUS);
+      super(METHOD.GET, CollectionAction.COLSTATUS);
     }
 
     public ColStatus setWithSegments(boolean withSegments) {
@@ -1084,7 +1150,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
   public static class Delete extends AsyncCollectionSpecificAdminRequest {
 
     private Delete(String collection) {
-      super(CollectionAction.DELETE, collection);
+      super(METHOD.POST, CollectionAction.DELETE, collection);
     }
   }
 
@@ -1105,7 +1171,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected Properties extraProperties;
 
     public Backup(String collection, String name) {
-      super(CollectionAction.BACKUP, collection);
+      super(METHOD.POST, CollectionAction.BACKUP, collection);
       this.name = name;
       this.repositoryName = Optional.empty();
     }
@@ -1251,7 +1317,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected Integer backupId;
 
     public Restore(String collection, String backupName) {
-      super(CollectionAction.RESTORE, collection);
+      super(METHOD.POST, CollectionAction.RESTORE, collection);
       this.backupName = backupName;
       this.numReplicas = ReplicaCount.empty();
     }
@@ -1437,7 +1503,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected String location;
 
     public InstallShard(String collection, String shard, String location, 
String backupRepository) {
-      super(CollectionAction.INSTALLSHARDDATA, collection, shard);
+      super(METHOD.POST, CollectionAction.INSTALLSHARDDATA, collection, shard);
 
       this.repositoryName = backupRepository;
       this.location = location;
@@ -1469,7 +1535,10 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected final String commitName;
 
     public CreateSnapshot(String collection, String commitName) {
-      super(CollectionAction.CREATESNAPSHOT, 
checkNotNull(CoreAdminParams.COLLECTION, collection));
+      super(
+          METHOD.POST,
+          CollectionAction.CREATESNAPSHOT,
+          checkNotNull(CoreAdminParams.COLLECTION, collection));
       this.commitName = checkNotNull(CoreAdminParams.COMMIT_NAME, commitName);
     }
 
@@ -1496,7 +1565,10 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected final String commitName;
 
     public DeleteSnapshot(String collection, String commitName) {
-      super(CollectionAction.DELETESNAPSHOT, 
checkNotNull(CoreAdminParams.COLLECTION, collection));
+      super(
+          METHOD.POST,
+          CollectionAction.DELETESNAPSHOT,
+          checkNotNull(CoreAdminParams.COLLECTION, collection));
       this.commitName = checkNotNull(CoreAdminParams.COMMIT_NAME, commitName);
     }
 
@@ -1521,7 +1593,10 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
   @SuppressWarnings("serial")
   public static class ListSnapshots extends 
AsyncCollectionSpecificAdminRequest {
     public ListSnapshots(String collection) {
-      super(CollectionAction.LISTSNAPSHOTS, 
checkNotNull(CoreAdminParams.COLLECTION, collection));
+      super(
+          METHOD.GET,
+          CollectionAction.LISTSNAPSHOTS,
+          checkNotNull(CoreAdminParams.COLLECTION, collection));
     }
 
     @Override
@@ -1568,6 +1643,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
 
     private CreateShard(String collection, String shard) {
       super(
+          METHOD.POST,
           CollectionAction.CREATESHARD,
           collection,
           SolrIdentifierValidator.validateShardName(shard));
@@ -1597,7 +1673,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected String sleep;
 
     private MockCollTask(String collection) {
-      super(CollectionAction.MOCK_COLL_TASK);
+      super(METHOD.POST, CollectionAction.MOCK_COLL_TASK);
       this.collection = checkNotNull(CoreAdminParams.COLLECTION, collection);
     }
 
@@ -1635,7 +1711,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected String createNodeSet;
 
     private SplitShard(String collection) {
-      super(CollectionAction.SPLITSHARD);
+      super(METHOD.POST, CollectionAction.SPLITSHARD);
       this.collection = checkNotNull(CoreAdminParams.COLLECTION, collection);
     }
 
@@ -1759,7 +1835,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     private Boolean deleteDataDir;
 
     private DeleteShard(String collection, String shard) {
-      super(CollectionAction.DELETESHARD, collection, shard);
+      super(METHOD.POST, CollectionAction.DELETESHARD, collection, shard);
     }
 
     public Boolean getDeleteInstanceDir() {
@@ -1806,7 +1882,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
   // FORCELEADER request
   public static class ForceLeader extends ShardSpecificAdminRequest {
     private ForceLeader(String collection, String shard) {
-      super(CollectionAction.FORCELEADER, collection, shard);
+      super(METHOD.POST, CollectionAction.FORCELEADER, collection, shard);
     }
   }
 
@@ -1839,7 +1915,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected String requestId = null;
 
     private RequestStatus(String requestId) {
-      super(CollectionAction.REQUESTSTATUS);
+      super(METHOD.GET, CollectionAction.REQUESTSTATUS);
       this.requestId = checkNotNull("requestId", requestId);
     }
 
@@ -1900,7 +1976,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected Boolean flush = null;
 
     private DeleteStatus(String requestId, Boolean flush) {
-      super(CollectionAction.DELETESTATUS);
+      super(METHOD.POST, CollectionAction.DELETESTATUS);
       if (requestId == null && flush == null)
         throw new IllegalArgumentException(
             "Either requestid or flush parameter must be specified.");
@@ -1951,7 +2027,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     private Map<String, String> properties = new HashMap<>();
 
     public SetAliasProperty(String aliasName) {
-      super(CollectionAction.ALIASPROP);
+      super(METHOD.POST, CollectionAction.ALIASPROP);
       this.aliasName = SolrIdentifierValidator.validateAliasName(aliasName);
     }
 
@@ -1990,7 +2066,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected String aliasedCollections;
 
     private CreateAlias(String aliasName, String aliasedCollections) {
-      super(CollectionAction.CREATEALIAS);
+      super(METHOD.POST, CollectionAction.CREATEALIAS);
       this.aliasName = SolrIdentifierValidator.validateAliasName(aliasName);
       this.aliasedCollections = checkNotNull("aliasedCollections", 
aliasedCollections);
     }
@@ -2064,7 +2140,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
         String start,
         String interval,
         Create createCollTemplate) {
-      super(CollectionAction.CREATEALIAS);
+      super(METHOD.POST, CollectionAction.CREATEALIAS);
       this.aliasName = aliasName;
       this.start = start;
       this.interval = interval;
@@ -2179,7 +2255,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
 
     public CreateCategoryRoutedAlias(
         String aliasName, String routerField, int maxCardinality, Create 
createCollTemplate) {
-      super(CollectionAction.CREATEALIAS);
+      super(METHOD.POST, CollectionAction.CREATEALIAS);
       this.aliasName = aliasName;
       this.routerField = routerField;
       this.maxCardinality = maxCardinality;
@@ -2285,7 +2361,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
 
     public DimensionalRoutedAlias(
         String aliasName, Create createCollTemplate, 
RoutedAliasAdminRequest... dims) {
-      super(CollectionAction.CREATEALIAS);
+      super(METHOD.POST, CollectionAction.CREATEALIAS);
       this.aliasName = aliasName;
       this.createCollTemplate = createCollTemplate;
       this.dims = dims;
@@ -2369,7 +2445,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected String aliasName;
 
     private DeleteAlias(String aliasName) {
-      super(CollectionAction.DELETEALIAS);
+      super(METHOD.POST, CollectionAction.DELETEALIAS);
       this.aliasName = checkNotNull("aliasName", aliasName);
     }
 
@@ -2422,7 +2498,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected String createNodeSet;
 
     private AddReplica(String collection, String shard, String routeKey, 
Replica.Type type) {
-      super(CollectionAction.ADDREPLICA);
+      super(METHOD.POST, CollectionAction.ADDREPLICA);
       this.collection = checkNotNull(CoreAdminParams.COLLECTION, collection);
       this.shard = shard;
       this.routeKey = routeKey;
@@ -2622,19 +2698,19 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     private Integer count;
 
     private DeleteReplica(String collection, String shard, String replica) {
-      super(CollectionAction.DELETEREPLICA, collection);
+      super(METHOD.POST, CollectionAction.DELETEREPLICA, collection);
       this.shard = shard;
       this.replica = replica;
     }
 
     private DeleteReplica(String collection, String shard, int count) {
-      super(CollectionAction.DELETEREPLICA, collection);
+      super(METHOD.POST, CollectionAction.DELETEREPLICA, collection);
       this.shard = shard;
       this.count = count;
     }
 
     private DeleteReplica(String collection, int count) {
-      super(CollectionAction.DELETEREPLICA, collection);
+      super(METHOD.POST, CollectionAction.DELETEREPLICA, collection);
       this.count = count;
     }
 
@@ -2721,7 +2797,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     private String propertyValue;
 
     private ClusterProp(String propertyName, String propertyValue) {
-      super(CollectionAction.CLUSTERPROP);
+      super(METHOD.POST, CollectionAction.CLUSTERPROP);
       this.propertyName = checkNotNull("propertyName", propertyName);
       this.propertyValue = propertyValue;
     }
@@ -2761,7 +2837,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     private String propertyValue;
 
     private CollectionProp(String collection, String propertyName, String 
propertyValue) {
-      super(CollectionAction.COLLECTIONPROP, collection);
+      super(METHOD.POST, CollectionAction.COLLECTIONPROP, collection);
       this.propertyName = checkNotNull("propertyName", propertyName);
       this.propertyValue = propertyValue;
     }
@@ -2804,7 +2880,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     private Properties properties;
 
     private Migrate(String collection, String targetCollection, String 
splitKey) {
-      super(CollectionAction.MIGRATE);
+      super(METHOD.POST, CollectionAction.MIGRATE);
       this.collection = checkNotNull(CoreAdminParams.COLLECTION, collection);
       this.targetCollection = checkNotNull("targetCollection", 
targetCollection);
       this.splitKey = checkNotNull("split.key", splitKey);
@@ -2870,7 +2946,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
   // ADDROLE request
   public static class AddRole extends CollectionAdminRoleRequest {
     private AddRole(String node, String role) {
-      super(CollectionAction.ADDROLE, node, role);
+      super(METHOD.POST, CollectionAction.ADDROLE, node, role);
     }
   }
 
@@ -2887,7 +2963,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
   // REMOVEROLE request
   public static class RemoveRole extends CollectionAdminRoleRequest {
     private RemoveRole(String node, String role) {
-      super(CollectionAction.REMOVEROLE, node, role);
+      super(METHOD.POST, CollectionAction.REMOVEROLE, node, role);
     }
   }
 
@@ -2900,7 +2976,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
   public static class OverseerStatus extends AsyncCollectionAdminRequest {
 
     public OverseerStatus() {
-      super(CollectionAction.OVERSEERSTATUS);
+      super(METHOD.GET, CollectionAction.OVERSEERSTATUS);
     }
   }
 
@@ -2909,7 +2985,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
       extends CollectionAdminRequest<RequestApiDistributedProcessingResponse> {
 
     public RequestApiDistributedProcessing() {
-      super(CollectionAction.DISTRIBUTEDAPIPROCESSING);
+      super(METHOD.GET, CollectionAction.DISTRIBUTEDAPIPROCESSING);
     }
 
     @Override
@@ -2938,7 +3014,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected String routeKey = null;
 
     public ClusterStatus() {
-      super(CollectionAction.CLUSTERSTATUS);
+      super(METHOD.GET, CollectionAction.CLUSTERSTATUS);
     }
 
     public ClusterStatus setCollectionName(String collectionName) {
@@ -2993,7 +3069,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
   public static class ListAliases extends 
CollectionAdminRequest<CollectionAdminResponse> {
 
     public ListAliases() {
-      super(CollectionAction.LISTALIASES);
+      super(METHOD.GET, CollectionAction.LISTALIASES);
     }
 
     @Override
@@ -3013,7 +3089,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
   // LIST request
   public static class List extends 
CollectionAdminRequest<CollectionAdminResponse> {
     public List() {
-      super(CollectionAction.LIST);
+      super(METHOD.GET, CollectionAction.LIST);
     }
 
     @Override
@@ -3086,7 +3162,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     private Boolean purgeUnused;
 
     private DeleteBackup(String backupName) {
-      super(CollectionAction.DELETEBACKUP);
+      super(METHOD.POST, CollectionAction.DELETEBACKUP);
 
       this.name = backupName;
     }
@@ -3189,7 +3265,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     private String repositoryName;
 
     private ListBackup(String backupName) {
-      super(CollectionAction.LISTBACKUP);
+      super(METHOD.GET, CollectionAction.LISTBACKUP);
 
       this.backupName = backupName;
     }
@@ -3251,7 +3327,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
         String replica,
         String propertyName,
         String propertyValue) {
-      super(CollectionAction.ADDREPLICAPROP, collection, shard);
+      super(METHOD.POST, CollectionAction.ADDREPLICAPROP, collection, shard);
       this.replica = checkNotNull(CoreAdminParams.REPLICA, replica);
       this.propertyName = checkNotNull("propertyName", propertyName);
       this.propertyValue = checkNotNull("propertyValue", propertyValue);
@@ -3307,7 +3383,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
 
     private DeleteReplicaProp(
         String collection, String shard, String replica, String propertyName) {
-      super(CollectionAction.DELETEREPLICAPROP, collection, shard);
+      super(METHOD.POST, CollectionAction.DELETEREPLICAPROP, collection, 
shard);
       this.replica = checkNotNull(CoreAdminParams.REPLICA, replica);
       this.propertyName = checkNotNull("propertyName", propertyName);
     }
@@ -3343,7 +3419,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected Boolean shardUnique;
 
     private BalanceShardUnique(String collection, String propertyName) {
-      super(CollectionAction.BALANCESHARDUNIQUE);
+      super(METHOD.POST, CollectionAction.BALANCESHARDUNIQUE);
       this.collection = checkNotNull(CoreAdminParams.COLLECTION, collection);
       this.propertyName = checkNotNull("propertyName", propertyName);
     }
@@ -3391,7 +3467,7 @@ public abstract class CollectionAdminRequest<T extends 
CollectionAdminResponse>
     protected Map<String, Object> attributes;
 
     private Modify(String collection, Map<String, Object> attributes) {
-      super(CollectionAction.MODIFYCOLLECTION, collection);
+      super(METHOD.POST, CollectionAction.MODIFYCOLLECTION, collection);
       this.attributes = attributes;
     }
 
diff --git 
a/solr/solrj/src/java/org/apache/solr/client/solrj/request/ConfigSetAdminRequest.java
 
b/solr/solrj/src/java/org/apache/solr/client/solrj/request/ConfigSetAdminRequest.java
index e0b0a708e3f..2154f63ba12 100644
--- 
a/solr/solrj/src/java/org/apache/solr/client/solrj/request/ConfigSetAdminRequest.java
+++ 
b/solr/solrj/src/java/org/apache/solr/client/solrj/request/ConfigSetAdminRequest.java
@@ -50,12 +50,28 @@ public abstract class ConfigSetAdminRequest<
     return this;
   }
 
+  public ConfigSetAdminRequest(METHOD method) {
+    this(method, "/admin/configs");
+  }
+
+  public ConfigSetAdminRequest(METHOD method, String path) {
+    super(method, path, SolrRequestType.ADMIN);
+  }
+
+  /**
+   * @deprecated Use {@link #ConfigSetAdminRequest(METHOD)}.
+   */
+  @Deprecated(since = "10.1")
   public ConfigSetAdminRequest() {
-    super(METHOD.GET, "/admin/configs", SolrRequestType.ADMIN);
+    this(METHOD.POST);
   }
 
+  /**
+   * @deprecated Use {@link #ConfigSetAdminRequest(METHOD, String)}.
+   */
+  @Deprecated(since = "10.1")
   public ConfigSetAdminRequest(String path) {
-    super(METHOD.GET, path, SolrRequestType.ADMIN);
+    this(METHOD.POST, path);
   }
 
   protected abstract Q getThis();
@@ -78,6 +94,18 @@ public abstract class ConfigSetAdminRequest<
       extends ConfigSetAdminRequest<T, ConfigSetAdminResponse> {
     protected String configSetName = null;
 
+    protected ConfigSetSpecificAdminRequest(METHOD method) {
+      super(method);
+    }
+
+    /**
+     * @deprecated Use {@link #ConfigSetSpecificAdminRequest(METHOD)}.
+     */
+    @Deprecated(since = "10.1")
+    protected ConfigSetSpecificAdminRequest() {
+      this(METHOD.POST);
+    }
+
     public final T setConfigSetName(String configSetName) {
       this.configSetName = configSetName;
       return getThis();
@@ -121,8 +149,8 @@ public abstract class ConfigSetAdminRequest<
     protected Boolean cleanup;
 
     public Upload() {
+      super(METHOD.POST);
       action = ConfigSetAction.UPLOAD;
-      setMethod(SolrRequest.METHOD.POST);
     }
 
     @Override
@@ -255,6 +283,7 @@ public abstract class ConfigSetAdminRequest<
     protected Properties properties;
 
     public Create() {
+      super(METHOD.POST);
       action = ConfigSetAction.CREATE;
     }
 
@@ -300,6 +329,7 @@ public abstract class ConfigSetAdminRequest<
   // DELETE request
   public static class Delete extends ConfigSetSpecificAdminRequest<Delete> {
     public Delete() {
+      super(METHOD.POST);
       action = ConfigSetAction.DELETE;
     }
 
@@ -312,6 +342,7 @@ public abstract class ConfigSetAdminRequest<
   // LIST request
   public static class List extends ConfigSetAdminRequest<List, 
ConfigSetAdminResponse.List> {
     public List() {
+      super(METHOD.GET);
       action = ConfigSetAction.LIST;
     }
 
diff --git 
a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java
 
b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java
index 3c4b5dae0a1..755efb65fe8 100644
--- 
a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java
+++ 
b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java
@@ -62,6 +62,7 @@ public class CoreAdminRequest extends 
SolrRequest<CoreAdminResponse> {
     private String collectionConfigName;
 
     public Create() {
+      super(METHOD.POST);
       action = CoreAdminAction.CREATE;
     }
 
@@ -233,6 +234,7 @@ public class CoreAdminRequest extends 
SolrRequest<CoreAdminResponse> {
     protected Boolean onlyIfLeaderActive;
 
     public WaitForState() {
+      super(METHOD.POST);
       action = CoreAdminAction.PREPRECOVERY;
     }
 
@@ -330,6 +332,7 @@ public class CoreAdminRequest extends 
SolrRequest<CoreAdminResponse> {
   public static class RequestRecovery extends CoreAdminRequest {
 
     public RequestRecovery() {
+      super(METHOD.POST);
       action = CoreAdminAction.REQUESTRECOVERY;
     }
 
@@ -352,6 +355,7 @@ public class CoreAdminRequest extends 
SolrRequest<CoreAdminResponse> {
     private String collection;
 
     public RequestSyncShard() {
+      super(METHOD.POST);
       action = CoreAdminAction.REQUESTSYNCSHARD;
     }
 
@@ -391,6 +395,7 @@ public class CoreAdminRequest extends 
SolrRequest<CoreAdminResponse> {
     protected List<String> srcCores;
 
     public MergeIndexes() {
+      super(METHOD.POST);
       action = CoreAdminAction.MERGEINDEXES;
     }
 
@@ -438,6 +443,7 @@ public class CoreAdminRequest extends 
SolrRequest<CoreAdminResponse> {
     protected boolean deleteInstanceDir;
 
     public Unload(boolean deleteIndex) {
+      super(METHOD.POST);
       action = CoreAdminAction.UNLOAD;
       this.deleteIndex = deleteIndex;
     }
@@ -480,7 +486,7 @@ public class CoreAdminRequest extends 
SolrRequest<CoreAdminResponse> {
     private String commitName;
 
     public CreateSnapshot(String commitName) {
-      super();
+      super(METHOD.POST);
       this.action = CoreAdminAction.CREATESNAPSHOT;
       if (commitName == null) {
         throw new NullPointerException("Please specify non null value for 
commitName parameter.");
@@ -504,7 +510,7 @@ public class CoreAdminRequest extends 
SolrRequest<CoreAdminResponse> {
     private String commitName;
 
     public DeleteSnapshot(String commitName) {
-      super();
+      super(METHOD.POST);
       this.action = CoreAdminAction.DELETESNAPSHOT;
 
       if (commitName == null) {
@@ -527,17 +533,33 @@ public class CoreAdminRequest extends 
SolrRequest<CoreAdminResponse> {
 
   public static class ListSnapshots extends CoreAdminRequest {
     public ListSnapshots() {
-      super();
+      super(METHOD.GET);
       this.action = CoreAdminAction.LISTSNAPSHOTS;
     }
   }
 
+  public CoreAdminRequest(METHOD method) {
+    this(method, "/admin/cores");
+  }
+
+  public CoreAdminRequest(METHOD method, String path) {
+    super(method, path, SolrRequestType.ADMIN);
+  }
+
+  /**
+   * @deprecated Use {@link #CoreAdminRequest(METHOD)}.
+   */
+  @Deprecated(since = "10.1")
   public CoreAdminRequest() {
-    super(METHOD.GET, "/admin/cores", SolrRequestType.ADMIN);
+    this(METHOD.POST);
   }
 
+  /**
+   * @deprecated Use {@link #CoreAdminRequest(METHOD, String)}.
+   */
+  @Deprecated(since = "10.1")
   public CoreAdminRequest(String path) {
-    super(METHOD.GET, path, SolrRequestType.ADMIN);
+    this(METHOD.POST, path);
   }
 
   public void setCoreName(String coreName) {
@@ -594,7 +616,7 @@ public class CoreAdminRequest extends 
SolrRequest<CoreAdminResponse> {
 
   public static CoreAdminResponse reloadCore(String name, SolrClient client)
       throws SolrServerException, IOException {
-    CoreAdminRequest req = new CoreAdminRequest();
+    CoreAdminRequest req = new CoreAdminRequest(METHOD.POST);
     req.setCoreName(name);
     req.setAction(CoreAdminAction.RELOAD);
     return req.process(client);
@@ -626,7 +648,7 @@ public class CoreAdminRequest extends 
SolrRequest<CoreAdminResponse> {
    */
   public static CoreAdminResponse renameCore(String coreName, String newName, 
SolrClient client)
       throws SolrServerException, IOException {
-    CoreAdminRequest req = new CoreAdminRequest();
+    CoreAdminRequest req = new CoreAdminRequest(METHOD.POST);
     req.setCoreName(coreName);
     req.setOtherCoreName(SolrIdentifierValidator.validateCoreName(newName));
     req.setAction(CoreAdminAction.RENAME);
@@ -645,7 +667,7 @@ public class CoreAdminRequest extends 
SolrRequest<CoreAdminResponse> {
    */
   public static CoreAdminResponse swapCore(String core1, String core2, 
SolrClient client)
       throws SolrServerException, IOException {
-    CoreAdminRequest req = new CoreAdminRequest();
+    CoreAdminRequest req = new CoreAdminRequest(METHOD.POST);
     req.setCoreName(core1);
     req.setOtherCoreName(core2);
     req.setAction(CoreAdminAction.SWAP);
@@ -660,7 +682,7 @@ public class CoreAdminRequest extends 
SolrRequest<CoreAdminResponse> {
   public static CoreStatusResponse.SingleCoreData getCoreStatus(
       String coreName, boolean getIndexInfo, SolrClient client)
       throws SolrServerException, IOException {
-    CoreAdminRequest req = new CoreAdminRequest();
+    CoreAdminRequest req = new CoreAdminRequest(METHOD.GET);
     req.setAction(CoreAdminAction.STATUS);
     req.setIndexInfoNeeded(getIndexInfo);
     return req.process(client).getCoreStatus(coreName);
@@ -668,7 +690,7 @@ public class CoreAdminRequest extends 
SolrRequest<CoreAdminResponse> {
 
   public static CoreAdminResponse getStatus(String name, SolrClient client)
       throws SolrServerException, IOException {
-    CoreAdminRequest req = new CoreAdminRequest();
+    CoreAdminRequest req = new CoreAdminRequest(METHOD.GET);
     req.setCoreName(name);
     req.setAction(CoreAdminAction.STATUS);
     return req.process(client);
diff --git 
a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCollectionAdminRequest.java
 
b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCollectionAdminRequest.java
index 3963b5866a3..7cbab3936e6 100644
--- 
a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCollectionAdminRequest.java
+++ 
b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCollectionAdminRequest.java
@@ -17,14 +17,34 @@
 package org.apache.solr.client.solrj.request;
 
 import org.apache.solr.SolrTestCase;
+import org.apache.solr.client.solrj.SolrRequest.METHOD;
 import org.apache.solr.client.solrj.request.CollectionAdminRequest.CreateAlias;
 import org.apache.solr.client.solrj.request.CollectionAdminRequest.CreateShard;
+import org.apache.solr.client.solrj.response.CollectionAdminResponse;
 import org.apache.solr.common.SolrException;
+import org.apache.solr.common.params.CollectionParams.CollectionAction;
+import org.apache.solr.common.util.NamedList;
 import org.junit.Test;
 
 /** Unit tests for {@link CollectionAdminRequest}. */
 public class TestCollectionAdminRequest extends SolrTestCase {
 
+  @Test
+  @SuppressWarnings("deprecation")
+  public void testAdminRequestsChooseExplicitHttpMethods() {
+    CollectionAdminRequest<CollectionAdminResponse> legacyRequest =
+        new CollectionAdminRequest<>(CollectionAction.CREATE) {
+          @Override
+          protected CollectionAdminResponse createResponse(NamedList<Object> 
namedList) {
+            return new CollectionAdminResponse();
+          }
+        };
+    assertEquals(METHOD.POST, legacyRequest.getMethod());
+    assertEquals(
+        METHOD.POST, CollectionAdminRequest.createCollection("collection", 
null, 1, 1).getMethod());
+    assertEquals(METHOD.GET, new CollectionAdminRequest.List().getMethod());
+  }
+
   @Test
   public void testInvalidCollectionNameRejectedWhenCreatingCollection() {
     final SolrException e =
diff --git 
a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestConfigSetAdminRequest.java
 
b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestConfigSetAdminRequest.java
index 39b22fed446..357e061b17b 100644
--- 
a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestConfigSetAdminRequest.java
+++ 
b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestConfigSetAdminRequest.java
@@ -18,6 +18,7 @@ package org.apache.solr.client.solrj.request;
 
 import java.nio.file.Path;
 import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.SolrRequest.METHOD;
 import org.apache.solr.client.solrj.response.ConfigSetAdminResponse;
 import org.apache.solr.common.params.ConfigSetParams;
 import org.apache.solr.common.util.NamedList;
@@ -26,6 +27,14 @@ import org.junit.Test;
 /** Basic error checking of ConfigSetAdminRequests. */
 public class TestConfigSetAdminRequest extends SolrTestCaseJ4 {
 
+  @Test
+  @SuppressWarnings("deprecation")
+  public void testAdminRequestsChooseExplicitHttpMethods() {
+    assertEquals(METHOD.POST, new MyConfigSetAdminRequest().getMethod());
+    assertEquals(METHOD.POST, new ConfigSetAdminRequest.Create().getMethod());
+    assertEquals(METHOD.GET, new ConfigSetAdminRequest.List().getMethod());
+  }
+
   @Test
   public void testNoAction() {
     MyConfigSetAdminRequest request = new MyConfigSetAdminRequest();
diff --git 
a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java 
b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java
index d4b7beece42..45198ba422c 100644
--- 
a/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java
+++ 
b/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java
@@ -43,6 +43,14 @@ import org.junit.Test;
 
 public class TestCoreAdmin extends AbstractEmbeddedSolrServerTestCase {
 
+  @Test
+  @SuppressWarnings("deprecation")
+  public void testAdminRequestsChooseExplicitHttpMethods() {
+    assertEquals(METHOD.POST, new CoreAdminRequest().getMethod());
+    assertEquals(METHOD.POST, new CoreAdminRequest.Create().getMethod());
+    assertEquals(METHOD.GET, new CoreAdminRequest.ListSnapshots().getMethod());
+  }
+
   @Test
   public void testConfigSet() throws Exception {
 

Reply via email to