isaric commented on code in PR #4466:
URL: https://github.com/apache/solr/pull/4466#discussion_r3410126342
##########
solr/core/src/java/org/apache/solr/core/PluginInfo.java:
##########
@@ -192,27 +194,19 @@ public PluginInfo getChild(String type) {
}
@Override
- @SuppressWarnings({"unchecked", "rawtypes"})
- public Map<String, Object> toMap(Map<String, Object> map) {
- map.putAll(attributes);
- Map m = map;
- if (initArgs != null) m.putAll(initArgs.asMap(3));
- if (children != null) {
- for (PluginInfo child : children) {
- Object old = m.get(child.name);
- if (old == null) {
- m.put(child.name, child.toMap(new LinkedHashMap<>()));
- } else if (old instanceof List list) {
- list.add(child.toMap(new LinkedHashMap<>()));
- } else {
- ArrayList l = new ArrayList();
- l.add(old);
- l.add(child.toMap(new LinkedHashMap<>()));
- m.put(child.name, l);
- }
- }
+ @SuppressWarnings("unchecked")
+ public void writeMap(EntryWriter ew) throws IOException {
+ new NamedList<>(attributes).writeMap(ew);
+ if (initArgs != null) {
+ new SimpleOrderedMap<>(initArgs).writeMap(ew);
+ }
+ if (children == null || children.isEmpty()) {
+ return;
+ }
+
+ for (PluginInfo child : children) {
+ child.writeMap(ew);
}
- return m;
}
Review Comment:
Already addressed during Part 2 — the implementation groups children into a
`childrenGrouped` `LinkedHashMap` keyed by `child.name`, accumulating
duplicates into a `List`. That code is now on `main`.
##########
solr/core/src/java/org/apache/solr/handler/admin/BaseHandlerApiSupport.java:
##########
@@ -195,26 +196,27 @@ public Map<String, Object> toMap(Map<String, Object>
suppliedMap) {
: map.get(key);
if (o == null) o = pathValues.get(key);
if (o == null && useRequestParams) o = origParams.getParams(key);
+ if (o == null) continue;
// make strings out of as many things as we can now to minimize
differences from
// the standard impls that pass through a
NamedList/SimpleOrderedMap...
Class<?> oClass = o.getClass();
if (oClass.isPrimitive()
|| Number.class.isAssignableFrom(oClass)
|| Character.class.isAssignableFrom(oClass)
|| Boolean.class.isAssignableFrom(oClass)) {
- suppliedMap.put(param, String.valueOf(o));
+ ew.put(param, String.valueOf(o));
} else if (List.class.isAssignableFrom(oClass)
+ && !((List) o).isEmpty()
&& ((List) o).get(0) instanceof String) {
Review Comment:
Already addressed during Part 1 — `if (l.isEmpty() || l.get(0) instanceof
String)` (BaseHandlerApiSupport.java:211) treats empty lists as `String[0]`,
matching the prior invariant. On `main` now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]