yihua commented on code in PR #18470:
URL: https://github.com/apache/hudi/pull/18470#discussion_r3037185240


##########
hudi-io/src/main/java/org/apache/hudi/io/util/FileIOUtils.java:
##########
@@ -94,11 +94,12 @@ public static String readAsUTFString(InputStream input, int 
length) throws IOExc
    * @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) {

Review Comment:
   🤖 Just to flag the subtle scope of this catch: 
`bufferedReader.lines().collect(...)` doesn't actually throw a checked 
`IOException` — any I/O error during stream consumption surfaces as 
`UncheckedIOException` (a `RuntimeException`) and bypasses this block. The 
catch is really there to handle `IOException` thrown by `close()` during 
try-with-resources teardown, which the compiler requires since the method 
doesn't declare `throws IOException`. The behavior is correct, but it might be 
worth a short comment explaining that, so future readers aren't surprised when 
read errors don't land here.



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