gnodet-bot commented on code in PR #27331:
URL: https://github.com/apache/camel/pull/27331#discussion_r4177139002


##########
components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java:
##########
@@ -713,6 +715,28 @@ private boolean isCreateNewURL(Exchange exchange) {
         return create;
     }
 
+    /**
+     * The body as a stream for the request entity. A Map or a List (a body 
unmarshalled from JSON, or built as a map)
+     * cannot become one, and the converter's message only names the 
conversion: say what to do (CAMEL-25309).
+     */
+    private static InputStream mandatoryBodyStream(Exchange exchange, Message 
in) throws InvalidPayloadException {
+        try {
+            return in.getMandatoryBody(InputStream.class);
+        } catch (InvalidPayloadException e) {
+            Object body = in.getBody();
+            if (body instanceof Map || body instanceof Collection) {
+                InvalidPayloadException answer = new InvalidPayloadException(
+                        exchange, InputStream.class, in,
+                        "a " + (body instanceof Map ? "Map" : "List")
+                                                         + " is not an HTTP 
request body: marshal it to JSON first "

Review Comment:
   💡 **Nit:** `Collection` covers `List`, `Set`, `Queue`, etc., but the hint 
always says "List" for any non-Map Collection. A `Set` body (unlikely but 
possible) would get "a List is not an HTTP request body" — slightly misleading.
   
   Since the realistic scenario after `unmarshal: json` is always `List`, this 
is cosmetic, but a precise label is easy:
   
   ```suggestion
                           "a " + (body instanceof Map ? "Map" : body 
instanceof List ? "List" : "Collection")
   ```
   
   This would require importing `java.util.List` (already indirectly 
available). Not blocking — the current message is good enough for the 99% case.



-- 
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]

Reply via email to