You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by da...@apache.org on 2026/04/17 00:47:45 UTC
(hudi) branch master updated: fix: fix BufferedReader resource leak in FileIOUtils.readAsUTFStringLines (#18470)
This is an automated email from the ASF dual-hosted git repository.
danny0405 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git
The following commit(s) were added to refs/heads/master by this push:
new 2b33f5d407d6 fix: fix BufferedReader resource leak in FileIOUtils.readAsUTFStringLines (#18470)
2b33f5d407d6 is described below
commit 2b33f5d407d6371fbe74dc3e304cc92ef45961c4
Author: mailtoboggavarapu-coder <ma...@gmail.com>
AuthorDate: Thu Apr 16 20:47:38 2026 -0400
fix: fix BufferedReader resource leak in FileIOUtils.readAsUTFStringLines (#18470)
---
.../src/main/java/org/apache/hudi/io/util/FileIOUtils.java | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/hudi-io/src/main/java/org/apache/hudi/io/util/FileIOUtils.java b/hudi-io/src/main/java/org/apache/hudi/io/util/FileIOUtils.java
index 7262eb106983..bf50d6a7b61a 100644
--- a/hudi-io/src/main/java/org/apache/hudi/io/util/FileIOUtils.java
+++ b/hudi-io/src/main/java/org/apache/hudi/io/util/FileIOUtils.java
@@ -43,7 +43,6 @@ import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
@@ -94,11 +93,13 @@ public class FileIOUtils {
* @return String lines in a list.
*/
public static List<String> readAsUTFStringLines(InputStream input) {
- List<String> lines = new ArrayList<>();
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8));
- lines = bufferedReader.lines().collect(Collectors.toList());
- closeQuietly(bufferedReader);
- return lines;
+ try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8))) {
+ return bufferedReader.lines().collect(Collectors.toList());
+ } catch (IOException e) {
+ // Note: stream errors from lines().collect(...) surface as UncheckedIOException and bypass this block.
+ // This catch handles IOException from close() during try-with-resources teardown.
+ throw new RuntimeException(e);
+ }
}
public static void copy(InputStream inputStream, OutputStream outputStream) throws IOException {