Skip to content

[test]Fix resource leak in CompressUtils.gzipCompressFile#8396

Open
cxzl25 wants to merge 1 commit into
apache:masterfrom
cxzl25:fix_gzip
Open

[test]Fix resource leak in CompressUtils.gzipCompressFile#8396
cxzl25 wants to merge 1 commit into
apache:masterfrom
cxzl25:fix_gzip

Conversation

@cxzl25

@cxzl25 cxzl25 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Purpose

The original CompressUtils.gzipCompressFile implementation only closed
streams on the happy path. If an IOException was thrown after the streams
were opened, none of them would be closed, causing a resource leak.

  • Rewrite using try-with-resources so FileInputStream, FileOutputStream,
    and GZIPOutputStream are always closed regardless of whether an exception
    occurs
  • CompressUtils is kept in paimon-core/src/main/java because it is used by
    both HiveCatalogFormatTableITCaseBase (Hive IT) and FormatTableTestBase
    (Spark UT)

Tests

GHA

return result;
}

private static void gzipCompressFile(String src, String dest) throws IOException {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making this helper local to the Hive test leaves another caller broken. paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/sql/FormatTableTestBase.scala still imports org.apache.paimon.utils.CompressUtils and calls CompressUtils.gzipCompressFile, so deleting the core class will make the Spark test module fail to compile. Please either move the helper to a shared test utility used by both modules, or update the Spark test to use its own/local helper as well.

fix

[test] Move gzip helper from core production code to hive test
@cxzl25 cxzl25 changed the title [test] Move gzip helper from core production code to hive test [test]Fix resource leak in CompressUtils.gzipCompressFile Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants