Merge branch '3.3.x'

Closes gh-43270
This commit is contained in:
Andy Wilkinson
2024-11-22 15:40:51 +00:00
28 changed files with 184 additions and 129 deletions

View File

@@ -600,7 +600,7 @@ class DockerApiTests {
}
@Test
void createWithPlatformAndInsufficientApiVersionThrowsException() throws Exception {
void createWithPlatformAndInsufficientApiVersionThrowsException() {
ImageReference imageReference = ImageReference.of("ubuntu:bionic");
ContainerConfig config = ContainerConfig.of(imageReference, (update) -> update.withCommand("/bin/bash"));
ImagePlatform platform = ImagePlatform.of("linux/arm64/v1");

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.
@@ -17,8 +17,10 @@
package org.springframework.boot.buildpack.platform.json;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.util.stream.Collectors;
@@ -45,8 +47,13 @@ public abstract class AbstractJsonTests {
}
protected final String getContentAsString(String name) {
return new BufferedReader(new InputStreamReader(getContent(name), StandardCharsets.UTF_8)).lines()
.collect(Collectors.joining("\n"));
try (InputStream in = getContent(name)) {
return new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)).lines()
.collect(Collectors.joining("\n"));
}
catch (IOException ex) {
throw new UncheckedIOException(ex);
}
}
}

View File

@@ -348,8 +348,11 @@ class BootZipCopyAction implements CopyAction {
private void writeJarModeLibrary(String location, JarModeLibrary library) throws IOException {
String name = location + library.getName();
writeEntry(name, ZipEntryContentWriter.fromInputStream(library.openStream()), false,
(entry) -> prepareStoredEntry(library.openStream(), entry));
writeEntry(name, ZipEntryContentWriter.fromInputStream(library.openStream()), false, (entry) -> {
try (InputStream in = library.openStream()) {
prepareStoredEntry(library.openStream(), entry);
}
});
if (BootZipCopyAction.this.layerResolver != null) {
Layer layer = BootZipCopyAction.this.layerResolver.getLayer(library);
this.layerIndex.add(layer, name);

View File

@@ -122,9 +122,10 @@ class NativeImagePluginActionIntegrationTests {
BuildResult result = this.gradleBuild.build("bootJar");
assertThat(result.task(":bootJar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs");
JarFile jarFile = new JarFile(new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".jar"));
Manifest manifest = jarFile.getManifest();
assertThat(manifest.getMainAttributes().getValue("Spring-Boot-Native-Processed")).isEqualTo("true");
try (JarFile jarFile = new JarFile(new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".jar"))) {
Manifest manifest = jarFile.getManifest();
assertThat(manifest.getMainAttributes().getValue("Spring-Boot-Native-Processed")).isEqualTo("true");
}
}
private String projectPath(String path) {

View File

@@ -84,6 +84,7 @@ public class NestedFileSystemProvider extends FileSystemProvider {
}
@Override
@SuppressWarnings("resource")
public Path getPath(URI uri) {
NestedLocation location = NestedLocation.fromUri(uri);
synchronized (this.fileSystems) {

View File

@@ -475,7 +475,6 @@ class BuildImageTests extends AbstractArchiveIntegrationTests {
@TestTemplate
void whenBuildImageIsInvokedWithCreatedDate(MavenBuild mavenBuild) {
String testBuildId = randomString();
mavenBuild.project("dockerTest", "build-image-created-date")
.goals("package")
.systemProperty("spring-boot.build-image.pullPolicy", "IF_NOT_PRESENT")

View File

@@ -88,6 +88,7 @@ public enum TestImage {
* {@link org.testcontainers.containers.CassandraContainer}.
* @deprecated since 3.4.0 for removal in 3.6.0 in favor of {@link #CASSANDRA}
*/
@SuppressWarnings("deprecation")
@Deprecated(since = "3.4.0", forRemoval = true)
CASSANDRA_DEPRECATED("cassandra", "3.11.10", () -> org.testcontainers.containers.CassandraContainer.class,
(container) -> ((org.testcontainers.containers.CassandraContainer<?>) container)
@@ -139,6 +140,7 @@ public enum TestImage {
* deprecated {@link org.testcontainers.containers.KafkaContainer}.
* @deprecated since 3.4.0 for removal in 3.6.0 in favor of {@link #CONFLUENT_KAFKA}
*/
@SuppressWarnings("deprecation")
@Deprecated(since = "3.4.0", forRemoval = true)
CONFLUENT_KAFKA_DEPRECATED("confluentinc/cp-kafka", "7.4.0",
() -> org.testcontainers.containers.KafkaContainer.class),

View File

@@ -99,6 +99,7 @@ final class ModifiedClassPathClassLoader extends URLClassLoader {
return super.loadClass(name);
}
@SuppressWarnings("resource")
static ModifiedClassPathClassLoader get(Class<?> testClass, Method testMethod, List<Object> arguments) {
Set<AnnotatedElement> candidates = new LinkedHashSet<>();
candidates.add(testClass);