Include directory entries when copying loader into a Boot archive

See gh-8816
pull/7469/head
Andy Wilkinson 8 years ago
parent 15d6c9d5c7
commit 2f64cdfa98

@ -115,6 +115,9 @@ class BootZipCopyAction implements CopyAction {
try (ZipInputStream in = new ZipInputStream(getClass()
.getResourceAsStream("/META-INF/loader/spring-boot-loader.jar"))) {
while ((entry = in.getNextEntry()) != null) {
if (entry.isDirectory() && !entry.getName().startsWith("META-INF/")) {
writeDirectory(entry, out);
}
if (entry.getName().endsWith(".class")) {
writeClass(entry, in, out);
}
@ -125,13 +128,21 @@ class BootZipCopyAction implements CopyAction {
}
}
private void writeDirectory(ZipEntry entry, ZipOutputStream out) throws IOException {
if (!this.preserveFileTimestamps) {
entry.setTime(GUtil.CONSTANT_TIME_FOR_ZIP_ENTRIES);
}
out.putNextEntry(entry);
out.closeEntry();
}
private void writeClass(ZipEntry entry, ZipInputStream in, ZipOutputStream out)
throws IOException {
byte[] buffer = new byte[4096];
if (!this.preserveFileTimestamps) {
entry.setTime(GUtil.CONSTANT_TIME_FOR_ZIP_ENTRIES);
}
out.putNextEntry(entry);
byte[] buffer = new byte[4096];
int read;
while ((read = in.read(buffer)) > 0) {
out.write(buffer, 0, read);

@ -132,6 +132,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
assertThat(jarFile.getEntry(
"org/springframework/boot/loader/LaunchedURLClassLoader.class"))
.isNotNull();
assertThat(jarFile.getEntry("org/springframework/boot/loader/")).isNotNull();
}
}
@ -146,6 +147,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
assertThat(jarFile.getEntry(
"org/springframework/boot/loader/LaunchedURLClassLoader.class"))
.isNotNull();
assertThat(jarFile.getEntry("org/springframework/boot/loader/")).isNotNull();
}
}

Loading…
Cancel
Save