This is an automated email from the ASF dual-hosted git repository. garydgregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit e85942d044742981b68fe6b82eca03a8caa285b7 Author: Gary Gregory <[email protected]> AuthorDate: Mon Aug 17 07:11:48 2026 -0400 Sort members. --- .../gzip/GzipCompressorInputStreamTest.java | 50 +++++++++++----------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/test/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStreamTest.java b/src/test/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStreamTest.java index 4b218a147..06ef3f232 100644 --- a/src/test/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStreamTest.java +++ b/src/test/java/org/apache/commons/compress/compressors/gzip/GzipCompressorInputStreamTest.java @@ -59,6 +59,31 @@ */ class GzipCompressorInputStreamTest { + private static byte[] gzipMemberWithFileName(final byte[] fileNameField) throws IOException { + final ByteArrayOutputStream bos = new ByteArrayOutputStream(); + bos.write(0x1f); + bos.write(0x8b); // magic + bos.write(0x08); // deflate + bos.write(0x08); // FLG: FNAME present + bos.write(new byte[] { 0, 0, 0, 0 }); // MTIME + bos.write(0x00); // XFL + bos.write(0xff); // OS unknown + bos.write(fileNameField); + bos.write(0x00); // NUL terminator for FNAME + final ByteArrayOutputStream deflated = new ByteArrayOutputStream(); + try (DeflaterOutputStream dos = new DeflaterOutputStream(deflated, new Deflater(Deflater.DEFAULT_COMPRESSION, true))) { + // empty payload + } + bos.write(deflated.toByteArray()); + final long crc = new CRC32().getValue(); + bos.write((int) (crc & 0xff)); + bos.write((int) (crc >> 8 & 0xff)); + bos.write((int) (crc >> 16 & 0xff)); + bos.write((int) (crc >> 24 & 0xff)); + bos.write(new byte[] { 0, 0, 0, 0 }); // ISIZE + return bos.toByteArray(); + } + @TempDir Path tempDir; @@ -361,31 +386,6 @@ void testReadGzipFileCreatedByCli() throws IOException { } } - private static byte[] gzipMemberWithFileName(final byte[] fileNameField) throws IOException { - final ByteArrayOutputStream bos = new ByteArrayOutputStream(); - bos.write(0x1f); - bos.write(0x8b); // magic - bos.write(0x08); // deflate - bos.write(0x08); // FLG: FNAME present - bos.write(new byte[] { 0, 0, 0, 0 }); // MTIME - bos.write(0x00); // XFL - bos.write(0xff); // OS unknown - bos.write(fileNameField); - bos.write(0x00); // NUL terminator for FNAME - final ByteArrayOutputStream deflated = new ByteArrayOutputStream(); - try (DeflaterOutputStream dos = new DeflaterOutputStream(deflated, new Deflater(Deflater.DEFAULT_COMPRESSION, true))) { - // empty payload - } - bos.write(deflated.toByteArray()); - final long crc = new CRC32().getValue(); - bos.write((int) (crc & 0xff)); - bos.write((int) (crc >> 8 & 0xff)); - bos.write((int) (crc >> 16 & 0xff)); - bos.write((int) (crc >> 24 & 0xff)); - bos.write(new byte[] { 0, 0, 0, 0 }); // ISIZE - return bos.toByteArray(); - } - /** * A member whose FNAME field cannot be round-tripped through the configured charset must fail with a CompressorException rather than a raw * IllegalArgumentException escaping the IOException contract of read().
