mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
Merge branch '3.1.x' into 3.2.x
See gh-39340
This commit is contained in:
commit
899da7891a
@ -34,7 +34,7 @@ bom {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
library("Commons Compress", "1.25.0") {
|
library("Commons Compress", "1.21") {
|
||||||
group("org.apache.commons") {
|
group("org.apache.commons") {
|
||||||
modules = [
|
modules = [
|
||||||
"commons-compress"
|
"commons-compress"
|
||||||
|
@ -131,12 +131,12 @@ final class ImageBuildpack implements Buildpack {
|
|||||||
try (TarArchiveInputStream tarIn = new TarArchiveInputStream(Files.newInputStream(path));
|
try (TarArchiveInputStream tarIn = new TarArchiveInputStream(Files.newInputStream(path));
|
||||||
TarArchiveOutputStream tarOut = new TarArchiveOutputStream(out)) {
|
TarArchiveOutputStream tarOut = new TarArchiveOutputStream(out)) {
|
||||||
tarOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
|
tarOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
|
||||||
TarArchiveEntry entry = tarIn.getNextEntry();
|
TarArchiveEntry entry = tarIn.getNextTarEntry();
|
||||||
while (entry != null) {
|
while (entry != null) {
|
||||||
tarOut.putArchiveEntry(entry);
|
tarOut.putArchiveEntry(entry);
|
||||||
StreamUtils.copy(tarIn, tarOut);
|
StreamUtils.copy(tarIn, tarOut);
|
||||||
tarOut.closeArchiveEntry();
|
tarOut.closeArchiveEntry();
|
||||||
entry = tarIn.getNextEntry();
|
entry = tarIn.getNextTarEntry();
|
||||||
}
|
}
|
||||||
tarOut.finish();
|
tarOut.finish();
|
||||||
}
|
}
|
||||||
|
@ -90,13 +90,13 @@ final class TarGzipBuildpack implements Buildpack {
|
|||||||
new GzipCompressorInputStream(Files.newInputStream(this.path)));
|
new GzipCompressorInputStream(Files.newInputStream(this.path)));
|
||||||
TarArchiveOutputStream output = new TarArchiveOutputStream(outputStream)) {
|
TarArchiveOutputStream output = new TarArchiveOutputStream(outputStream)) {
|
||||||
writeBasePathEntries(output, basePath);
|
writeBasePathEntries(output, basePath);
|
||||||
TarArchiveEntry entry = tar.getNextEntry();
|
TarArchiveEntry entry = tar.getNextTarEntry();
|
||||||
while (entry != null) {
|
while (entry != null) {
|
||||||
entry.setName(basePath + "/" + entry.getName());
|
entry.setName(basePath + "/" + entry.getName());
|
||||||
output.putArchiveEntry(entry);
|
output.putArchiveEntry(entry);
|
||||||
StreamUtils.copy(tar, output);
|
StreamUtils.copy(tar, output);
|
||||||
output.closeArchiveEntry();
|
output.closeArchiveEntry();
|
||||||
entry = tar.getNextEntry();
|
entry = tar.getNextTarEntry();
|
||||||
}
|
}
|
||||||
output.finish();
|
output.finish();
|
||||||
}
|
}
|
||||||
|
@ -295,14 +295,14 @@ public class DockerApi {
|
|||||||
Path exportFile = copyToTemp(response.getContent());
|
Path exportFile = copyToTemp(response.getContent());
|
||||||
ImageArchiveManifest manifest = getManifest(reference, exportFile);
|
ImageArchiveManifest manifest = getManifest(reference, exportFile);
|
||||||
try (TarArchiveInputStream tar = new TarArchiveInputStream(new FileInputStream(exportFile.toFile()))) {
|
try (TarArchiveInputStream tar = new TarArchiveInputStream(new FileInputStream(exportFile.toFile()))) {
|
||||||
TarArchiveEntry entry = tar.getNextEntry();
|
TarArchiveEntry entry = tar.getNextTarEntry();
|
||||||
while (entry != null) {
|
while (entry != null) {
|
||||||
if (manifestContainsLayerEntry(manifest, entry.getName())) {
|
if (manifestContainsLayerEntry(manifest, entry.getName())) {
|
||||||
Path layerFile = copyToTemp(tar);
|
Path layerFile = copyToTemp(tar);
|
||||||
exports.accept(entry.getName(), layerFile);
|
exports.accept(entry.getName(), layerFile);
|
||||||
Files.delete(layerFile);
|
Files.delete(layerFile);
|
||||||
}
|
}
|
||||||
entry = tar.getNextEntry();
|
entry = tar.getNextTarEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Files.delete(exportFile);
|
Files.delete(exportFile);
|
||||||
@ -347,12 +347,12 @@ public class DockerApi {
|
|||||||
|
|
||||||
private ImageArchiveManifest getManifest(ImageReference reference, Path exportFile) throws IOException {
|
private ImageArchiveManifest getManifest(ImageReference reference, Path exportFile) throws IOException {
|
||||||
try (TarArchiveInputStream tar = new TarArchiveInputStream(new FileInputStream(exportFile.toFile()))) {
|
try (TarArchiveInputStream tar = new TarArchiveInputStream(new FileInputStream(exportFile.toFile()))) {
|
||||||
TarArchiveEntry entry = tar.getNextEntry();
|
TarArchiveEntry entry = tar.getNextTarEntry();
|
||||||
while (entry != null) {
|
while (entry != null) {
|
||||||
if (entry.getName().equals("manifest.json")) {
|
if (entry.getName().equals("manifest.json")) {
|
||||||
return readManifest(tar);
|
return readManifest(tar);
|
||||||
}
|
}
|
||||||
entry = tar.getNextEntry();
|
entry = tar.getNextTarEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("Manifest not found in image " + reference);
|
throw new IllegalArgumentException("Manifest not found in image " + reference);
|
||||||
|
@ -128,10 +128,10 @@ class DirectoryBuildpackTests {
|
|||||||
byte[] content = layers.get(0).toByteArray();
|
byte[] content = layers.get(0).toByteArray();
|
||||||
try (TarArchiveInputStream tar = new TarArchiveInputStream(new ByteArrayInputStream(content))) {
|
try (TarArchiveInputStream tar = new TarArchiveInputStream(new ByteArrayInputStream(content))) {
|
||||||
List<TarArchiveEntry> entries = new ArrayList<>();
|
List<TarArchiveEntry> entries = new ArrayList<>();
|
||||||
TarArchiveEntry entry = tar.getNextEntry();
|
TarArchiveEntry entry = tar.getNextTarEntry();
|
||||||
while (entry != null) {
|
while (entry != null) {
|
||||||
entries.add(entry);
|
entries.add(entry);
|
||||||
entry = tar.getNextEntry();
|
entry = tar.getNextTarEntry();
|
||||||
}
|
}
|
||||||
assertThat(entries).extracting("name", "mode")
|
assertThat(entries).extracting("name", "mode")
|
||||||
.containsExactlyInAnyOrder(tuple("/cnb/", 0755), tuple("/cnb/buildpacks/", 0755),
|
.containsExactlyInAnyOrder(tuple("/cnb/", 0755), tuple("/cnb/buildpacks/", 0755),
|
||||||
|
@ -215,10 +215,10 @@ class ImageBuildpackTests extends AbstractJsonTests {
|
|||||||
byte[] content = layers.get(0).toByteArray();
|
byte[] content = layers.get(0).toByteArray();
|
||||||
List<TarArchiveEntry> entries = new ArrayList<>();
|
List<TarArchiveEntry> entries = new ArrayList<>();
|
||||||
try (TarArchiveInputStream tar = new TarArchiveInputStream(new ByteArrayInputStream(content))) {
|
try (TarArchiveInputStream tar = new TarArchiveInputStream(new ByteArrayInputStream(content))) {
|
||||||
TarArchiveEntry entry = tar.getNextEntry();
|
TarArchiveEntry entry = tar.getNextTarEntry();
|
||||||
while (entry != null) {
|
while (entry != null) {
|
||||||
entries.add(entry);
|
entries.add(entry);
|
||||||
entry = tar.getNextEntry();
|
entry = tar.getNextTarEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertThat(entries).extracting("name", "mode")
|
assertThat(entries).extracting("name", "mode")
|
||||||
|
@ -336,10 +336,10 @@ class DockerApiTests {
|
|||||||
archive.writeTo(out);
|
archive.writeTo(out);
|
||||||
try (TarArchiveInputStream in = new TarArchiveInputStream(
|
try (TarArchiveInputStream in = new TarArchiveInputStream(
|
||||||
new ByteArrayInputStream(out.toByteArray()))) {
|
new ByteArrayInputStream(out.toByteArray()))) {
|
||||||
TarArchiveEntry entry = in.getNextEntry();
|
TarArchiveEntry entry = in.getNextTarEntry();
|
||||||
while (entry != null) {
|
while (entry != null) {
|
||||||
contents.add(name, entry.getName());
|
contents.add(name, entry.getName());
|
||||||
entry = in.getNextEntry();
|
entry = in.getNextTarEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -364,10 +364,10 @@ class DockerApiTests {
|
|||||||
archive.writeTo(out);
|
archive.writeTo(out);
|
||||||
try (TarArchiveInputStream in = new TarArchiveInputStream(
|
try (TarArchiveInputStream in = new TarArchiveInputStream(
|
||||||
new ByteArrayInputStream(out.toByteArray()))) {
|
new ByteArrayInputStream(out.toByteArray()))) {
|
||||||
TarArchiveEntry entry = in.getNextEntry();
|
TarArchiveEntry entry = in.getNextTarEntry();
|
||||||
while (entry != null) {
|
while (entry != null) {
|
||||||
contents.add(name, entry.getName());
|
contents.add(name, entry.getName());
|
||||||
entry = in.getNextEntry();
|
entry = in.getNextTarEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -54,14 +54,14 @@ class ImageArchiveTests extends AbstractJsonTests {
|
|||||||
try (TarArchiveInputStream tar = new TarArchiveInputStream(
|
try (TarArchiveInputStream tar = new TarArchiveInputStream(
|
||||||
new ByteArrayInputStream(outputStream.toByteArray()))) {
|
new ByteArrayInputStream(outputStream.toByteArray()))) {
|
||||||
for (int i = 0; i < EXISTING_IMAGE_LAYER_COUNT; i++) {
|
for (int i = 0; i < EXISTING_IMAGE_LAYER_COUNT; i++) {
|
||||||
TarArchiveEntry blankEntry = tar.getNextEntry();
|
TarArchiveEntry blankEntry = tar.getNextTarEntry();
|
||||||
assertThat(blankEntry.getName()).isEqualTo("blank_" + i);
|
assertThat(blankEntry.getName()).isEqualTo("blank_" + i);
|
||||||
}
|
}
|
||||||
TarArchiveEntry layerEntry = tar.getNextEntry();
|
TarArchiveEntry layerEntry = tar.getNextTarEntry();
|
||||||
byte[] layerContent = read(tar, layerEntry.getSize());
|
byte[] layerContent = read(tar, layerEntry.getSize());
|
||||||
TarArchiveEntry configEntry = tar.getNextEntry();
|
TarArchiveEntry configEntry = tar.getNextTarEntry();
|
||||||
byte[] configContent = read(tar, configEntry.getSize());
|
byte[] configContent = read(tar, configEntry.getSize());
|
||||||
TarArchiveEntry manifestEntry = tar.getNextEntry();
|
TarArchiveEntry manifestEntry = tar.getNextTarEntry();
|
||||||
byte[] manifestContent = read(tar, manifestEntry.getSize());
|
byte[] manifestContent = read(tar, manifestEntry.getSize());
|
||||||
assertExpectedLayer(layerEntry, layerContent);
|
assertExpectedLayer(layerEntry, layerContent);
|
||||||
assertExpectedConfig(configEntry, configContent);
|
assertExpectedConfig(configEntry, configContent);
|
||||||
@ -72,7 +72,7 @@ class ImageArchiveTests extends AbstractJsonTests {
|
|||||||
private void assertExpectedLayer(TarArchiveEntry entry, byte[] content) throws Exception {
|
private void assertExpectedLayer(TarArchiveEntry entry, byte[] content) throws Exception {
|
||||||
assertThat(entry.getName()).isEqualTo("bb09e17fd1bd2ee47155f1349645fcd9fff31e1247c7ed99cad469f1c16a4216.tar");
|
assertThat(entry.getName()).isEqualTo("bb09e17fd1bd2ee47155f1349645fcd9fff31e1247c7ed99cad469f1c16a4216.tar");
|
||||||
try (TarArchiveInputStream tar = new TarArchiveInputStream(new ByteArrayInputStream(content))) {
|
try (TarArchiveInputStream tar = new TarArchiveInputStream(new ByteArrayInputStream(content))) {
|
||||||
TarArchiveEntry contentEntry = tar.getNextEntry();
|
TarArchiveEntry contentEntry = tar.getNextTarEntry();
|
||||||
assertThat(contentEntry.getName()).isEqualTo("/spring/");
|
assertThat(contentEntry.getName()).isEqualTo("/spring/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,9 +61,9 @@ class LayerTests {
|
|||||||
layer.writeTo(outputStream);
|
layer.writeTo(outputStream);
|
||||||
try (TarArchiveInputStream tarStream = new TarArchiveInputStream(
|
try (TarArchiveInputStream tarStream = new TarArchiveInputStream(
|
||||||
new ByteArrayInputStream(outputStream.toByteArray()))) {
|
new ByteArrayInputStream(outputStream.toByteArray()))) {
|
||||||
assertThat(tarStream.getNextEntry().getName()).isEqualTo("/directory/");
|
assertThat(tarStream.getNextTarEntry().getName()).isEqualTo("/directory/");
|
||||||
assertThat(tarStream.getNextEntry().getName()).isEqualTo("/directory/file");
|
assertThat(tarStream.getNextTarEntry().getName()).isEqualTo("/directory/file");
|
||||||
assertThat(tarStream.getNextEntry()).isNull();
|
assertThat(tarStream.getNextTarEntry()).isNull();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,10 +58,10 @@ class TarArchiveTests {
|
|||||||
try (TarArchiveInputStream tarStream = new TarArchiveInputStream(
|
try (TarArchiveInputStream tarStream = new TarArchiveInputStream(
|
||||||
new ByteArrayInputStream(outputStream.toByteArray()))) {
|
new ByteArrayInputStream(outputStream.toByteArray()))) {
|
||||||
List<TarArchiveEntry> entries = new ArrayList<>();
|
List<TarArchiveEntry> entries = new ArrayList<>();
|
||||||
TarArchiveEntry entry = tarStream.getNextEntry();
|
TarArchiveEntry entry = tarStream.getNextTarEntry();
|
||||||
while (entry != null) {
|
while (entry != null) {
|
||||||
entries.add(entry);
|
entries.add(entry);
|
||||||
entry = tarStream.getNextEntry();
|
entry = tarStream.getNextTarEntry();
|
||||||
}
|
}
|
||||||
assertThat(entries).hasSize(6);
|
assertThat(entries).hasSize(6);
|
||||||
assertThat(entries.get(0).getName()).isEqualTo("/workspace/");
|
assertThat(entries.get(0).getName()).isEqualTo("/workspace/");
|
||||||
|
@ -44,8 +44,8 @@ class TarLayoutWriterTests {
|
|||||||
}
|
}
|
||||||
try (TarArchiveInputStream tarInputStream = new TarArchiveInputStream(
|
try (TarArchiveInputStream tarInputStream = new TarArchiveInputStream(
|
||||||
new ByteArrayInputStream(outputStream.toByteArray()))) {
|
new ByteArrayInputStream(outputStream.toByteArray()))) {
|
||||||
TarArchiveEntry directoryEntry = tarInputStream.getNextEntry();
|
TarArchiveEntry directoryEntry = tarInputStream.getNextTarEntry();
|
||||||
TarArchiveEntry fileEntry = tarInputStream.getNextEntry();
|
TarArchiveEntry fileEntry = tarInputStream.getNextTarEntry();
|
||||||
byte[] fileContent = new byte[(int) fileEntry.getSize()];
|
byte[] fileContent = new byte[(int) fileEntry.getSize()];
|
||||||
tarInputStream.read(fileContent);
|
tarInputStream.read(fileContent);
|
||||||
assertThat(tarInputStream.getNextEntry()).isNull();
|
assertThat(tarInputStream.getNextEntry()).isNull();
|
||||||
|
@ -67,11 +67,11 @@ class ZipFileTarArchiveTests {
|
|||||||
tarArchive.writeTo(outputStream);
|
tarArchive.writeTo(outputStream);
|
||||||
try (TarArchiveInputStream tarStream = new TarArchiveInputStream(
|
try (TarArchiveInputStream tarStream = new TarArchiveInputStream(
|
||||||
new ByteArrayInputStream(outputStream.toByteArray()))) {
|
new ByteArrayInputStream(outputStream.toByteArray()))) {
|
||||||
TarArchiveEntry dirEntry = tarStream.getNextEntry();
|
TarArchiveEntry dirEntry = tarStream.getNextTarEntry();
|
||||||
assertThat(dirEntry.getName()).isEqualTo("spring/");
|
assertThat(dirEntry.getName()).isEqualTo("spring/");
|
||||||
assertThat(dirEntry.getLongUserId()).isEqualTo(123);
|
assertThat(dirEntry.getLongUserId()).isEqualTo(123);
|
||||||
assertThat(dirEntry.getLongGroupId()).isEqualTo(456);
|
assertThat(dirEntry.getLongGroupId()).isEqualTo(456);
|
||||||
TarArchiveEntry fileEntry = tarStream.getNextEntry();
|
TarArchiveEntry fileEntry = tarStream.getNextTarEntry();
|
||||||
assertThat(fileEntry.getName()).isEqualTo("spring/boot");
|
assertThat(fileEntry.getName()).isEqualTo("spring/boot");
|
||||||
assertThat(fileEntry.getLongUserId()).isEqualTo(123);
|
assertThat(fileEntry.getLongUserId()).isEqualTo(123);
|
||||||
assertThat(fileEntry.getLongGroupId()).isEqualTo(456);
|
assertThat(fileEntry.getLongGroupId()).isEqualTo(456);
|
||||||
|
@ -195,7 +195,7 @@ class ApplicationPluginActionIntegrationTests {
|
|||||||
List<String> entryNames = new ArrayList<>();
|
List<String> entryNames = new ArrayList<>();
|
||||||
try (TarArchiveInputStream input = new TarArchiveInputStream(new FileInputStream(distribution))) {
|
try (TarArchiveInputStream input = new TarArchiveInputStream(new FileInputStream(distribution))) {
|
||||||
TarArchiveEntry entry;
|
TarArchiveEntry entry;
|
||||||
while ((entry = input.getNextEntry()) != null) {
|
while ((entry = input.getNextTarEntry()) != null) {
|
||||||
entryNames.add(entry.getName());
|
entryNames.add(entry.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ class ApplicationPluginActionIntegrationTests {
|
|||||||
private void tarEntries(File distribution, Consumer<TarArchiveEntry> consumer) throws IOException {
|
private void tarEntries(File distribution, Consumer<TarArchiveEntry> consumer) throws IOException {
|
||||||
try (TarArchiveInputStream input = new TarArchiveInputStream(new FileInputStream(distribution))) {
|
try (TarArchiveInputStream input = new TarArchiveInputStream(new FileInputStream(distribution))) {
|
||||||
TarArchiveEntry entry;
|
TarArchiveEntry entry;
|
||||||
while ((entry = input.getNextEntry()) != null) {
|
while ((entry = input.getNextTarEntry()) != null) {
|
||||||
consumer.accept(entry);
|
consumer.accept(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,12 +80,12 @@ public class ImageAssert extends AbstractAssert<ImageAssert, ImageReference> {
|
|||||||
this.actual.writeTo(out);
|
this.actual.writeTo(out);
|
||||||
try (TarArchiveInputStream in = new TarArchiveInputStream(
|
try (TarArchiveInputStream in = new TarArchiveInputStream(
|
||||||
new ByteArrayInputStream(out.toByteArray()))) {
|
new ByteArrayInputStream(out.toByteArray()))) {
|
||||||
TarArchiveEntry entry = in.getNextEntry();
|
TarArchiveEntry entry = in.getNextTarEntry();
|
||||||
while (entry != null) {
|
while (entry != null) {
|
||||||
if (!entry.isDirectory()) {
|
if (!entry.isDirectory()) {
|
||||||
entryNames.add(entry.getName().replaceFirst("^/workspace/", ""));
|
entryNames.add(entry.getName().replaceFirst("^/workspace/", ""));
|
||||||
}
|
}
|
||||||
entry = in.getNextEntry();
|
entry = in.getNextTarEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ public class ImageAssert extends AbstractAssert<ImageAssert, ImageReference> {
|
|||||||
this.actual.writeTo(out);
|
this.actual.writeTo(out);
|
||||||
try (TarArchiveInputStream in = new TarArchiveInputStream(
|
try (TarArchiveInputStream in = new TarArchiveInputStream(
|
||||||
new ByteArrayInputStream(out.toByteArray()))) {
|
new ByteArrayInputStream(out.toByteArray()))) {
|
||||||
TarArchiveEntry entry = in.getNextEntry();
|
TarArchiveEntry entry = in.getNextTarEntry();
|
||||||
while (entry != null) {
|
while (entry != null) {
|
||||||
if (entry.getName().equals(name)) {
|
if (entry.getName().equals(name)) {
|
||||||
ByteArrayOutputStream entryOut = new ByteArrayOutputStream();
|
ByteArrayOutputStream entryOut = new ByteArrayOutputStream();
|
||||||
@ -109,7 +109,7 @@ public class ImageAssert extends AbstractAssert<ImageAssert, ImageReference> {
|
|||||||
assertConsumer.accept(new JsonContentAssert(LayerContentAssert.class, entryOut.toString()));
|
assertConsumer.accept(new JsonContentAssert(LayerContentAssert.class, entryOut.toString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
entry = in.getNextEntry();
|
entry = in.getNextTarEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
failWithMessage("Expected JSON entry '%s' in layer with digest '%s'", name, this.actual.getId());
|
failWithMessage("Expected JSON entry '%s' in layer with digest '%s'", name, this.actual.getId());
|
||||||
|
Loading…
Reference in New Issue
Block a user