Skip to content

fix(lib-storage): accept gzip/bz2 aliases on read and case-fold compress names safely - #1520

Merged
wgzhao merged 1 commit into
masterfrom
fix/compress-alias-symmetry
Sep 3, 2026
Merged

wgzhao merged 1 commit into
masterfrom
fix/compress-alias-symmetry

Conversation

@wgzhao

@wgzhao wgzhao commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Summary

Two compression-handling asymmetries in the storage module, both affecting which compress spellings work and whether case conversion is locale-safe:

  1. Reader cannot accept the aliases the writer produces. StorageWriterUtil.createWriter normalizes gzip → gz and bz2 → bzip2, but StorageReaderUtil.createBufferedReader uppercased the raw config value and handed it to CompressorStreamFactory, which only knows canonical names (gz, bzip2, …). A compress: "gzip" job written by the writer could never be read back on the read side.
  2. Locale-sensitive case folding. toLowerCase()/toUpperCase() without a locale mangle ASCII names on e.g. tr_TR JVMs ("ZIP".toLowerCase() → "zıp"), silently breaking the zip dispatch, the factory call, and the suffix map lookup in FileHelper.getCompressFileSuffix.

What type of change is this?

  • Bugfix

Changes

  • createBufferedReader: normalize gzip → gz, bz2 → bzip2 (mirroring createWriter), then dispatch on the canonical lowercase name and pass it directly to CompressorStreamFactory (zip/lzo still handled by the module's own streams).
  • createWriter and FileHelper.getCompressFileSuffix: all compress-name case conversions now use Locale.ROOT.

Motivation and Context

Reported against lib/addax-storage by a module code review; verified empirically against commons-compress 1.27.1 (the pinned version), which throws Compressor: ... not found for gzip/bz2/GZIP/BZ2 spellings.

How has this been tested?

  • mvn -DskipTests compile -pl :addax-storage (JDK 17) — clean.
  • Manual trace: gz, gzip, GZIP, bz2, bzip2, zip, lzo, xz, zstd on the read path; -Duser.language=tr -Duser.country=TR casing behavior.
  • No unit tests added; per project convention, verification happens in the build environment manually.

Checklist (required)

  • I have read the project's contributing guidelines and code of conduct.
  • My change includes appropriate tests (if applicable). — n/a, manual verification per project convention
  • I ran a local build and fixed any compilation issues.
  • I updated or added documentation if needed (README, docs/ or docs/en/). — n/a
  • I updated CHANGELOG.md when appropriate.
  • I have not added any secrets or credentials.
  • I have checked for sensitive or personal data in this PR.

…ess names safely

why: the reader path uppercased the compress name and handed it to commons-compress, which only knows the canonical gz/bzip2 spellings, so the gzip/bz2 aliases the write side normalizes could never be read back; toLowerCase/toUpperCase without an explicit locale mangles ASCII names ("ZIP" -> "zıp" under tr_TR) and breaks both dispatch and suffix lookup.

what: normalize gzip->gz and bz2->bzip2 before dispatch in createBufferedReader (mirroring createWriter), pass the canonical lowercase name to CompressorStreamFactory, and use Locale.ROOT for every compress-name case conversion in the reader/writer utils and FileHelper.getCompressFileSuffix.

impact: a compress value written by the writer now reads back with the same spelling; Turkish-locale JVMs keep routing zip/gzip/gz correctly.
@wgzhao
wgzhao merged commit 4cc383a into master Sep 3, 2026
2 checks passed
@wgzhao
wgzhao deleted the fix/compress-alias-symmetry branch September 4, 2026 00:30
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.

1 participant