This is an automated email from the ASF dual-hosted git repository.
JingsongLi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 564542f50a [test] Fix resource leak in CompressUtils.gzipCompressFile
(#8396)
564542f50a is described below
commit 564542f50a1121cc7bc0cf61ba87ac0da5368fd4
Author: cxzl25 <[email protected]>
AuthorDate: Fri Jul 3 20:15:02 2026 +0800
[test] Fix resource leak in CompressUtils.gzipCompressFile (#8396)
---
.../java/org/apache/paimon/utils/CompressUtils.java | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git
a/paimon-core/src/main/java/org/apache/paimon/utils/CompressUtils.java
b/paimon-core/src/main/java/org/apache/paimon/utils/CompressUtils.java
index 2a4aa71b3d..dae12bd715 100644
--- a/paimon-core/src/main/java/org/apache/paimon/utils/CompressUtils.java
+++ b/paimon-core/src/main/java/org/apache/paimon/utils/CompressUtils.java
@@ -27,20 +27,14 @@ import java.util.zip.GZIPOutputStream;
public class CompressUtils {
public static void gzipCompressFile(String src, String dest) throws
IOException {
- FileInputStream fis = new FileInputStream(src);
- FileOutputStream fos = new FileOutputStream(dest);
- GZIPOutputStream gzipOs = new GZIPOutputStream(fos);
- byte[] buffer = new byte[1024];
- int bytesRead;
- while (true) {
- bytesRead = fis.read(buffer);
- if (bytesRead == -1) {
- fis.close();
- gzipOs.close();
- return;
+ try (FileInputStream fis = new FileInputStream(src);
+ FileOutputStream fos = new FileOutputStream(dest);
+ GZIPOutputStream gzipOs = new GZIPOutputStream(fos)) {
+ byte[] buffer = new byte[1024];
+ int bytesRead;
+ while ((bytesRead = fis.read(buffer)) != -1) {
+ gzipOs.write(buffer, 0, bytesRead);
}
-
- gzipOs.write(buffer, 0, bytesRead);
}
}
}