This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
The following commit(s) were added to refs/heads/master by this push:
new be0ada2d7 Add test for an empty central directory
be0ada2d7 is described below
commit be0ada2d796c8a29e53a7ec84171290b48804bb0
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Jan 14 07:46:18 2026 -0500
Add test for an empty central directory
---
.../compress/archivers/zip/ZipArchiveInputStreamTest.java | 9 +++++++++
.../commons/compress/archivers/zip/ZipFileTest.java | 5 +++++
.../org/apache/commons/compress/zip/ZipFile-method.zip | Bin 0 -> 109 bytes
3 files changed, 14 insertions(+)
diff --git
a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
index 3da6147aa..df91f36ce 100644
---
a/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
+++
b/src/test/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStreamTest.java
@@ -211,6 +211,15 @@ void testDecompressNextSymbol() throws IOException {
}
}
+ @Test
+ void testEmptyCentralDirectory() throws Exception {
+ try (ZipArchiveInputStream inputStream =
ZipArchiveInputStream.builder()
+
.setURI(getURI("org/apache/commons/compress/zip/ZipFile-method.zip"))
+ .get()) {
+ inputStream.forEach(IOConsumer.noop());
+ }
+ }
+
@Test
void testGetCompressedCountEmptyZip() throws IOException {
try (ZipArchiveInputStream zin =
ZipArchiveInputStream.builder().setByteArray(ArrayUtils.EMPTY_BYTE_ARRAY).get())
{
diff --git
a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
index 7f297c3b0..be29b7835 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
@@ -463,6 +463,11 @@ void testDuplicateEntry() throws Exception {
}
}
+ @Test
+ void testEmptyCentralDirectory() throws Exception {
+ assertThrows(ArchiveException.class, () ->
ZipFile.builder().setPath(getPath("org/apache/commons/compress/zip/ZipFile-method.zip")).get());
+ }
+
/**
* Test entries alignment.
*/
diff --git
a/src/test/resources/org/apache/commons/compress/zip/ZipFile-method.zip
b/src/test/resources/org/apache/commons/compress/zip/ZipFile-method.zip
new file mode 100644
index 000000000..6a1457b92
Binary files /dev/null and
b/src/test/resources/org/apache/commons/compress/zip/ZipFile-method.zip differ