Merge branch '4.1.x'

Closes gh-51607
This commit is contained in:
Andy Wilkinson
2026-09-07 12:20:42 +01:00
24 changed files with 44 additions and 44 deletions
@@ -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;
@@ -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;
@@ -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());
@@ -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)) {