[Git][java-team/zip4j][upstream] New upstream version 2.11.6

Andrius Merkys (@merkys) gitlab at salsa.debian.org
Tue Feb 17 09:44:35 GMT 2026



Andrius Merkys pushed to branch upstream at Debian Java Maintainers / zip4j


Commits:
d11af9f0 by Andrius Merkys at 2026-02-17T03:57:02-05:00
New upstream version 2.11.6
- - - - -


6 changed files:

- .github/workflows/maven.yml
- README.md
- pom.xml
- src/main/java/net/lingala/zip4j/ZipFile.java
- src/test/java/net/lingala/zip4j/CreateZipFileIT.java
- src/test/java/net/lingala/zip4j/ZipFileTest.java


Changes:

=====================================
.github/workflows/maven.yml
=====================================
@@ -13,7 +13,7 @@ jobs:
     steps:
     - uses: actions/checkout at v2
     - name: Set up JDK 11
-      uses: actions/setup-java at v2
+      uses: actions/setup-java at v5
       with:
         java-version: '11'
         distribution: 'temurin'


=====================================
README.md
=====================================
@@ -71,7 +71,7 @@ Zip4j supports JDK 7 as well. In cases where the feature/class from JDK 8 is mis
 <dependency>
     <groupId>net.lingala.zip4j</groupId>
     <artifactId>zip4j</artifactId>
