Browse Source

bugfix => 修复运行时,rewrite zip文件后导致的启动类加载不到问题

邓沙利文 4 years ago
parent
commit
2f1a9f80b1

+ 2 - 9
class-winter-core/src/main/java/winter/com/ideaaedi/classwinter/util/JarUtil.java

@@ -278,19 +278,12 @@ public final class JarUtil {
             ZipEntry zipEntry = entries.nextElement();
             zipEntryList.add(zipEntry);
         }
-        
-        Map<String, byte[]> originBytesMap = new HashMap<>(64);
-        for (ZipEntry zipEntry : zipEntryList) {
-            String zipEntryName = zipEntry.getName();
-            byte[] originBytes = IOUtil.toBytes(zipFile.getInputStream(zipEntry));
-            originBytesMap.put(zipEntryName, originBytes);
-        }
         // zipFile.getName()形如:   /abc/my-project.jar   /abc/my-project.war  /abc/my-projectzip
-        try (FileOutputStream fos = new FileOutputStream(zipFilePath, false);
+        try (FileOutputStream fos = new FileOutputStream(zipFilePath, true);
              ZipOutputStream zos = new ZipOutputStream(fos)) {
             for (ZipEntry zipEntry : zipEntryList) {
                 String zipEntryName = zipEntry.getName();
-                byte[] originBytes = originBytesMap.get(zipEntryName);
+                byte[] originBytes = IOUtil.toBytes(zipFile.getInputStream(zipEntry));
                 byte[] replaceBytes = replacerMap.get(zipEntryName);
                 if (replacerMap.containsKey(zipEntryName) && replaceBytes != null) {
                     // 覆盖