davsclaus commented on code in PR #30918:
URL: https://github.com/apache/camel/pull/30918#discussion_r4717098504


##########
components/camel-parquet-avro/src/main/java/org/apache/camel/dataformat/parquet/avro/ParquetAvroDataFormat.java:
##########
@@ -116,12 +129,36 @@ public void marshal(Exchange exchange, Object graph, 
OutputStream stream) throws
                 .withCompressionCodec(compressionCodecName)
                 .withWriteMode(OVERWRITE)
                 .build()) {
-            for (Object grapElem : list) {
+            for (Object grapElem : records) {
                 writer.write(grapElem);
             }
         }
     }
 
+    /**
+     * The records to write: a List as is, the elements of another Iterable 
(such as a Set), of an array, of an Iterator
+     * or of a Stream, or the body itself as a single record. A Path is a 
single value, although it is an Iterable of
+     * its names.
+     */
+    private static List<?> toRecords(Object graph) {
+        if (graph instanceof List<?> list) {
+            return list;
+        }
+        List<Object> records = new ArrayList<>();
+        if (graph instanceof Iterable<?> iterable && !(graph instanceof Path)) 
{
+            iterable.forEach(records::add);
+        } else if (graph instanceof Object[] array) {
+            Collections.addAll(records, array);
+        } else if (graph instanceof Iterator<?> iterator) {
+            iterator.forEachRemaining(records::add);
+        } else if (graph instanceof Stream<?> stream) {
+            stream.forEach(records::add);

Review Comment:
   Fixed in 93acc56: the Stream body is read in a try-with-resources, and 
streamIsClosed checks that it gets closed.
   
   _Claude Code on behalf of Claus Ibsen_



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