Skip to content

Commit d9461e2

Browse files
authored
Remove MapWriter.append (#2919)
Undocumented and called in only 2 places. Since MapWriter is implemented by a great many things, we should be conservative adding methods there. append() is kind of clever but I think it's outside the scope of what MapWriter should be.
1 parent 02cdf9e commit d9461e2

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

solr/core/src/java/org/apache/solr/cloud/ZkController.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,16 +1702,18 @@ public void publish(
17021702
}
17031703
if (core != null && core.getDirectoryFactory().isSharedStorage()) {
17041704
if (core.getDirectoryFactory().isSharedStorage()) {
1705+
// append additional entries to 'm'
1706+
MapWriter original = m;
17051707
m =
1706-
m.append(
1707-
props -> {
1708-
props.put(ZkStateReader.SHARED_STORAGE_PROP, "true");
1709-
props.put("dataDir", core.getDataDir());
1710-
UpdateLog ulog = core.getUpdateHandler().getUpdateLog();
1711-
if (ulog != null) {
1712-
props.put("ulogDir", ulog.getUlogDir());
1713-
}
1714-
});
1708+
props -> {
1709+
original.writeMap(props);
1710+
props.put(ZkStateReader.SHARED_STORAGE_PROP, "true");
1711+
props.put("dataDir", core.getDataDir());
1712+
UpdateLog ulog = core.getUpdateHandler().getUpdateLog();
1713+
if (ulog != null) {
1714+
props.put("ulogDir", ulog.getUlogDir());
1715+
}
1716+
};
17151717
}
17161718
}
17171719
} catch (SolrCoreInitializationException ex) {

solr/core/src/test/org/apache/solr/cloud/OverseerTaskQueueTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Map;
2222
import org.apache.solr.cloud.api.collections.CollectionHandlingUtils;
2323
import org.apache.solr.common.MapWriter;
24+
import org.apache.solr.common.cloud.ZkNodeProps;
2425
import org.apache.solr.common.cloud.ZkStateReader;
2526
import org.apache.solr.common.params.CollectionAdminParams;
2627
import org.apache.solr.common.params.CommonAdminParams;
@@ -73,8 +74,9 @@ public void testContainsTaskWithRequestId() throws Exception {
7374
String watchID = tq.createResponseNode();
7475
String requestId2 = "baz";
7576

77+
// append async then submit
7678
tq.createRequestNode(
77-
Utils.toJSON(props.append(ew -> ew.put(CommonAdminParams.ASYNC, requestId2))), watchID);
79+
Utils.toJSON(new ZkNodeProps(props).plus(CommonAdminParams.ASYNC, requestId2)), watchID);
7880

7981
// Set a SolrResponse as the response node by removing the QueueEvent, as done in
8082
// OverseerTaskProcessor

solr/solrj/src/java/org/apache/solr/common/MapWriter.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
*/
3434
public interface MapWriter extends MapSerializable, NavigableObject, JSONWriter.Writable {
3535

36+
/** Writes this object's entries out to {@code ew}. */
37+
void writeMap(EntryWriter ew) throws IOException;
38+
3639
default String jsonStr() {
3740
return Utils.toJSONString(this);
3841
}
@@ -42,6 +45,7 @@ default Map<String, Object> toMap(Map<String, Object> map) {
4245
return Utils.convertToMap(this, map);
4346
}
4447

48+
/** For implementing Noggit {@link org.noggit.JSONWriter.Writable}. */
4549
@Override
4650
default void write(JSONWriter writer) {
4751
writer.startObject();
@@ -70,8 +74,7 @@ public MapWriter.EntryWriter put(CharSequence k, Object v) {
7074
writer.endObject();
7175
}
7276

73-
void writeMap(EntryWriter ew) throws IOException;
74-
77+
@Deprecated
7578
default MapWriter append(MapWriter another) {
7679
MapWriter m = this;
7780
return ew -> {

0 commit comments

Comments
 (0)