SOLR-17600 (Part 1/4): Migrate V2 API Payloads from MapSerializable#4463
SOLR-17600 (Part 1/4): Migrate V2 API Payloads from MapSerializable#4463isaric wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Refactors multiple Solr handlers/tests to standardize conversion of Solr/MapWriter-style objects into map-like structures (favoring Utils.convertToMap(...) / SimpleOrderedMap) and updates one internal API adapter to a MapWriter#writeMap(...) implementation.
Changes:
- Replaced a number of
toMap(new HashMap<>())call sites withUtils.convertToMap(...)ornew SimpleOrderedMap<>(...). - Updated config/response building code paths to use
MapWriter/SimpleOrderedMaprather thanMapSerializable. - Adjusted
BaseHandlerApiSupportparameter adapter to implementwriteMap(...)and skip null-valued entries.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerAPI.java | Updates test param map construction to use SimpleOrderedMap. |
| solr/core/src/java/org/apache/solr/handler/export/ExportWriterStream.java | Uses SimpleOrderedMap when materializing MapWriter values. |
| solr/core/src/java/org/apache/solr/handler/designer/ManagedSchemaDiff.java | Uses Utils.convertToMap for diff map materialization. |
| solr/core/src/java/org/apache/solr/handler/admin/api/SplitShardAPI.java | Uses Utils.convertToMap for v2 payload → v1 params. |
| solr/core/src/java/org/apache/solr/handler/admin/api/SplitCoreAPI.java | Uses Utils.convertToMap for v2 payload → v1 params. |
| solr/core/src/java/org/apache/solr/handler/admin/api/RequestSyncShardAPI.java | Uses Utils.convertToMap for v2 payload → v1 params. |
| solr/core/src/java/org/apache/solr/handler/admin/api/RequestCoreRecoveryAPI.java | Uses Utils.convertToMap for v2 payload → v1 params. |
| solr/core/src/java/org/apache/solr/handler/admin/api/RequestBufferUpdatesAPI.java | Uses Utils.convertToMap for v2 payload → v1 params. |
| solr/core/src/java/org/apache/solr/handler/admin/api/RequestApplyCoreUpdatesAPI.java | Uses Utils.convertToMap for v2 payload → v1 params. |
| solr/core/src/java/org/apache/solr/handler/admin/api/RejoinLeaderElectionAPI.java | Uses Utils.convertToMap for v2 payload → v1 params. |
| solr/core/src/java/org/apache/solr/handler/admin/api/RebalanceLeadersAPI.java | Uses Utils.convertToMap for v2 payload → v1 params. |
| solr/core/src/java/org/apache/solr/handler/admin/api/PrepareCoreRecoveryAPI.java | Uses Utils.convertToMap for v2 payload → v1 params. |
| solr/core/src/java/org/apache/solr/handler/admin/api/OverseerOperationAPI.java | Builds v1 params using SimpleOrderedMap instead of toMap(HashMap). |
| solr/core/src/java/org/apache/solr/handler/admin/api/MoveReplicaAPI.java | Uses Utils.convertToMap for v2 payload → v1 params. |
| solr/core/src/java/org/apache/solr/handler/admin/api/ModifyCollectionAPI.java | Uses Utils.convertToMap for v2 payload → v1 params. |
| solr/core/src/java/org/apache/solr/handler/admin/api/MigrateDocsAPI.java | Uses Utils.convertToMap for v2 payload → v1 params. |
| solr/core/src/java/org/apache/solr/handler/admin/api/InstallShardData.java | Uses Utils.convertToMap before creating ZkNodeProps. |
| solr/core/src/java/org/apache/solr/handler/admin/api/CreateCore.java | Uses Utils.convertToMap to derive request body from v1 params. |
| solr/core/src/java/org/apache/solr/handler/admin/ZookeeperInfoHandler.java | Uses Utils.convertToMap for DocCollection serialization. |
| solr/core/src/java/org/apache/solr/handler/admin/IndexSizeEstimator.java | Uses SimpleOrderedMap when converting MapWriter results. |
| solr/core/src/java/org/apache/solr/handler/admin/BaseHandlerApiSupport.java | Switches adapter from toMap(...) to writeMap(...) and filters nulls. |
| solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java | Migrates plugin/config map building to MapWriter/SimpleOrderedMap and adds helper for component lookup. |
| solr/core/src/java/org/apache/solr/handler/ClusterAPI.java | Builds role command maps using SimpleOrderedMap. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Map<String, Object> map = new SimpleOrderedMap<>(queue); | ||
| entry.setValue(map); | ||
| } else if (value instanceof MapWriterSummaryStatistics stats) { | ||
| Map<String, Object> map = new LinkedHashMap<>(); | ||
| stats.toMap(map); | ||
| Map<String, Object> map = new SimpleOrderedMap<>(stats); |
There was a problem hiding this comment.
SOM is good here; this is a response-structure
There was a problem hiding this comment.
SimpleOrderedMap<T> extends NamedList<T> implements Map<String, T> (SimpleOrderedMap.java:46), so it is a Map. @dsmiley also confirmed SOM is appropriate here as a response structure.
| o instanceof MapSerializable | ||
| ? ((MapSerializable) o).toMap(new LinkedHashMap<>()) | ||
| o instanceof MapWriter | ||
| ? new SimpleOrderedMap<>((MapWriter) o) |
There was a problem hiding this comment.
Keeping SOM here. The resulting pluginInfo map is mutated downstream in getComponentInfo (computeIfAbsent) and to inject _packageinfo_ via put, so it needs to be a real mutable Map.
There was a problem hiding this comment.
SimpleOrderedMap implements Map<String, T>, so the type is compatible. The SOM stays here because the resulting map is mutated downstream (computeIfAbsent, put).
| pluginInfo = (Map) plugin; | ||
| } else if (plugin instanceof PluginInfo) { | ||
| pluginInfo = ((PluginInfo) plugin).toMap(new LinkedHashMap<>()); | ||
| pluginInfo = new SimpleOrderedMap<>((PluginInfo) plugin); |
There was a problem hiding this comment.
SimpleOrderedMap implements Map<String, T>, so the type is compatible. This line was reverted to .toMap(new LinkedHashMap<>()) because PluginInfo does not implement MapWriter until Part 2.
baae128 to
74d671e
Compare
dsmiley
left a comment
There was a problem hiding this comment.
Thanks for resuming this effort!
| Map<String, Object> map = new SimpleOrderedMap<>(queue); | ||
| entry.setValue(map); | ||
| } else if (value instanceof MapWriterSummaryStatistics stats) { | ||
| Map<String, Object> map = new LinkedHashMap<>(); | ||
| stats.toMap(map); | ||
| Map<String, Object> map = new SimpleOrderedMap<>(stats); |
There was a problem hiding this comment.
SOM is good here; this is a response-structure
| o instanceof MapSerializable | ||
| ? ((MapSerializable) o).toMap(new LinkedHashMap<>()) | ||
| o instanceof MapWriter | ||
| ? new SimpleOrderedMap<>((MapWriter) o) |
74d671e to
00c356e
Compare
|
Please never force-push once someone has seen/reviewed your PR. It resets the review state. Not only that, but I see it's still one commit so I really don't know what changed. |
There was a problem hiding this comment.
The code here seems mostly populating a response. For such cases, I question if you need to convert existing MapWriter things to SimpleOrderedMap (e.g. by using SOM's constructor). Meaning, simply pass the MapWriter as-is. I believe the response writers will all check the value to be of type MapWriter and then do the right thing. I mentioned this point in Part 2 previously.
There was a problem hiding this comment.
Applied at line 208 where the value isn't mutated. The remaining SOM conversions (lines 292, 339, 372) all feed code paths that subsequently call computeIfAbsent / put / setValue on the map, so they need a mutable Map and the conversion stays.
Note: 339 and 372 were also broken in the originally pushed code (tried to wrap a MapSerializable in SimpleOrderedMap, which only has a MapWriter constructor — premature change that assumed Part 2's migration). I reverted them to .toMap(new LinkedHashMap<>()) so Part 1 compiles standalone; the SOM-wrap will land naturally in Part 2 once SolrConfig / PluginInfo become MapWriter.
- OverseerOperationAPI: restore HashMap (LinkedHashMap was an
unintended change; all sibling *API classes use HashMap)
- SolrConfigHandler: drop needless SimpleOrderedMap wrap around
ParamSet; response writers handle MapWriter directly
- SolrConfigHandler: revert two SimpleOrderedMap conversions that
required Part 2's MapWriter migration to compile; restored to
toMap(LinkedHashMap) to keep Part 1 independently buildable
|
Sorry about the force-push — that was a mistake. Future updates to all four PRs will land as additive commits so review state is preserved. |
|
The change is widespread enough across these 4 parts that I think it deserves an "other" type of changelog entry. I guess we'll add that to the last one that actually vanquishes MapSerializable. |
|
LMK if you've addressed everything and you think this is ready for merge. I don't want to scrutinize this further; I'm glad you looked into the matters I called out. |
This is Part 1 of 4 to deprecate and remove the
MapSerializableinterface as part of SOLR-17600.This PR migrates all V2 API payload and handler classes to use
MapWriter/Utils.convertToMap.Note: The work has been split into 4 PRs to make reviewing easier. The subsequent PRs are stacked on top of this one.