Skip to content

Commit

Permalink
Merge branch '3.2.x'
Browse files Browse the repository at this point in the history
Closes gh-39341
  • Loading branch information
wilkinsona committed Jan 30, 2024
2 parents 224ce7c + 8c18d75 commit 10e750a
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion spring-boot-project/spring-boot-parent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bom {
]
}
}
library("Commons Compress", "1.23.0") {
library("Commons Compress", "1.25.0") {
group("org.apache.commons") {
modules = [
"commons-compress"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -131,12 +131,12 @@ private void copyLayerTar(Path path, OutputStream out) throws IOException {
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();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -90,13 +90,13 @@ private void copyAndRebaseEntries(OutputStream outputStream) throws IOException
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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,15 +296,15 @@ public void exportLayerFiles(ImageReference reference, IOBiConsumer<String, Path
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);
}
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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -128,10 +128,10 @@ private void assertHasExpectedLayers(Buildpack buildpack) throws IOException {
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),
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -213,10 +213,10 @@ private void assertAppliesExpectedLayers(Buildpack buildpack) throws IOException
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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -336,10 +336,10 @@ void exportLayersExportsLayerTars() throws Exception {
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();
}
}
});
Expand All @@ -364,10 +364,10 @@ void exportLayersWithSymlinksExportsLayerTars() throws Exception {
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();
}
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -54,14 +54,14 @@ void fromImageWritesToValidArchiveTar() throws Exception {
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);
Expand All @@ -72,7 +72,7 @@ void fromImageWritesToValidArchiveTar() throws Exception {
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/");
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -61,9 +61,9 @@ void ofCreatesLayer() throws Exception {
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();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -58,10 +58,10 @@ void ofWritesTarContent() throws Exception {
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/");
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -44,8 +44,8 @@ void writesTarArchive() throws Exception {
}
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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -67,11 +67,11 @@ void writeToAdaptsContent() throws Exception {
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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -195,7 +195,7 @@ private List<String> tarEntryNames(File distribution) throws IOException {
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());
}
}
Expand All @@ -205,7 +205,7 @@ private List<String> tarEntryNames(File distribution) throws IOException {
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);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -80,12 +80,12 @@ public ListAssert<String> entries() {
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();
}
}
}
Expand All @@ -101,15 +101,15 @@ public void jsonEntry(String name, Consumer<JsonContentAssert> assertConsumer) {
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();
IOUtils.copy(in, entryOut);
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());
Expand Down

0 comments on commit 10e750a

Please sign in to comment.