Upgrade to Commons Compress 1.25.0

Closes gh-39148
This commit is contained in:
Andy Wilkinson 2024-01-30 11:56:26 +00:00
parent 9f1dda22ab
commit 1c2a622f7f
15 changed files with 48 additions and 48 deletions

View File

@ -34,7 +34,7 @@ bom {
]
}
}
library("Commons Compress", "1.21") {
library("Commons Compress", "1.25.0") {
group("org.apache.commons") {
modules = [
"commons-compress"

View File

@ -22,7 +22,7 @@ dependencies {
api("com.fasterxml.jackson.core:jackson-databind")
api("com.fasterxml.jackson.module:jackson-module-parameter-names")
api("net.java.dev.jna:jna-platform")
api("org.apache.commons:commons-compress:1.19")
api("org.apache.commons:commons-compress")
api("org.apache.httpcomponents.client5:httpclient5")
api("org.springframework:spring-core")
api("org.tomlj:tomlj:1.0.0")

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -131,12 +131,12 @@ final class ImageBuildpack implements Buildpack {
try (TarArchiveInputStream tarIn = new TarArchiveInputStream(Files.newInputStream(path));
TarArchiveOutputStream tarOut = new TarArchiveOutputStream(out)) {
tarOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
TarArchiveEntry entry = tarIn.getNextTarEntry();
TarArchiveEntry entry = tarIn.getNextEntry();
while (entry != null) {
tarOut.putArchiveEntry(entry);
StreamUtils.copy(tarIn, tarOut);
tarOut.closeArchiveEntry();
entry = tarIn.getNextTarEntry();
entry = tarIn.getNextEntry();
}
tarOut.finish();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -90,13 +90,13 @@ final class TarGzipBuildpack implements Buildpack {
new GzipCompressorInputStream(Files.newInputStream(this.path)));
TarArchiveOutputStream output = new TarArchiveOutputStream(outputStream)) {
writeBasePathEntries(output, basePath);
TarArchiveEntry entry = tar.getNextTarEntry();
TarArchiveEntry entry = tar.getNextEntry();
while (entry != null) {
entry.setName(basePath + "/" + entry.getName());
output.putArchiveEntry(entry);
StreamUtils.copy(tar, output);
output.closeArchiveEntry();
entry = tar.getNextTarEntry();
entry = tar.getNextEntry();
}
output.finish();
}

View File

@ -296,7 +296,7 @@ public class DockerApi {
ImageArchiveManifest manifest = null;
Map<String, Path> layerFiles = new HashMap<>();
try (TarArchiveInputStream tar = new TarArchiveInputStream(response.getContent())) {
TarArchiveEntry entry = tar.getNextTarEntry();
TarArchiveEntry entry = tar.getNextEntry();
while (entry != null) {
if (entry.getName().equals("manifest.json")) {
manifest = readManifest(tar);
@ -304,7 +304,7 @@ public class DockerApi {
if (entry.getName().endsWith(".tar")) {
layerFiles.put(entry.getName(), copyToTemp(tar));
}
entry = tar.getNextTarEntry();
entry = tar.getNextEntry();
}
}
Assert.notNull(manifest, "Manifest not found in image " + reference);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -128,10 +128,10 @@ class DirectoryBuildpackTests {
byte[] content = layers.get(0).toByteArray();
try (TarArchiveInputStream tar = new TarArchiveInputStream(new ByteArrayInputStream(content))) {
List<TarArchiveEntry> entries = new ArrayList<>();
TarArchiveEntry entry = tar.getNextTarEntry();
TarArchiveEntry entry = tar.getNextEntry();
while (entry != null) {
entries.add(entry);
entry = tar.getNextTarEntry();
entry = tar.getNextEntry();
}
assertThat(entries).extracting("name", "mode")
.containsExactlyInAnyOrder(tuple("/cnb/", 0755), tuple("/cnb/buildpacks/", 0755),

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -213,10 +213,10 @@ class ImageBuildpackTests extends AbstractJsonTests {
byte[] content = layers.get(0).toByteArray();
List<TarArchiveEntry> entries = new ArrayList<>();
try (TarArchiveInputStream tar = new TarArchiveInputStream(new ByteArrayInputStream(content))) {
TarArchiveEntry entry = tar.getNextTarEntry();
TarArchiveEntry entry = tar.getNextEntry();
while (entry != null) {
entries.add(entry);
entry = tar.getNextTarEntry();
entry = tar.getNextEntry();
}
}
assertThat(entries).extracting("name", "mode")

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -336,10 +336,10 @@ class DockerApiTests {
archive.writeTo(out);
try (TarArchiveInputStream in = new TarArchiveInputStream(
new ByteArrayInputStream(out.toByteArray()))) {
TarArchiveEntry entry = in.getNextTarEntry();
TarArchiveEntry entry = in.getNextEntry();
while (entry != null) {
contents.add(name, entry.getName());
entry = in.getNextTarEntry();
entry = in.getNextEntry();
}
}
});
@ -364,10 +364,10 @@ class DockerApiTests {
archive.writeTo(out);
try (TarArchiveInputStream in = new TarArchiveInputStream(
new ByteArrayInputStream(out.toByteArray()))) {
TarArchiveEntry entry = in.getNextTarEntry();
TarArchiveEntry entry = in.getNextEntry();
while (entry != null) {
contents.add(name, entry.getName());
entry = in.getNextTarEntry();
entry = in.getNextEntry();
}
}
});

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -54,14 +54,14 @@ class ImageArchiveTests extends AbstractJsonTests {
try (TarArchiveInputStream tar = new TarArchiveInputStream(
new ByteArrayInputStream(outputStream.toByteArray()))) {
for (int i = 0; i < EXISTING_IMAGE_LAYER_COUNT; i++) {
TarArchiveEntry blankEntry = tar.getNextTarEntry();
TarArchiveEntry blankEntry = tar.getNextEntry();
assertThat(blankEntry.getName()).isEqualTo("blank_" + i);
}
TarArchiveEntry layerEntry = tar.getNextTarEntry();
TarArchiveEntry layerEntry = tar.getNextEntry();
byte[] layerContent = read(tar, layerEntry.getSize());
TarArchiveEntry configEntry = tar.getNextTarEntry();
TarArchiveEntry configEntry = tar.getNextEntry();
byte[] configContent = read(tar, configEntry.getSize());
TarArchiveEntry manifestEntry = tar.getNextTarEntry();
TarArchiveEntry manifestEntry = tar.getNextEntry();
byte[] manifestContent = read(tar, manifestEntry.getSize());
assertExpectedLayer(layerEntry, layerContent);
assertExpectedConfig(configEntry, configContent);
@ -72,7 +72,7 @@ class ImageArchiveTests extends AbstractJsonTests {
private void assertExpectedLayer(TarArchiveEntry entry, byte[] content) throws Exception {
assertThat(entry.getName()).isEqualTo("bb09e17fd1bd2ee47155f1349645fcd9fff31e1247c7ed99cad469f1c16a4216.tar");
try (TarArchiveInputStream tar = new TarArchiveInputStream(new ByteArrayInputStream(content))) {
TarArchiveEntry contentEntry = tar.getNextTarEntry();
TarArchiveEntry contentEntry = tar.getNextEntry();
assertThat(contentEntry.getName()).isEqualTo("/spring/");
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -61,9 +61,9 @@ class LayerTests {
layer.writeTo(outputStream);
try (TarArchiveInputStream tarStream = new TarArchiveInputStream(
new ByteArrayInputStream(outputStream.toByteArray()))) {
assertThat(tarStream.getNextTarEntry().getName()).isEqualTo("/directory/");
assertThat(tarStream.getNextTarEntry().getName()).isEqualTo("/directory/file");
assertThat(tarStream.getNextTarEntry()).isNull();
assertThat(tarStream.getNextEntry().getName()).isEqualTo("/directory/");
assertThat(tarStream.getNextEntry().getName()).isEqualTo("/directory/file");
assertThat(tarStream.getNextEntry()).isNull();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -58,10 +58,10 @@ class TarArchiveTests {
try (TarArchiveInputStream tarStream = new TarArchiveInputStream(
new ByteArrayInputStream(outputStream.toByteArray()))) {
List<TarArchiveEntry> entries = new ArrayList<>();
TarArchiveEntry entry = tarStream.getNextTarEntry();
TarArchiveEntry entry = tarStream.getNextEntry();
while (entry != null) {
entries.add(entry);
entry = tarStream.getNextTarEntry();
entry = tarStream.getNextEntry();
}
assertThat(entries).hasSize(6);
assertThat(entries.get(0).getName()).isEqualTo("/workspace/");

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -44,8 +44,8 @@ class TarLayoutWriterTests {
}
try (TarArchiveInputStream tarInputStream = new TarArchiveInputStream(
new ByteArrayInputStream(outputStream.toByteArray()))) {
TarArchiveEntry directoryEntry = tarInputStream.getNextTarEntry();
TarArchiveEntry fileEntry = tarInputStream.getNextTarEntry();
TarArchiveEntry directoryEntry = tarInputStream.getNextEntry();
TarArchiveEntry fileEntry = tarInputStream.getNextEntry();
byte[] fileContent = new byte[(int) fileEntry.getSize()];
tarInputStream.read(fileContent);
assertThat(tarInputStream.getNextEntry()).isNull();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -67,11 +67,11 @@ class ZipFileTarArchiveTests {
tarArchive.writeTo(outputStream);
try (TarArchiveInputStream tarStream = new TarArchiveInputStream(
new ByteArrayInputStream(outputStream.toByteArray()))) {
TarArchiveEntry dirEntry = tarStream.getNextTarEntry();
TarArchiveEntry dirEntry = tarStream.getNextEntry();
assertThat(dirEntry.getName()).isEqualTo("spring/");
assertThat(dirEntry.getLongUserId()).isEqualTo(123);
assertThat(dirEntry.getLongGroupId()).isEqualTo(456);
TarArchiveEntry fileEntry = tarStream.getNextTarEntry();
TarArchiveEntry fileEntry = tarStream.getNextEntry();
assertThat(fileEntry.getName()).isEqualTo("spring/boot");
assertThat(fileEntry.getLongUserId()).isEqualTo(123);
assertThat(fileEntry.getLongGroupId()).isEqualTo(456);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -195,7 +195,7 @@ class ApplicationPluginActionIntegrationTests {
List<String> entryNames = new ArrayList<>();
try (TarArchiveInputStream input = new TarArchiveInputStream(new FileInputStream(distribution))) {
TarArchiveEntry entry;
while ((entry = input.getNextTarEntry()) != null) {
while ((entry = input.getNextEntry()) != null) {
entryNames.add(entry.getName());
}
}
@ -205,7 +205,7 @@ class ApplicationPluginActionIntegrationTests {
private void tarEntries(File distribution, Consumer<TarArchiveEntry> consumer) throws IOException {
try (TarArchiveInputStream input = new TarArchiveInputStream(new FileInputStream(distribution))) {
TarArchiveEntry entry;
while ((entry = input.getNextTarEntry()) != null) {
while ((entry = input.getNextEntry()) != null) {
consumer.accept(entry);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -80,12 +80,12 @@ public class ImageAssert extends AbstractAssert<ImageAssert, ImageReference> {
this.actual.writeTo(out);
try (TarArchiveInputStream in = new TarArchiveInputStream(
new ByteArrayInputStream(out.toByteArray()))) {
TarArchiveEntry entry = in.getNextTarEntry();
TarArchiveEntry entry = in.getNextEntry();
while (entry != null) {
if (!entry.isDirectory()) {
entryNames.add(entry.getName().replaceFirst("^/workspace/", ""));
}
entry = in.getNextTarEntry();
entry = in.getNextEntry();
}
}
}
@ -101,7 +101,7 @@ public class ImageAssert extends AbstractAssert<ImageAssert, ImageReference> {
this.actual.writeTo(out);
try (TarArchiveInputStream in = new TarArchiveInputStream(
new ByteArrayInputStream(out.toByteArray()))) {
TarArchiveEntry entry = in.getNextTarEntry();
TarArchiveEntry entry = in.getNextEntry();
while (entry != null) {
if (entry.getName().equals(name)) {
ByteArrayOutputStream entryOut = new ByteArrayOutputStream();
@ -109,7 +109,7 @@ public class ImageAssert extends AbstractAssert<ImageAssert, ImageReference> {
assertConsumer.accept(new JsonContentAssert(LayerContentAssert.class, entryOut.toString()));
return;
}
entry = in.getNextTarEntry();
entry = in.getNextEntry();
}
}
failWithMessage("Expected JSON entry '%s' in layer with digest '%s'", name, this.actual.getId());