From 146a6665ab34245a7b5da26256be2442def2f9d8 Mon Sep 17 00:00:00 2001 From: Sergio del Amo Date: Thu, 4 May 2023 17:41:00 +0200 Subject: [PATCH] build: Micronaut Framework 3.9.1 (#1267) --- ...mDependencyVersionResolverReplacement.java | 3 +- .../example/micronaut/InventoryService.groovy | 4 +-- .../example/micronaut/WarehouseClient.groovy | 4 +-- .../example/micronaut/InventoryService.java | 4 +-- .../example/micronaut/WarehouseClient.java | 4 +-- .../example/micronaut/InventoryService.kt | 4 +-- .../example/micronaut/WarehouseClient.kt | 4 +-- .../metadata.json | 2 +- .../metadata.json | 2 +- guides/micronaut-error-handling/metadata.json | 2 +- .../src/main/resources/application.yml | 1 - .../metadata.json | 2 +- .../micronaut/FakeGcsServerContainer.java | 34 +++++++------------ .../ProfilePicturesControllerTest.java | 26 ++++---------- guides/micronaut-scope-types/metadata.json | 2 +- guides/micronaut-spring-boot/metadata.json | 2 +- version.txt | 2 +- 17 files changed, 39 insertions(+), 63 deletions(-) diff --git a/buildSrc/src/main/java/io/micronaut/guides/DefaultPomDependencyVersionResolverReplacement.java b/buildSrc/src/main/java/io/micronaut/guides/DefaultPomDependencyVersionResolverReplacement.java index 472fc3f6e3..5d47ba50a2 100644 --- a/buildSrc/src/main/java/io/micronaut/guides/DefaultPomDependencyVersionResolverReplacement.java +++ b/buildSrc/src/main/java/io/micronaut/guides/DefaultPomDependencyVersionResolverReplacement.java @@ -5,6 +5,7 @@ import io.micronaut.core.io.ResourceResolver; import io.micronaut.starter.build.dependencies.Coordinate; import io.micronaut.starter.build.dependencies.DefaultPomDependencyVersionResolver; +import io.micronaut.starter.build.dependencies.StarterCoordinates; import jakarta.inject.Singleton; import java.util.Map; @@ -23,6 +24,6 @@ public DefaultPomDependencyVersionResolverReplacement(ResourceResolver resourceR @Override @NonNull public Optional resolve(@NonNull String artifactId) { - return Optional.ofNullable(coordinates.get(artifactId)); + return Optional.ofNullable(coordinates.computeIfAbsent(artifactId, k -> StarterCoordinates.ALL_COORDINATES.get(artifactId))); } } diff --git a/guides/micronaut-cloud-trace-base/groovy/src/main/groovy/example/micronaut/InventoryService.groovy b/guides/micronaut-cloud-trace-base/groovy/src/main/groovy/example/micronaut/InventoryService.groovy index 69e2a63763..54be367d90 100644 --- a/guides/micronaut-cloud-trace-base/groovy/src/main/groovy/example/micronaut/InventoryService.groovy +++ b/guides/micronaut-cloud-trace-base/groovy/src/main/groovy/example/micronaut/InventoryService.groovy @@ -1,7 +1,7 @@ package example.micronaut -import io.opentelemetry.extension.annotations.SpanAttribute -import io.opentelemetry.extension.annotations.WithSpan +import io.opentelemetry.instrumentation.annotations.SpanAttribute +import io.opentelemetry.instrumentation.annotations.WithSpan import io.opentelemetry.api.trace.Span import io.opentelemetry.api.trace.Tracer import jakarta.inject.Singleton diff --git a/guides/micronaut-cloud-trace-base/groovy/src/main/groovy/example/micronaut/WarehouseClient.groovy b/guides/micronaut-cloud-trace-base/groovy/src/main/groovy/example/micronaut/WarehouseClient.groovy index 7a80ba3bf6..cff6bab61c 100644 --- a/guides/micronaut-cloud-trace-base/groovy/src/main/groovy/example/micronaut/WarehouseClient.groovy +++ b/guides/micronaut-cloud-trace-base/groovy/src/main/groovy/example/micronaut/WarehouseClient.groovy @@ -6,8 +6,8 @@ import io.micronaut.http.annotation.QueryValue import io.micronaut.http.client.annotation.Client import io.micronaut.tracing.annotation.ContinueSpan import io.micronaut.tracing.annotation.SpanTag -import io.opentelemetry.extension.annotations.SpanAttribute -import io.opentelemetry.extension.annotations.WithSpan +import io.opentelemetry.instrumentation.annotations.SpanAttribute +import io.opentelemetry.instrumentation.annotations.WithSpan import java.util.Map; diff --git a/guides/micronaut-cloud-trace-base/java/src/main/java/example/micronaut/InventoryService.java b/guides/micronaut-cloud-trace-base/java/src/main/java/example/micronaut/InventoryService.java index 6c24be6626..c980b7918d 100644 --- a/guides/micronaut-cloud-trace-base/java/src/main/java/example/micronaut/InventoryService.java +++ b/guides/micronaut-cloud-trace-base/java/src/main/java/example/micronaut/InventoryService.java @@ -1,7 +1,7 @@ package example.micronaut; -import io.opentelemetry.extension.annotations.SpanAttribute; -import io.opentelemetry.extension.annotations.WithSpan; +import io.opentelemetry.instrumentation.annotations.SpanAttribute; +import io.opentelemetry.instrumentation.annotations.WithSpan; import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.Tracer; import jakarta.inject.Singleton; diff --git a/guides/micronaut-cloud-trace-base/java/src/main/java/example/micronaut/WarehouseClient.java b/guides/micronaut-cloud-trace-base/java/src/main/java/example/micronaut/WarehouseClient.java index 1a25fb8a5d..64c25e2ef0 100644 --- a/guides/micronaut-cloud-trace-base/java/src/main/java/example/micronaut/WarehouseClient.java +++ b/guides/micronaut-cloud-trace-base/java/src/main/java/example/micronaut/WarehouseClient.java @@ -6,8 +6,8 @@ import io.micronaut.http.client.annotation.Client; import io.micronaut.tracing.annotation.ContinueSpan; import io.micronaut.tracing.annotation.SpanTag; -import io.opentelemetry.extension.annotations.SpanAttribute; -import io.opentelemetry.extension.annotations.WithSpan; +import io.opentelemetry.instrumentation.annotations.SpanAttribute; +import io.opentelemetry.instrumentation.annotations.WithSpan; import java.util.Map; diff --git a/guides/micronaut-cloud-trace-base/kotlin/src/main/kotlin/example/micronaut/InventoryService.kt b/guides/micronaut-cloud-trace-base/kotlin/src/main/kotlin/example/micronaut/InventoryService.kt index f691530cce..2920cb6c40 100644 --- a/guides/micronaut-cloud-trace-base/kotlin/src/main/kotlin/example/micronaut/InventoryService.kt +++ b/guides/micronaut-cloud-trace-base/kotlin/src/main/kotlin/example/micronaut/InventoryService.kt @@ -2,8 +2,8 @@ package example.micronaut import io.opentelemetry.api.trace.Span import io.opentelemetry.api.trace.Tracer -import io.opentelemetry.extension.annotations.SpanAttribute -import io.opentelemetry.extension.annotations.WithSpan +import io.opentelemetry.instrumentation.annotations.SpanAttribute +import io.opentelemetry.instrumentation.annotations.WithSpan import jakarta.inject.Singleton import java.util.concurrent.ConcurrentHashMap import kotlin.math.abs diff --git a/guides/micronaut-cloud-trace-base/kotlin/src/main/kotlin/example/micronaut/WarehouseClient.kt b/guides/micronaut-cloud-trace-base/kotlin/src/main/kotlin/example/micronaut/WarehouseClient.kt index 030ddbe7de..2e77f6ba1c 100644 --- a/guides/micronaut-cloud-trace-base/kotlin/src/main/kotlin/example/micronaut/WarehouseClient.kt +++ b/guides/micronaut-cloud-trace-base/kotlin/src/main/kotlin/example/micronaut/WarehouseClient.kt @@ -7,8 +7,8 @@ import io.micronaut.http.annotation.QueryValue import io.micronaut.http.client.annotation.Client import io.micronaut.tracing.annotation.ContinueSpan import io.micronaut.tracing.annotation.SpanTag -import io.opentelemetry.extension.annotations.SpanAttribute -import io.opentelemetry.extension.annotations.WithSpan +import io.opentelemetry.instrumentation.annotations.SpanAttribute +import io.opentelemetry.instrumentation.annotations.WithSpan @Client("/warehouse") // <1> interface WarehouseClient { diff --git a/guides/micronaut-custom-validation-annotation/metadata.json b/guides/micronaut-custom-validation-annotation/metadata.json index 1069532062..7c5465d736 100644 --- a/guides/micronaut-custom-validation-annotation/metadata.json +++ b/guides/micronaut-custom-validation-annotation/metadata.json @@ -8,7 +8,7 @@ "apps": [ { "name": "default", - "features": ["junit-params"] + "features": ["junit-params", "micronaut-validation"] } ], "languages": ["java"] diff --git a/guides/micronaut-data-access-mybatis/metadata.json b/guides/micronaut-data-access-mybatis/metadata.json index 7154a438bb..49ba27946a 100644 --- a/guides/micronaut-data-access-mybatis/metadata.json +++ b/guides/micronaut-data-access-mybatis/metadata.json @@ -8,7 +8,7 @@ "apps": [ { "name": "default", - "features": ["graalvm", "flyway", "jdbc-hikari", "mybatis", "serialization-jackson"] + "features": ["graalvm", "flyway", "jdbc-hikari", "mybatis", "serialization-jackson", "micronaut-validation"] } ] } diff --git a/guides/micronaut-error-handling/metadata.json b/guides/micronaut-error-handling/metadata.json index 525095f298..84ab5c6eff 100644 --- a/guides/micronaut-error-handling/metadata.json +++ b/guides/micronaut-error-handling/metadata.json @@ -10,7 +10,7 @@ "apps": [ { "name": "default", - "features": ["graalvm", "views-velocity", "geb", "serialization-jackson"] + "features": ["graalvm", "views-velocity", "geb", "serialization-jackson", "micronaut-validation"] } ] } diff --git a/guides/micronaut-metrics/src/main/resources/application.yml b/guides/micronaut-metrics/src/main/resources/application.yml index dc2342d3f3..e34983d688 100644 --- a/guides/micronaut-metrics/src/main/resources/application.yml +++ b/guides/micronaut-metrics/src/main/resources/application.yml @@ -39,7 +39,6 @@ datasources: driverClassName: org.h2.Driver username: sa password: '' - schema-generate: CREATE_DROP dialect: H2 #end::datasource[] netty: diff --git a/guides/micronaut-microstream-persistence/metadata.json b/guides/micronaut-microstream-persistence/metadata.json index e5dc98520b..afea452df8 100644 --- a/guides/micronaut-microstream-persistence/metadata.json +++ b/guides/micronaut-microstream-persistence/metadata.json @@ -8,7 +8,7 @@ "apps": [ { "name": "default", - "features": ["microstream", "serialization-jackson"] + "features": ["microstream", "serialization-jackson", "micronaut-validation"] } ] } diff --git a/guides/micronaut-object-storage-gcp/java/src/test/java/example/micronaut/FakeGcsServerContainer.java b/guides/micronaut-object-storage-gcp/java/src/test/java/example/micronaut/FakeGcsServerContainer.java index 4bbc21c993..6aca6e8bba 100644 --- a/guides/micronaut-object-storage-gcp/java/src/test/java/example/micronaut/FakeGcsServerContainer.java +++ b/guides/micronaut-object-storage-gcp/java/src/test/java/example/micronaut/FakeGcsServerContainer.java @@ -1,32 +1,22 @@ package example.micronaut; -import io.micronaut.core.io.socket.SocketUtils; -import org.testcontainers.containers.FixedHostPortGenericContainer; import org.testcontainers.containers.GenericContainer; -import org.testcontainers.utility.DockerImageName; -public class FakeGcsServerContainer extends FixedHostPortGenericContainer { +class FakeGcsServerContainer extends GenericContainer { - public static final String DEFAULT_IMAGE_NAME = "fsouza/fake-gcs-server:1.40.1"; - public static final int DEFAULT_PORT = 4443; + private static final String DEFAULT_IMAGE_NAME = "fsouza/fake-gcs-server:1.40.1"; + private static final int DEFAULT_PORT = 4443; - private int port; - - public FakeGcsServerContainer(String dockerImageName) { - super(dockerImageName); - } - - @Override - protected void configure() { - super.configure(); - - this.port = SocketUtils.findAvailableTcpPort(); - addFixedExposedPort(port, DEFAULT_PORT); - - withCreateContainerCmdModifier(cmd -> cmd.withEntrypoint("/bin/fake-gcs-server", "-scheme", "http")); + public FakeGcsServerContainer() { + super(DEFAULT_IMAGE_NAME); + this.withExposedPorts(DEFAULT_PORT) + .withCreateContainerCmdModifier(cmd -> cmd.withEntrypoint("/bin/fake-gcs-server", "-scheme", "http")); } - public int getPort() { - return port; + public String getUrl() { + if (!isRunning()) { + start(); + } + return String.format("http://%s:%s", getHost(), getMappedPort(DEFAULT_PORT)); } } diff --git a/guides/micronaut-object-storage-gcp/java/src/test/java/example/micronaut/ProfilePicturesControllerTest.java b/guides/micronaut-object-storage-gcp/java/src/test/java/example/micronaut/ProfilePicturesControllerTest.java index aaa667c1fc..1664a3fd35 100644 --- a/guides/micronaut-object-storage-gcp/java/src/test/java/example/micronaut/ProfilePicturesControllerTest.java +++ b/guides/micronaut-object-storage-gcp/java/src/test/java/example/micronaut/ProfilePicturesControllerTest.java @@ -6,22 +6,17 @@ import com.google.cloud.storage.BucketInfo; import com.google.cloud.storage.Storage; import com.google.cloud.storage.StorageOptions; -import io.micronaut.context.annotation.Bean; import io.micronaut.context.annotation.Factory; import io.micronaut.context.annotation.Primary; import io.micronaut.context.annotation.Property; import io.micronaut.context.annotation.Requires; -import io.micronaut.context.event.BeanCreatedEvent; -import io.micronaut.context.event.BeanCreatedEventListener; -import io.micronaut.core.annotation.NonNull; -import io.micronaut.gcp.GoogleCloudConfiguration; import io.micronaut.objectstorage.googlecloud.GoogleCloudStorageConfiguration; import io.micronaut.test.extensions.junit5.annotation.MicronautTest; import jakarta.inject.Inject; import jakarta.inject.Singleton; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import java.io.IOException; @@ -36,7 +31,8 @@ class ProfilePicturesControllerTest extends AbstractProfilePicturesControllerTes static final String SPEC_NAME = "ProfilePicturesControllerTest"; - static FakeGcsServerContainer fakeGcs = new FakeGcsServerContainer(FakeGcsServerContainer.DEFAULT_IMAGE_NAME); + @Container + static FakeGcsServerContainer fakeGcs = new FakeGcsServerContainer(); @Inject Storage client; @@ -44,25 +40,16 @@ class ProfilePicturesControllerTest extends AbstractProfilePicturesControllerTes @Inject GoogleCloudStorageConfiguration configuration; - @BeforeAll - static void beforeAll() { - fakeGcs.start(); - } - @BeforeEach void beforeEach() { client.create(BucketInfo.newBuilder(configuration.getBucket()).build()); } + @AfterEach void afterEach() { client.get(configuration.getBucket()).delete(); } - @AfterAll - static void afterAll() { - fakeGcs.stop(); - } - @Override protected void assertThatFileIsStored(String key, String expected) throws IOException { BlobId blobId = BlobId.of(configuration.getBucket(), key); @@ -78,9 +65,8 @@ static class FakeGcsFactory { @Singleton @Primary Storage storage() { - String fakeGcsExternalUrl = String.format("http://%s:%s", fakeGcs.getHost(), fakeGcs.getPort()); return StorageOptions.newBuilder() - .setHost(fakeGcsExternalUrl) + .setHost(fakeGcs.getUrl()) .setProjectId("test-project") .setCredentials(NoCredentials.getInstance()) .build() diff --git a/guides/micronaut-scope-types/metadata.json b/guides/micronaut-scope-types/metadata.json index b6a74b8e18..b449781daa 100644 --- a/guides/micronaut-scope-types/metadata.json +++ b/guides/micronaut-scope-types/metadata.json @@ -9,7 +9,7 @@ "apps": [ { "name": "default", - "features": ["junit-params","management"] + "features": ["junit-params","management", "micronaut-validation"] } ] } diff --git a/guides/micronaut-spring-boot/metadata.json b/guides/micronaut-spring-boot/metadata.json index 8857814b54..1610762ae3 100644 --- a/guides/micronaut-spring-boot/metadata.json +++ b/guides/micronaut-spring-boot/metadata.json @@ -8,7 +8,7 @@ "apps": [ { "name": "default", - "features": ["spring-web","spring-boot", "views-thymeleaf"] + "features": ["spring-web","spring-boot", "views-thymeleaf", "micronaut-validation"] } ] } \ No newline at end of file diff --git a/version.txt b/version.txt index 203e6d5c9a..6bd10744ae 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -3.8.9 +3.9.1