Pārlūkot izejas kodu

修改ZipWriter接口,去掉@NotNull注释,增加防空判断,避免打包异常

Signed-off-by: luoshi <luoshi@qmth.com.cn>
luoshi 3 gadi atpakaļ
vecāks
revīzija
7e11df71e2

+ 10 - 5
tools-common/src/main/java/com/qmth/boot/tools/io/ZipWriter.java

@@ -1,6 +1,5 @@
 package com.qmth.boot.tools.io;
 
-import com.sun.istack.internal.NotNull;
 import org.apache.commons.lang3.StringUtils;
 
 import java.io.*;
@@ -44,6 +43,9 @@ public class ZipWriter {
     }
 
     private ZipWriter(OutputStream outputStream) {
+        if (outputStream == null) {
+            throw new IllegalArgumentException("OutputStream should not be null");
+        }
         this.ous = new ZipOutputStream(outputStream);
     }
 
@@ -54,9 +56,12 @@ public class ZipWriter {
      * @param path
      * @throws IOException
      */
-    public void write(@NotNull InputStream inputStream, @NotNull String... path) throws IOException {
+    public void write(InputStream inputStream, String... path) throws IOException {
+        if (inputStream == null) {
+            throw new IllegalArgumentException("InputStream should not be null");
+        }
         if (path == null || path.length == 0) {
-            throw new RuntimeException("path should not be empty");
+            throw new IllegalArgumentException("path should not be empty");
         }
         ous.putNextEntry(new ZipEntry(StringUtils.join(path, File.separator)));
         IOUtils.copy(inputStream, ous);
@@ -70,7 +75,7 @@ public class ZipWriter {
      * @param path
      * @throws IOException
      */
-    public void write(@NotNull File file, @NotNull String... path) throws IOException {
+    public void write(File file, String... path) throws IOException {
         write(new FileInputStream(file), path);
     }
 
@@ -81,7 +86,7 @@ public class ZipWriter {
      * @param path
      * @throws IOException
      */
-    public void write(@NotNull byte[] data, @NotNull String... path) throws IOException {
+    public void write(byte[] data, String... path) throws IOException {
         write(new ByteArrayInputStream(data), path);
     }