From 5f7321a7a44950e637d831423a2e58c5d18ab6a2 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Thu, 14 Dec 2023 08:54:59 +0100 Subject: [PATCH] Fix double creation of Manifest file --- .../boot/jarmode/layertools/ExtractJarCommand.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/main/java/org/springframework/boot/jarmode/layertools/ExtractJarCommand.java b/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/main/java/org/springframework/boot/jarmode/layertools/ExtractJarCommand.java index 2a90058f484b..05bf3e679fef 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/main/java/org/springframework/boot/jarmode/layertools/ExtractJarCommand.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/main/java/org/springframework/boot/jarmode/layertools/ExtractJarCommand.java @@ -37,6 +37,7 @@ import org.springframework.boot.jarmode.layertools.JarStructure.Entry; import org.springframework.util.Assert; import org.springframework.util.StreamUtils; +import org.springframework.util.StringUtils; /** * Hacking. @@ -89,11 +90,11 @@ protected void run(Map options, List parameters) { } else { JarEntry jarEntry = createJarEntry(resolvedEntry, zipEntry); - output.putNextEntry(jarEntry); - if (!zipEntry.isDirectory()) { + if (jarEntry != null) { + output.putNextEntry(jarEntry); StreamUtils.copy(zip, output); + output.closeEntry(); } - output.closeEntry(); } } zipEntry = zip.getNextEntry(); @@ -144,6 +145,9 @@ private void write(ZipInputStream zip, ZipEntry entry, Path destination, String } private static JarEntry createJarEntry(Entry resolvedEntry, ZipEntry originalEntry) { + if (!StringUtils.hasLength(resolvedEntry.location())) { + return null; + } JarEntry jarEntry = new JarEntry(resolvedEntry.location()); FileTime lastModifiedTime = originalEntry.getLastModifiedTime(); if (lastModifiedTime != null) {