Abacn commented on code in PR #26259:
URL: https://github.com/apache/beam/pull/26259#discussion_r1191353011


##########
sdks/java/core/src/main/java/org/apache/beam/sdk/coders/IterableLikeCoder.java:
##########
@@ -103,30 +102,27 @@ public void encode(IterableT iterable, OutputStream 
outStream)
     if (iterable == null) {
       throw new CoderException("cannot encode a null " + iterableName);
     }
-    DataOutputStream dataOutStream = new DataOutputStream(outStream);
     if (iterable instanceof Collection) {
       // We can know the size of the Iterable.  Use an encoding with a
       // leading size field, followed by that many elements.
       Collection<T> collection = (Collection<T>) iterable;
-      dataOutStream.writeInt(collection.size());
+      BitConverters.writeBigEndianInt(collection.size(), outStream);
       for (T elem : collection) {
-        elementCoder.encode(elem, dataOutStream);
+        elementCoder.encode(elem, outStream);
       }
     } else {
       // We don't know the size without traversing it so use a fixed size 
buffer
       // and encode as many elements as possible into it before outputting the 
size followed
       // by the elements.
-      dataOutStream.writeInt(-1);
+      BitConverters.writeBigEndianInt(-1, outStream);
       BufferedElementCountingOutputStream countingOutputStream =
-          new BufferedElementCountingOutputStream(dataOutStream);
+          new BufferedElementCountingOutputStream(outStream);
       for (T elem : iterable) {
         countingOutputStream.markElementStart();
         elementCoder.encode(elem, countingOutputStream);
       }
       countingOutputStream.finish();
     }
-    // Make sure all our output gets pushed to the underlying outStream.
-    dataOutStream.flush();

Review Comment:
   Is there any concern removing this? There was a comment saying "make sure to 
flush"



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