ahmedabu98 commented on code in PR #40980:
URL: https://github.com/apache/beam/pull/40980#discussion_r4555454042


##########
sdks/java/extensions/sorter/src/main/java/org/apache/beam/sdk/extensions/sorter/NativeFileSorter.java:
##########
@@ -204,7 +206,12 @@ public KV<byte[], byte[]> next() {
 
   private @Nullable KV<byte[], byte[]> readKeyValueOrFail(InputStream 
inputStream) {
     try {
-      return readKeyValue(inputStream);
+      @Nullable KV<byte[], byte[]> kv = readKeyValue(inputStream);
+      if (kv == null) {
+        // The block is used up: release its file handle now
+        inputStream.close();

Review Comment:
   `readKeyValue` already handles EOF and returns null, but I hear you. Added a 
try-catch here that closes the stream too



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