-    <version>2.11.5-SNAPSHOT</version>
+    <version>2.11.6</version>
 </dependency>
 ```
 


=====================================
pom.xml
=====================================
@@ -6,7 +6,7 @@
 
     <groupId>net.lingala.zip4j</groupId>
     <artifactId>zip4j</artifactId>
-    <version>2.11.4</version>
+    <version>2.11.7-SNAPHOT</version>
 
     <name>Zip4j</name>
     <description>Zip4j - A Java library for zip files and streams</description>
@@ -29,28 +29,17 @@
     </licenses>
 
     <properties>
-        <maven.compiler.source>1.7</maven.compiler.source>
-        <maven.compiler.target>1.7</maven.compiler.target>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>1.8</maven.compiler.target>
         <junit.version>4.13.1</junit.version>
         <lombok.version>1.18.8</lombok.version>
-        <assertj.version>2.9.1</assertj.version>
+        <assertj.version>3.27.7</assertj.version>
         <mockito.version>2.28.2</mockito.version>
         <powermock.version>2.0.2</powermock.version>
         <failsafe.plugin.version>3.0.0-M3</failsafe.plugin.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     </properties>
 
-    <distributionManagement>
-        <snapshotRepository>
-            <id>ossrh</id>
-            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
-        </snapshotRepository>
-        <repository>
-            <id>ossrh</id>
-            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
-        </repository>
-    </distributionManagement>
-
     <dependencies>
         <dependency>
             <groupId>junit</groupId>
@@ -126,8 +115,8 @@
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <configuration>
-                    <source>1.7</source>
-                    <target>1.7</target>
+                    <source>1.8</source>
+                    <target>1.8</target>
                 </configuration>
             </plugin>
             <plugin>
@@ -146,7 +135,7 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-source-plugin</artifactId>
-                <version>2.2.1</version>
+                <version>3.4.0</version>
                 <executions>
                     <execution>
                         <id>attach-sources</id>
@@ -160,7 +149,10 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-javadoc-plugin</artifactId>
-                <version>2.9.1</version>
+                <version>3.12.0</version>
+                <configuration>
+                    <doclint>all,-missing</doclint>
+                </configuration>
                 <executions>
                     <execution>
                         <id>attach-javadocs</id>
@@ -185,20 +177,10 @@
                     </execution>
                 </executions>
             </plugin>
-            <plugin>
-                <groupId>org.sonatype.plugins</groupId>
-                <artifactId>nexus-staging-maven-plugin</artifactId>
-                <version>1.6.8</version>
-                <extensions>true</extensions>
-                <configuration>
-                    <serverId>ossrh</serverId>
-                    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
-                    <autoReleaseAfterClose>true</autoReleaseAfterClose>
-                </configuration>
-            </plugin>
             <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
+                <version>6.0.0</version>
                 <extensions>true</extensions>
                 <configuration>
                     <instructions>
@@ -215,6 +197,15 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.sonatype.central</groupId>
+                <artifactId>central-publishing-maven-plugin</artifactId>
+                <version>0.10.0</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <publishingServerId>central</publishingServerId>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 </project>


=====================================
src/main/java/net/lingala/zip4j/ZipFile.java
=====================================
@@ -164,7 +164,7 @@ public class ZipFile implements Closeable {
    * @param parameters     - zip parameters for this file list
    * @param splitArchive   - if archive has to be split or not
    * @param splitLength    - if archive has to be split, then length in bytes at which it has to be split
-   * @throws ZipException
+   * @throws ZipException  - if zip file already exists, or of split length is less than 65536
    */
   public void createSplitZipFile(List<File> filesToAdd, ZipParameters parameters, boolean splitArchive,
                             long splitLength) throws ZipException {
@@ -180,12 +180,42 @@ public class ZipFile implements Closeable {
 
     createNewZipModel();
     zipModel.setSplitArchive(splitArchive);
-    zipModel.setSplitLength(splitLength);
+    zipModel.setSplitLength(splitArchive ? splitLength : -1);
 
     new AddFilesToZipTask(zipModel, password, headerWriter, buildAsyncParameters()).execute(
         new AddFilesToZipTaskParameters(filesToAdd, parameters, buildConfig()));
   }
 
+  /**
+   * Creates a split zip file from the input stream if splitArchive flag is set to true. If this flag is set to false
+   * this method behaves as creating a regular (non-split) zip file. Split Length has to be more than 65536 bytes
+   *
+   * @param inputStream stream to add to the zip file
+   * @param parameters zip parameters to consider when creating the zip file
+   * @param splitArchive true if zip file has to be split, false otherwise
+   * @param splitLength length in bytes at which the zip file has to be split
+   * @throws ZipException if zip file already exists, or of split length is less than 65536
+   */
+  public void createSplitZipFile(InputStream inputStream, ZipParameters parameters, boolean splitArchive,
+                                 long splitLength) throws ZipException {
+
+    if (zipFile.exists()) {
+      throw new ZipException("zip file: " + zipFile
+              + " already exists. To add files to existing zip file use addFile method");
+    }
+
+    if (inputStream == null) {
+      throw new ZipException("input stream is null, cannot create zip file");
+    }
+
+    createNewZipModel();
+    zipModel.setSplitArchive(splitArchive);
+    zipModel.setSplitLength(splitArchive ? splitLength : -1);
+
+    new AddStreamToZipTask(zipModel, password, headerWriter, buildAsyncParameters()).execute(
+            new AddStreamToZipTaskParameters(inputStream, parameters, buildConfig()));
+  }
+
   /**
    * Creates a zip file and adds the files/folders from the specified folder to the zip file.
    * This method does the same functionality as in addFolder method except that this method


=====================================
src/test/java/net/lingala/zip4j/CreateZipFileIT.java
=====================================
@@ -8,6 +8,7 @@ import net.lingala.zip4j.model.enums.AesKeyStrength;
 import net.lingala.zip4j.model.enums.CompressionLevel;
 import net.lingala.zip4j.model.enums.CompressionMethod;
 import net.lingala.zip4j.model.enums.EncryptionMethod;
+import net.lingala.zip4j.testutils.TestUtils;
 import net.lingala.zip4j.testutils.ZipFileVerifier;
 import net.lingala.zip4j.util.FileUtils;
 import net.lingala.zip4j.util.InternalZipConstants;
@@ -19,6 +20,9 @@ import org.junit.rules.ExpectedException;
 import java.io.File;
 import java.io.FilenameFilter;
 import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -281,6 +285,66 @@ public class CreateZipFileIT extends AbstractIT {
     verifyZipFileByExtractingAllFiles(generatedZipFile, outputFolder, 3);
   }
 
+  @Test
+  public void testCreateZipFileFromStreamThrowsExceptionIfZipFileExists() throws IOException {
+    try (ZipFile zipFile = new ZipFile(generatedZipFile)) {
+      zipFile.addFile(TestUtils.getTestFileFromResources("sample.pdf"));
+    }
+
+    expectedException.expect(ZipException.class);
+    expectedException.expectMessage("zip file: " + generatedZipFile
+            + " already exists. To add files to existing zip file use addFile method");
+
+    try (ZipFile zipFile = new ZipFile(generatedZipFile)) {
+      zipFile.createSplitZipFile((InputStream) null, new ZipParameters(), true, 512000);
+    }
+  }
+
+  @Test
+  public void testCreateZipFileFromStreamCreatesSplitFileSuccessfully() throws IOException {
+    Path fileToAdd = TestUtils.getTestFileFromResources("file_PDF_1MB.pdf").toPath();
+    ZipParameters zipParameters = new ZipParameters();
+    zipParameters.setFileNameInZip(fileToAdd.getFileName().toString());
+
+    try (ZipFile zipFile = new ZipFile(generatedZipFile);
+         InputStream inputStream = Files.newInputStream(fileToAdd)) {
+      zipFile.createSplitZipFile(inputStream, zipParameters, true, 512000);
+    }
+
+    verifyZipFileByExtractingAllFiles(generatedZipFile, null, outputFolder, 1);
+    verifySplitZip(generatedZipFile, 2, 512000);
+  }
+
+  @Test
+  public void testCreateZipFileFromStreamCreatesNonSplitFileWhenFlagIsFalse() throws IOException {
+    Path fileToAdd = TestUtils.getTestFileFromResources("file_PDF_1MB.pdf").toPath();
+    ZipParameters zipParameters = new ZipParameters();
+    zipParameters.setFileNameInZip(fileToAdd.getFileName().toString());
+
+    try (ZipFile zipFile = new ZipFile(generatedZipFile);
+         InputStream inputStream = Files.newInputStream(fileToAdd)) {
+      zipFile.createSplitZipFile(inputStream, zipParameters, false, 512000);
+    }
+
+    verifyZipFileByExtractingAllFiles(generatedZipFile, null, outputFolder, 1);
+    verifySplitZip(generatedZipFile, 1, 512000);
+  }
+
+  @Test
+  public void testCreateZipFileFromStreamCreatesNonSplitFileWhenSplitLengthIsLowerThanFileLength() throws IOException {
+    Path fileToAdd = TestUtils.getTestFileFromResources("sample.pdf").toPath();
+    ZipParameters zipParameters = new ZipParameters();
+    zipParameters.setFileNameInZip(fileToAdd.getFileName().toString());
+
+    try (ZipFile zipFile = new ZipFile(generatedZipFile);
+         InputStream inputStream = Files.newInputStream(fileToAdd)) {
+      zipFile.createSplitZipFile(inputStream, zipParameters, true, 512000);
+    }
+
+    verifyZipFileByExtractingAllFiles(generatedZipFile, null, outputFolder, 1);
+    verifySplitZip(generatedZipFile, 1, 512000);
+  }
+
   private void verifySplitZip(File zipFile, int numberOfExpectedSplitFiles, long splitLength) throws ZipException {
     assertNumberOfSplitFile(zipFile, numberOfExpectedSplitFiles);
     assertSplitFileSizes(zipFile, numberOfExpectedSplitFiles, splitLength);


=====================================
src/test/java/net/lingala/zip4j/ZipFileTest.java
=====================================
@@ -12,7 +12,9 @@ import org.junit.rules.ExpectedException;
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.Collections;
+import java.util.List;
 
 import static net.lingala.zip4j.util.InternalZipConstants.MIN_BUFF_SIZE;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -68,7 +70,7 @@ public class ZipFileTest {
     expectedException.expect(ZipException.class);
     expectedException.expectMessage("input file List is null, cannot create zip file");
 
-    zipFile.createSplitZipFile(null, new ZipParameters(), true, 10000);
+    zipFile.createSplitZipFile((List<File>) null, new ZipParameters(), true, 10000);
   }
 
   @Test
@@ -79,6 +81,14 @@ public class ZipFileTest {
     zipFile.createSplitZipFile(Collections.<File>emptyList(), new ZipParameters(), true, 10000);
   }
 
+  @Test
+  public void testCreateZipFileFromStreamThrowsExceptionIfStreamIsNull() throws IOException {
+    expectedException.expect(ZipException.class);
+    expectedException.expectMessage("input stream is null, cannot create zip file");
+
+    zipFile.createSplitZipFile((InputStream) null, new ZipParameters(), true, 512000);
+  }
+
   @Test
   public void testCreateZipFileFromFolderThrowsExceptionWheFolderIsNull() throws ZipException {
     expectedException.expect(ZipException.class);



View it on GitLab: https://salsa.debian.org/java-team/zip4j/-/commit/d11af9f0debd06ed1293e72f5b4f6ffc0c45f300

-- 
View it on GitLab: https://salsa.debian.org/java-team/zip4j/-/commit/d11af9f0debd06ed1293e72f5b4f6ffc0c45f300
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20260217/ab2ac665/attachment.htm>


More information about the pkg-java-commits mailing list