Skip to content

SOLR-17600 (Part 1/4): Migrate V2 API Payloads from MapSerializable#4463

Open
isaric wants to merge 2 commits into
apache:mainfrom
isaric:SOLR-17600-1-v2-api
Open

SOLR-17600 (Part 1/4): Migrate V2 API Payloads from MapSerializable#4463
isaric wants to merge 2 commits into
apache:mainfrom
isaric:SOLR-17600-1-v2-api

Conversation

@isaric
Copy link
Copy Markdown

@isaric isaric commented May 25, 2026

This is Part 1 of 4 to deprecate and remove the MapSerializable interface 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with Utils.convertToMap(...) or new SimpleOrderedMap<>(...).
  • Updated config/response building code paths to use MapWriter / SimpleOrderedMap rather than MapSerializable.
  • Adjusted BaseHandlerApiSupport parameter adapter to implement writeMap(...) 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.

Comment thread solr/core/src/java/org/apache/solr/handler/admin/api/OverseerOperationAPI.java Outdated
Comment on lines +281 to +284
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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SOM is good here; this is a response-structure

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed — keeping SOM.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java Outdated
o instanceof MapSerializable
? ((MapSerializable) o).toMap(new LinkedHashMap<>())
o instanceof MapWriter
? new SimpleOrderedMap<>((MapWriter) o)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SOM is okay for response

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SimpleOrderedMap implements Map<String, T>, so the type is compatible. The SOM stays here because the resulting map is mutated downstream (computeIfAbsent, put).

Comment thread solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java Outdated
pluginInfo = (Map) plugin;
} else if (plugin instanceof PluginInfo) {
pluginInfo = ((PluginInfo) plugin).toMap(new LinkedHashMap<>());
pluginInfo = new SimpleOrderedMap<>((PluginInfo) plugin);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java Outdated
@isaric isaric force-pushed the SOLR-17600-1-v2-api branch 2 times, most recently from baae128 to 74d671e Compare May 26, 2026 05:55
Copy link
Copy Markdown
Contributor

@dsmiley dsmiley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for resuming this effort!

Comment thread solr/core/src/java/org/apache/solr/handler/admin/api/OverseerOperationAPI.java Outdated
Comment thread solr/core/src/java/org/apache/solr/handler/admin/BaseHandlerApiSupport.java Outdated
Comment on lines +281 to +284
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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SOM is good here; this is a response-structure

Comment thread solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java Outdated
o instanceof MapSerializable
? ((MapSerializable) o).toMap(new LinkedHashMap<>())
o instanceof MapWriter
? new SimpleOrderedMap<>((MapWriter) o)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SOM is okay for response

@isaric isaric force-pushed the SOLR-17600-1-v2-api branch from 74d671e to 00c356e Compare June 2, 2026 14:52
@dsmiley
Copy link
Copy Markdown
Contributor

dsmiley commented Jun 3, 2026

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.

Comment thread solr/core/src/java/org/apache/solr/handler/admin/api/OverseerOperationAPI.java Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@isaric
Copy link
Copy Markdown
Author

isaric commented Jun 6, 2026

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.

@dsmiley
Copy link
Copy Markdown
Contributor

dsmiley commented Jun 6, 2026

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.

@dsmiley
Copy link
Copy Markdown
Contributor

dsmiley commented Jun 6, 2026

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants