From a7cebd31de16029dc3c2015f7cad3b1a995d72b5 Mon Sep 17 00:00:00 2001 From: jaykay12 Date: Tue, 27 Oct 2026 04:11:24 +0530 Subject: [PATCH 1/4] placeholder PR --- .../src/java/org/apache/solr/handler/ReplicationHandler.java | 1 + 1 file changed, 1 insertion(+) diff --git a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java index 8287459f28f3..1fc252c83550 100644 --- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java @@ -327,6 +327,7 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw reportErrorOnResponse(rsp, "No follower configured", null); } } else if (command.equals(CMD_SHOW_COMMITS)) { + // Needs to be solved for populateCommitInfo(rsp); } else if (command.equals(CMD_DETAILS)) { final CoreReplication coreReplicationAPI = new CoreReplication(core, req, rsp); From dfd245bfcc60a7ecc0522f7580f9ac4b2e83e17b Mon Sep 17 00:00:00 2001 From: jaykay12 Date: Fri, 30 Oct 2026 02:10:49 +0530 Subject: [PATCH 2/4] minor --- .../src/java/org/apache/solr/handler/ReplicationHandler.java | 1 - 1 file changed, 1 deletion(-) diff --git a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java index 53dfc9aba179..d0c4a89da198 100644 --- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java @@ -80,7 +80,6 @@ import org.apache.solr.client.api.model.FileMetaData; import org.apache.solr.client.api.model.IndexVersionResponse; import org.apache.solr.client.api.model.ReplicationDetailsResponse; -import org.apache.solr.client.api.model.ReplicationDetailsResponse.CommitDetails; import org.apache.solr.client.api.model.ReplicationDetailsResponse.FollowerDetails; import org.apache.solr.client.api.model.ReplicationDetailsResponse.LeaderDetails; import org.apache.solr.client.api.model.ReplicationDetailsResponse.ReplicationDetails; From 89f3cf2a5ad94bbb841f7d373fb5fdb5b4e5e015 Mon Sep 17 00:00:00 2001 From: jaykay12 Date: Fri, 30 Oct 2026 02:36:02 +0530 Subject: [PATCH 3/4] fixed for details --- .../java/org/apache/solr/handler/ReplicationHandler.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java index d0c4a89da198..40943072223a 100644 --- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java @@ -341,9 +341,8 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw reportErrorOnResponse(rsp, "No follower configured", null); } } else if (command.equals(CMD_SHOW_COMMITS)) { - // Needs to be solved for - final CoreReplication coreReplicationAPI = new CoreReplication(core, req, rsp); - V2ApiUtils.squashIntoSolrResponseWithoutHeader(rsp, coreReplicationAPI.fetchCommits()); + rsp.add(CMD_SHOW_COMMITS, getCommits()); + rsp.add(STATUS, OK_STATUS); } else if (command.equals(CMD_DETAILS)) { final CoreReplication coreReplicationAPI = new CoreReplication(core, req, rsp); // stringifyBooleans=true: V1's command=details has always rendered isLeader/isFollower/etc. @@ -353,6 +352,10 @@ public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throw coreReplicationAPI.fetchReplicationDetails(solrParams.getBool("follower", true)), true, true); + // V1 has rendered commits as NamedList (flatmap), not a map + @SuppressWarnings("unchecked") + final var details = (NamedList) rsp.getValues().get(CMD_DETAILS); + details.setVal(details.indexOf(CMD_SHOW_COMMITS, 0), getCommits()); } else if (CMD_ENABLE_REPL.equalsIgnoreCase(command)) { setReplicationEnabled(true); rsp.add(STATUS, OK_STATUS); From 1116c2d502b25de0b6204d5d4846e2c60c4dd33b Mon Sep 17 00:00:00 2001 From: Nick Shanin Date: Mon, 26 Oct 2026 14:49:39 +0000 Subject: [PATCH 4/4] SOLR-16398: Add regression test for v1 replication commits response shape The v1 command=commits response must keep rendering each commit as a NamedList (a flat name/value array by default), not a map. This test fails on the PR head 9599df2d01f and passes on its base 07fdebdda54. --- .../ReplicationCommitsV1ResponseTest.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 solr/core/src/test/org/apache/solr/handler/ReplicationCommitsV1ResponseTest.java diff --git a/solr/core/src/test/org/apache/solr/handler/ReplicationCommitsV1ResponseTest.java b/solr/core/src/test/org/apache/solr/handler/ReplicationCommitsV1ResponseTest.java new file mode 100644 index 000000000000..8b32aa273106 --- /dev/null +++ b/solr/core/src/test/org/apache/solr/handler/ReplicationCommitsV1ResponseTest.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.solr.handler; + +import java.util.List; +import java.util.Map; +import org.apache.solr.SolrTestCaseJ4; +import org.apache.solr.common.util.Utils; +import org.junit.BeforeClass; +import org.junit.Test; + +public class ReplicationCommitsV1ResponseTest extends SolrTestCaseJ4 { + + @BeforeClass + public static void beforeClass() throws Exception { + initCore("solrconfig-leader1.xml", "schema.xml"); + } + + @Test + public void testV1CommitsFlatNamedListShape() throws Exception { + assertU(adoc("id", "1")); + assertU(commit()); + + String json = + h.query("/replication", req("command", "commits", "wt", "json", "json.nl", "flat")); + assertFirstCommitIsFlatNamedList(json); + } + + @Test + public void testV1CommitsDefaultJsonShape() throws Exception { + assertU(adoc("id", "1")); + assertU(commit()); + + String json = h.query("/replication", req("command", "commits", "wt", "json")); + assertFirstCommitIsFlatNamedList(json); + } + + private static void assertFirstCommitIsFlatNamedList(String json) { + List commits = (List) ((Map) Utils.fromJSONString(json)).get("commits"); + assertFalse("expected at least one commit point", commits.isEmpty()); + Object firstCommit = commits.get(0); + assertTrue( + "v1 commits entry must stay a NamedList rendered as a flat name/value array, got: " + + firstCommit, + firstCommit instanceof List); + List entry = (List) firstCommit; + assertEquals("indexVersion", entry.get(0)); + assertEquals("generation", entry.get(2)); + } +}