mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Merge branch '4.0.x' into 4.1.x
Closes gh-51606
This commit is contained in:
+6
-6
@@ -248,7 +248,7 @@ class ExtractCommand extends Command {
|
||||
Manifest manifest = jarStructure.createLauncherManifest((library) -> librariesDirectory + library);
|
||||
mkdirs(file.getParentFile());
|
||||
try (JarOutputStream output = new JarOutputStream(new FileOutputStream(file))) {
|
||||
ManfiestWriter manfiestWriter = (sourceJarFile) -> {
|
||||
ManifestWriter manifestWriter = (sourceJarFile) -> {
|
||||
JarEntry entry = createJarEntry(JarFile.MANIFEST_NAME,
|
||||
sourceJarFile.getJarEntry(JarFile.MANIFEST_NAME));
|
||||
output.putNextEntry(entry);
|
||||
@@ -257,7 +257,7 @@ class ExtractCommand extends Command {
|
||||
};
|
||||
EnumSet<Type> allowedTypes = EnumSet.of(Type.APPLICATION_CLASS_OR_RESOURCE, Type.META_INF);
|
||||
Set<String> writtenEntries = new HashSet<>();
|
||||
withJarEntries(this.context.getArchiveFile(), manfiestWriter, ((stream, jarEntry) -> {
|
||||
withJarEntries(this.context.getArchiveFile(), manifestWriter, ((stream, jarEntry) -> {
|
||||
Entry entry = jarStructure.resolve(jarEntry);
|
||||
if (entry != null && allowedTypes.contains(entry.type()) && StringUtils.hasLength(entry.location())) {
|
||||
JarEntry newJarEntry = createJarEntry(entry.location(), jarEntry);
|
||||
@@ -346,11 +346,11 @@ class ExtractCommand extends Command {
|
||||
withJarEntries(file, null, callback);
|
||||
}
|
||||
|
||||
private static void withJarEntries(File file, @Nullable ManfiestWriter manfiestWriter, ThrowingConsumer callback)
|
||||
private static void withJarEntries(File file, @Nullable ManifestWriter manifestWriter, ThrowingConsumer callback)
|
||||
throws IOException {
|
||||
try (JarFile jarFile = new JarFile(file)) {
|
||||
if (manfiestWriter != null) {
|
||||
manfiestWriter.writeManifest(jarFile);
|
||||
if (manifestWriter != null) {
|
||||
manifestWriter.writeManifest(jarFile);
|
||||
}
|
||||
Enumeration<JarEntry> entries = jarFile.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
@@ -385,7 +385,7 @@ class ExtractCommand extends Command {
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private interface ManfiestWriter {
|
||||
private interface ManifestWriter {
|
||||
|
||||
void writeManifest(JarFile sourceJarFile) throws IOException;
|
||||
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ final class NestedPath implements Path {
|
||||
|
||||
NestedPath(NestedFileSystem fileSystem, String nestedEntryName) {
|
||||
if (fileSystem == null) {
|
||||
throw new IllegalArgumentException("'filesSystem' must not be null");
|
||||
throw new IllegalArgumentException("'fileSystem' must not be null");
|
||||
}
|
||||
this.fileSystem = fileSystem;
|
||||
this.nestedEntryName = (nestedEntryName != null && !nestedEntryName.isBlank()) ? nestedEntryName : null;
|
||||
|
||||
+2
-2
@@ -697,10 +697,10 @@ public final class ZipContent implements Closeable {
|
||||
}
|
||||
|
||||
void detect(ZipCentralDirectoryFileHeaderRecord centralRecord, FileDataBlock data, long pos,
|
||||
ByteBuffer loadeBuffer) throws IOException {
|
||||
ByteBuffer loadedBuffer) throws IOException {
|
||||
if (!this.detected) {
|
||||
long filenamePos = pos + ZipCentralDirectoryFileHeaderRecord.FILE_NAME_OFFSET;
|
||||
if (centralRecord.fileNameLength() > this.buffer.capacity() && ZipString.startsWith(loadeBuffer, data,
|
||||
if (centralRecord.fileNameLength() > this.buffer.capacity() && ZipString.startsWith(loadedBuffer, data,
|
||||
filenamePos, centralRecord.fileNameLength(), META_INF) >= 0) {
|
||||
this.buffer.clear();
|
||||
data.readFully(this.buffer, filenamePos + centralRecord.fileNameLength() - this.buffer.capacity());
|
||||
|
||||
+1
-1
@@ -193,7 +193,7 @@ class NestedJarFileTests {
|
||||
|
||||
@Test
|
||||
void getEntryWhenMultiReleaseEntryReturnsEntry() throws IOException {
|
||||
File multiReleaseFile = new File(this.tempDir, "mutli.zip");
|
||||
File multiReleaseFile = new File(this.tempDir, "multi.zip");
|
||||
try (ZipContent zip = ZipContent.open(this.file.toPath(), "multi-release.jar")) {
|
||||
try (InputStream in = zip.openRawZipData().asInputStream()) {
|
||||
try (FileOutputStream out = new FileOutputStream(multiReleaseFile)) {
|
||||
|
||||
Reference in New Issue
Block a user