Copilot commented on code in PR #4222:
URL: https://github.com/apache/solr/pull/4222#discussion_r2978016752
##########
solr/core/src/java/org/apache/solr/handler/admin/BaseHandlerApiSupport.java:
##########
@@ -134,7 +133,7 @@ private static void wrapParams(
final Map<String, String> pathValues = req.getPathTemplateValues();
final Map<String, Object> map =
co == null || !(co.getCommandData() instanceof Map)
- ? Collections.singletonMap("", co.getCommandData())
+ ? Map.of("", co.getCommandData())
: co.getDataMap();
Review Comment:
`wrapParams` now wraps non-map command data using `Map.of("",
co.getCommandData())`. `Map.of` rejects null values, but `CommandOperation` can
legitimately have `commandData == null` (e.g., commands with no payload /
explicit JSON null), which would throw NPE here and break the API. Consider
using a mutable map (e.g., `new HashMap<>(1)` + `put`) or another construction
that permits a null value for this sentinel entry.
##########
solr/core/src/java/org/apache/solr/handler/export/ExportWriter.java:
##########
@@ -180,14 +177,10 @@ protected void writeException(Exception e, PushWriter w,
boolean logException)
throws IOException {
w.writeMap(
mw -> {
- mw.put("responseHeader", singletonMap("status", 400))
+ mw.put("responseHeader", Map.of("status", 400))
.put(
"response",
- Map.of(
- "numFound",
- 0,
- "docs",
- singletonList(singletonMap("EXCEPTION",
e.getMessage()))));
+ Map.of("numFound", 0, "docs", List.of(Map.of("EXCEPTION",
e.getMessage()))));
});
Review Comment:
`writeException` builds the error response using `Map.of("EXCEPTION",
e.getMessage())`. `Map.of` does not permit null values, but many exceptions can
have a null message; that would cause a secondary NPE while trying to report
the original error. Consider coercing the message to a non-null string (e.g.,
`Objects.toString(e.getMessage(), "")`) or using a map implementation that
allows null values for this field.
--
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]