Skip to content

Commit

Permalink
Merge pull request #39719 from gsmet/3.9.1-backports-2
Browse files Browse the repository at this point in the history
3.9.1 backports 2
  • Loading branch information
gsmet committed Mar 27, 2024
2 parents 9904341 + d6c9134 commit 4145f02
Show file tree
Hide file tree
Showing 44 changed files with 1,471 additions and 152 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
<java-buildpack-client.version>0.0.6</java-buildpack-client.version>
<org-crac.version>0.1.3</org-crac.version>
<sshd-common.version>2.12.0</sshd-common.version>
<mime4j.version>0.8.9</mime4j.version>
<mime4j.version>0.8.11</mime4j.version>
<mutiny-zero.version>1.0.0</mutiny-zero.version>
<pulsar-client.version>3.0.0</pulsar-client.version>
<async-http-client.version>2.12.3</async-http-client.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.jboss.logging.Logger;

import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.pkg.NativeConfig;
import io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem;
import io.quarkus.deployment.pkg.builditem.NativeImageBuildItem;
Expand All @@ -34,6 +35,7 @@ public class UpxCompressionBuildStep {
*/
private static final String PATH = "PATH";

@BuildStep(onlyIf = NativeBuild.class)
public void compress(NativeConfig nativeConfig, NativeImageRunnerBuildItem nativeImageRunner,
NativeImageBuildItem image,
BuildProducer<UpxCompressedBuildItem> upxCompressedProducer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public Integer updateProject(TargetQuarkusVersionGroup targetQuarkusVersion, Rew
args.add("-PquarkusPluginVersion=" + ToolsUtils.getGradlePluginVersion(props));
args.add("--console");
args.add("plain");
args.add("--no-daemon");
args.add("--stacktrace");
args.add("quarkusUpdate");
if (!StringUtil.isNullOrEmpty(targetQuarkusVersion.platformVersion)) {
Expand Down
264 changes: 214 additions & 50 deletions docs/src/main/asciidoc/security-openid-connect-client.adoc

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

import org.jboss.logging.Logger;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.containers.wait.strategy.WaitAllStrategy;
import org.testcontainers.utility.DockerImageName;

import io.quarkus.datasource.common.runtime.DataSourceUtil;
Expand Down Expand Up @@ -99,16 +100,21 @@ public QuarkusPostgreSQLContainer(Optional<String> imageName, OptionalInt fixedE
super(DockerImageName
.parse(imageName.orElseGet(() -> ConfigureUtil.getDefaultImageNameFor("postgresql")))
.asCompatibleSubstituteFor(DockerImageName.parse(PostgreSQLContainer.IMAGE)));

this.fixedExposedPort = fixedExposedPort;
this.useSharedNetwork = useSharedNetwork;

// Workaround for https://github.com/testcontainers/testcontainers-java/issues/4799.
// The motivation of this custom wait strategy is that Testcontainers fails to start a Postgresql database when it
// has been already initialized.
// This custom wait strategy will work fine regardless of the state of the Postgresql database.
// More information in the issue ticket in Testcontainers.
this.waitStrategy = new LogMessageWaitStrategy()
.withRegEx("(" + READY_REGEX + ")?(" + SKIPPING_INITIALIZATION_REGEX + ")?")
.withTimes(2)

// Added Wait.forListeningPort() for https://github.com/quarkusio/quarkus/issues/25682
// as suggested by https://github.com/testcontainers/testcontainers-java/pull/6309
this.waitStrategy = new WaitAllStrategy()
.withStrategy(Wait.forLogMessage("(" + READY_REGEX + ")?(" + SKIPPING_INITIALIZATION_REGEX + ")?", 2))
.withStrategy(Wait.forListeningPort())
.withStartupTimeout(Duration.of(60L, ChronoUnit.SECONDS));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quarkus.micrometer.runtime.binder;

import java.util.Objects;

import io.micrometer.core.instrument.Tag;
import io.micrometer.core.instrument.binder.http.Outcome;

Expand Down Expand Up @@ -46,30 +48,47 @@ public static Tag outcome(int statusCode) {

/**
* Creates a {@code uri} tag based on the URI of the given {@code request}.
* Falling back to {@code REDIRECTION} for 3xx responses, {@code NOT_FOUND}
* for 404 responses, {@code root} for requests with no path info, and {@code UNKNOWN}
* Falling back to {@code REDIRECTION} for 3xx responses if there wasn't a matched path pattern, {@code NOT_FOUND}
* for 404 responses if there wasn't a matched path pattern, {@code root} for requests with no path info, and
* {@code UNKNOWN}
* for all other requests.
*
* @param pathInfo request path
* @param initialPath initial path before request pattern matching took place. Pass in null if there is pattern matching
* done in the caller.
* @param code status code of the response
* @return the uri tag derived from the request
*/
public static Tag uri(String pathInfo, int code) {
if (code > 0) {
if (code / 100 == 3) {
return URI_REDIRECTION;
} else if (code == 404) {
return URI_NOT_FOUND;
}
}
public static Tag uri(String pathInfo, String initialPath, int code) {
if (pathInfo == null) {
return URI_UNKNOWN;
}
if (pathInfo.isEmpty() || "/".equals(pathInfo)) {
return URI_ROOT;
}

if (code > 0) {
if (code / 100 == 3) {
if (isTemplatedPath(pathInfo, initialPath)) {
return Tag.of("uri", pathInfo);
} else {
return URI_REDIRECTION;
}
} else if (code == 404) {
if (isTemplatedPath(pathInfo, initialPath)) {
return Tag.of("uri", pathInfo);
} else {
return URI_NOT_FOUND;
}
}
}

// Use first segment of request path
return Tag.of("uri", pathInfo);
}

private static boolean isTemplatedPath(String pathInfo, String initialPath) {
// only include the path info if it has been matched to a template (initialPath != pathInfo) to avoid a metrics explosion with lots of entries
return initialPath != null && !Objects.equals(initialPath, pathInfo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void filter(final ClientRequestContext requestContext, final ClientRespon
Timer.Builder builder = Timer.builder(httpMetricsConfig.getHttpClientRequestsName())
.tags(Tags.of(
HttpCommonTags.method(requestContext.getMethod()),
HttpCommonTags.uri(requestPath, statusCode),
HttpCommonTags.uri(requestPath, requestContext.getUri().getPath(), statusCode),
HttpCommonTags.outcome(statusCode),
HttpCommonTags.status(statusCode),
clientName(requestContext)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public static class RequestTracker extends RequestMetricInfo {
this.tags = origin.and(
Tag.of("address", address),
HttpCommonTags.method(method),
HttpCommonTags.uri(path, -1));
HttpCommonTags.uri(path, null, -1));
}

void requestReset() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public HttpRequestMetric responsePushed(LongTaskTimer.Sample socketMetric, HttpM
config.getServerIgnorePatterns());
if (path != null) {
registry.counter(nameHttpServerPush, Tags.of(
HttpCommonTags.uri(path, response.statusCode()),
HttpCommonTags.uri(path, requestMetric.initialPath, response.statusCode()),
VertxMetricsTags.method(method),
VertxMetricsTags.outcome(response),
HttpCommonTags.status(response.statusCode())))
Expand Down Expand Up @@ -153,7 +153,7 @@ public void requestReset(HttpRequestMetric requestMetric) {
Timer.Builder builder = Timer.builder(nameHttpServerRequests)
.tags(Tags.of(
VertxMetricsTags.method(requestMetric.request().method()),
HttpCommonTags.uri(path, 0),
HttpCommonTags.uri(path, requestMetric.initialPath, 0),
Outcome.CLIENT_ERROR.asTag(),
HttpCommonTags.STATUS_RESET));

Expand All @@ -180,7 +180,7 @@ public void responseEnd(HttpRequestMetric requestMetric, HttpResponse response,
Timer.Sample sample = requestMetric.getSample();
Tags allTags = Tags.of(
VertxMetricsTags.method(requestMetric.request().method()),
HttpCommonTags.uri(path, response.statusCode()),
HttpCommonTags.uri(path, requestMetric.initialPath, response.statusCode()),
VertxMetricsTags.outcome(response),
HttpCommonTags.status(response.statusCode()));
if (!httpServerMetricsTagsContributors.isEmpty()) {
Expand Down Expand Up @@ -217,7 +217,7 @@ public LongTaskTimer.Sample connected(LongTaskTimer.Sample sample, HttpRequestMe
config.getServerIgnorePatterns());
if (path != null) {
return LongTaskTimer.builder(nameWebsocketConnections)
.tags(Tags.of(HttpCommonTags.uri(path, 0)))
.tags(Tags.of(HttpCommonTags.uri(path, requestMetric.initialPath, 0)))
.register(registry)
.start();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,21 @@ public void testStatus() {

@Test
public void testUriRedirect() {
Assertions.assertEquals(HttpCommonTags.URI_REDIRECTION, HttpCommonTags.uri("/moved", 301));
Assertions.assertEquals(HttpCommonTags.URI_REDIRECTION, HttpCommonTags.uri("/moved", 302));
Assertions.assertEquals(HttpCommonTags.URI_REDIRECTION, HttpCommonTags.uri("/moved", 304));
Assertions.assertEquals(HttpCommonTags.URI_REDIRECTION, HttpCommonTags.uri("/moved", null, 301));
Assertions.assertEquals(HttpCommonTags.URI_REDIRECTION, HttpCommonTags.uri("/moved", null, 302));
Assertions.assertEquals(HttpCommonTags.URI_REDIRECTION, HttpCommonTags.uri("/moved", null, 304));
Assertions.assertEquals(Tag.of("uri", "/moved/{id}"), HttpCommonTags.uri("/moved/{id}", "/moved/111", 304));
Assertions.assertEquals(HttpCommonTags.URI_ROOT, HttpCommonTags.uri("/", null, 304));
}

@Test
public void testUriDefaults() {
Assertions.assertEquals(HttpCommonTags.URI_ROOT, HttpCommonTags.uri("/", 200));
Assertions.assertEquals(Tag.of("uri", "/known/ok"), HttpCommonTags.uri("/known/ok", 200));
Assertions.assertEquals(HttpCommonTags.URI_NOT_FOUND, HttpCommonTags.uri("/invalid", 404));
Assertions.assertEquals(Tag.of("uri", "/known/bad/request"), HttpCommonTags.uri("/known/bad/request", 400));
Assertions.assertEquals(Tag.of("uri", "/known/server/error"), HttpCommonTags.uri("/known/server/error", 500));
Assertions.assertEquals(HttpCommonTags.URI_ROOT, HttpCommonTags.uri("/", null, 200));
Assertions.assertEquals(HttpCommonTags.URI_ROOT, HttpCommonTags.uri("/", null, 404));
Assertions.assertEquals(Tag.of("uri", "/known/ok"), HttpCommonTags.uri("/known/ok", null, 200));
Assertions.assertEquals(HttpCommonTags.URI_NOT_FOUND, HttpCommonTags.uri("/invalid", null, 404));
Assertions.assertEquals(Tag.of("uri", "/invalid/{id}"), HttpCommonTags.uri("/invalid/{id}", "/invalid/111", 404));
Assertions.assertEquals(Tag.of("uri", "/known/bad/request"), HttpCommonTags.uri("/known/bad/request", null, 400));
Assertions.assertEquals(Tag.of("uri", "/known/server/error"), HttpCommonTags.uri("/known/server/error", null, 500));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ public JsonObject jsonObject(JsonObject input) {
return result;
}

@POST
@Path("jsonObjectWrapper")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public JsonObjectWrapper jsonObjectWrapper(JsonObjectWrapper wrapper) {
var payload = wrapper.payload;
JsonObject result = new JsonObject();
result.put("name", payload.getString("name"));
result.put("age", 50);
result.put("nested", new JsonObject(Collections.singletonMap("foo", "bar")));
result.put("bools", new JsonArray().add(true));
return new JsonObjectWrapper(result);
}

@POST
@Path("jsonArray")
@Produces(MediaType.APPLICATION_JSON)
Expand All @@ -36,4 +50,22 @@ public JsonArray jsonArray(JsonArray input) {
result.add("last");
return result;
}

@POST
@Path("jsonArrayWrapper")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public JsonArrayWrapper jsonArrayWrapper(JsonArrayWrapper wrapper) {
var payload = wrapper.payload;
JsonArray result = payload.copy();
result.add("last");
return new JsonArrayWrapper(result);
}

public record JsonObjectWrapper(JsonObject payload) {
}

public record JsonArrayWrapper(JsonArray payload) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ public void testJsonObject() {
.body("bools[0]", Matchers.equalTo(true));
}

@Test
public void testJsonObjectWrapper() {
RestAssured.with()
.body("{\"payload\": {\"name\": \"Bob\"}}")
.contentType("application/json")
.post("/vertx/jsonObjectWrapper")
.then()
.statusCode(200)
.contentType("application/json")
.body("payload.name", Matchers.equalTo("Bob"))
.body("payload.age", Matchers.equalTo(50))
.body("payload.nested.foo", Matchers.equalTo("bar"))
.body("payload.bools[0]", Matchers.equalTo(true));
}

@Test
public void testJsonArray() {
RestAssured.with()
Expand All @@ -51,4 +66,17 @@ public void testJsonArray() {
.body("[1]", Matchers.equalTo("last"));
}

@Test
public void testJsonArrayWrapper() {
RestAssured.with()
.body("{\"payload\": [\"first\"]}")
.contentType("application/json")
.post("/vertx/jsonArrayWrapper")
.then()
.statusCode(200)
.contentType("application/json")
.body("payload[0]", Matchers.equalTo("first"))
.body("payload[1]", Matchers.equalTo("last"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,7 @@ public void setupEndpoints(ApplicationIndexBuildItem applicationIndexBuildItem,
initConverters.getMethodParam(0));
}))
.setConverterSupplierIndexerExtension(new GeneratedConverterIndexerExtension(
(name) -> new GeneratedClassGizmoAdaptor(generatedClassBuildItemBuildProducer,
applicationClassPredicate.test(name))))
(name) -> new GeneratedClassGizmoAdaptor(generatedClassBuildItemBuildProducer, true)))
.setHasRuntimeConverters(!paramConverterProviders.getParamConverterProviders().isEmpty())
.setClassLevelExceptionMappers(
classLevelExceptionMappers.isPresent() ? classLevelExceptionMappers.get().getMappers()
Expand Down
4 changes: 4 additions & 0 deletions extensions/vertx/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-mutiny-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jackson-spi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
import io.quarkus.jackson.spi.JacksonModuleBuildItem;
import io.quarkus.vertx.runtime.jackson.JsonArrayDeserializer;
import io.quarkus.vertx.runtime.jackson.JsonArraySerializer;
import io.quarkus.vertx.runtime.jackson.JsonObjectDeserializer;
import io.quarkus.vertx.runtime.jackson.JsonObjectSerializer;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.core.spi.JsonFactory;

public class VertxJsonProcessor {
Expand All @@ -24,4 +31,16 @@ void nativeSupport(List<ReinitializeVertxJsonBuildItem> reinitializeVertxJson,
serviceProviderBuildItemBuildProducer
.produce(ServiceProviderBuildItem.allProvidersFromClassPath(JsonFactory.class.getName()));
}

@BuildStep
JacksonModuleBuildItem registerJacksonSerDeser() {
return new JacksonModuleBuildItem.Builder("VertxTypes")
.add(JsonArraySerializer.class.getName(),
JsonArrayDeserializer.class.getName(),
JsonArray.class.getName())
.add(JsonObjectSerializer.class.getName(),
JsonObjectDeserializer.class.getName(),
JsonObject.class.getName())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/**
* Copied from {@code io.vertx.core.json.jackson.BufferDeserializer} as that class is package private
*/
class BufferDeserializer extends JsonDeserializer<Buffer> {
public class BufferDeserializer extends JsonDeserializer<Buffer> {

@Override
public Buffer deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* Copied from {@code io.vertx.core.json.jackson.BufferSerializer} as that class is package private
*/
class BufferSerializer extends JsonSerializer<Buffer> {
public class BufferSerializer extends JsonSerializer<Buffer> {

@Override
public void serialize(Buffer value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
Expand Down

0 comments on commit 4145f02

Please sign in to comment.