Repository navigation
fix(lib-storage): accept gzip/bz2 aliases on read and case-fold compress names safely - #1520
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two compression-handling asymmetries in the storage module, both affecting which
compressspellings work and whether case conversion is locale-safe:StorageWriterUtil.createWriternormalizesgzip → gzandbz2 → bzip2, butStorageReaderUtil.createBufferedReaderuppercased the raw config value and handed it toCompressorStreamFactory, which only knows canonical names (gz,bzip2, …). Acompress: "gzip"job written by the writer could never be read back on the read side.toLowerCase()/toUpperCase()without a locale mangle ASCII names on e.g.tr_TRJVMs ("ZIP".toLowerCase()→"zıp"), silently breaking thezipdispatch, the factory call, and the suffix map lookup inFileHelper.getCompressFileSuffix.What type of change is this?
Changes
createBufferedReader: normalizegzip → gz,bz2 → bzip2(mirroringcreateWriter), then dispatch on the canonical lowercase name and pass it directly toCompressorStreamFactory(zip/lzo still handled by the module's own streams).createWriterandFileHelper.getCompressFileSuffix: all compress-name case conversions now useLocale.ROOT.Motivation and Context
Reported against
lib/addax-storageby a module code review; verified empirically against commons-compress 1.27.1 (the pinned version), which throwsCompressor: ... not foundforgzip/bz2/GZIP/BZ2spellings.How has this been tested?
mvn -DskipTests compile -pl :addax-storage(JDK 17) — clean.gz,gzip,GZIP,bz2,bzip2,zip,lzo,xz,zstdon the read path;-Duser.language=tr -Duser.country=TRcasing behavior.Checklist (required)