Skip to content

Commit

Permalink
Merge pull request #24992 from gsmet/2.8.1-backports-3
Browse files Browse the repository at this point in the history
2.8.1 backports 3
  • Loading branch information
gsmet committed Apr 19, 2022
2 parents 030c699 + 454e480 commit e4f30c5
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 29 deletions.
21 changes: 4 additions & 17 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<smallrye-context-propagation.version>1.2.2</smallrye-context-propagation.version>
<smallrye-reactive-streams-operators.version>1.0.13</smallrye-reactive-streams-operators.version>
<smallrye-reactive-types-converter.version>2.7.0</smallrye-reactive-types-converter.version>
<smallrye-mutiny-vertx-binding.version>2.19.0</smallrye-mutiny-vertx-binding.version>
<smallrye-mutiny-vertx-binding.version>2.21.0</smallrye-mutiny-vertx-binding.version>
<smallrye-reactive-messaging.version>3.15.0</smallrye-reactive-messaging.version>
<smallrye-stork.version>1.1.0</smallrye-stork.version>
<jakarta.activation.version>1.2.1</jakarta.activation.version>
Expand Down Expand Up @@ -107,20 +107,14 @@
<wildfly-client-config.version>1.0.1.Final</wildfly-client-config.version>
<wildfly-elytron.version>1.19.0.Final</wildfly-elytron.version>
<jboss-threads.version>3.4.2.Final</jboss-threads.version>
<vertx.version>4.2.5</vertx.version>
<!--
Temporary fix, the client 4.2.5 does not work in the context of Quarkus (bug in the client)
The fix is shipped with this path release.
This property needs to be removed when we will update to Vert.x 4.2.6 or Vert.x 4.3.0
-->
<vertx.oracle-client.version>4.2.5.1</vertx.oracle-client.version>
<vertx.version>4.2.7</vertx.version>
<httpclient.version>4.5.13</httpclient.version>
<httpcore.version>4.4.15</httpcore.version>
<httpasync.version>4.1.5</httpasync.version>
<cronutils.version>9.1.6</cronutils.version>
<quartz.version>2.3.2</quartz.version>
<h2.version>1.4.197</h2.version> <!-- keep 1.4.197 as newer versions have severe regressions -->
<postgresql-jdbc.version>42.3.3</postgresql-jdbc.version>
<postgresql-jdbc.version>42.3.4</postgresql-jdbc.version>
<mariadb-jdbc.version>3.0.4</mariadb-jdbc.version>
<mysql-jdbc.version>8.0.28</mysql-jdbc.version>
<mssql-jdbc.version>7.2.2.jre8</mssql-jdbc.version>
Expand Down Expand Up @@ -157,7 +151,7 @@
<maven-invoker.version>3.1.0</maven-invoker.version>
<awaitility.version>4.2.0</awaitility.version>
<jboss-logmanager.version>1.0.9</jboss-logmanager.version>
<flyway.version>8.5.7</flyway.version>
<flyway.version>8.5.8</flyway.version>
<yasson.version>1.0.11</yasson.version>
<liquibase.version>4.9.0</liquibase.version>
<snakeyaml.version>1.30</snakeyaml.version>
Expand Down Expand Up @@ -287,13 +281,6 @@
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<!-- Temporarily override the version of the Oracle client, as a bug prevents the usage of the 4.2.5
version in Quarkus, instead, use 4.2.5.1. -->
<groupId>io.vertx</groupId>
<artifactId>vertx-oracle-client</artifactId>
<version>${vertx.oracle-client.version}</version>
</dependency>

<!-- gRPC dependencies, imported as a BOM -->
<dependency>
Expand Down
12 changes: 7 additions & 5 deletions docs/src/main/asciidoc/scripting.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Normally we would link to a Git repository to clone but in this case there is no
[source,java,subs=attributes+]
----
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.quarkus:quarkus-resteasy-reactive:{quarkus-version}
//DEPS io.quarkus.platform:quarkus-bom:{quarkus-version}@pom
//DEPS io.quarkus:quarkus-resteasy-reactive
//JAVAC_OPTIONS -parameters
//JAVA_OPTIONS -Djava.util.logging.manager=org.jboss.logmanager.LogManager
Expand Down Expand Up @@ -105,20 +106,21 @@ You will find at the top a line looking like this:

This line is what on Linux and macOS allows you to run it as a script. On Windows this line is ignored.

The next line
The next lines

[source,java]
----
// //DEPS <dependency1> <dependency2>
----

Is illustrating how you add dependencies to this script. This is a feature of JBang.
illustrate how you add dependencies to this script. This is a feature of JBang.

Go ahead and update this line to include the `quarkus-resteasy-reactive` dependency like so:
Go ahead and update this line to include the `quarkus-bom` and the `quarkus-resteasy-reactive` dependency like so:

[source,java,subs=attributes+]
----
//DEPS io.quarkus:quarkus-resteasy-reactive:{quarkus-version}
//DEPS io.quarkus.platform:quarkus-bom:{quarkus-version}@pom
//DEPS io.quarkus:quarkus-resteasy-reactive
----

Now, run `jbang quarkusapp.java` and you will see JBang resolving this dependency and building the jar with help from Quarkus' JBang integration.
Expand Down
9 changes: 9 additions & 0 deletions extensions/amazon-lambda-http/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/resources/http</directory>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down
9 changes: 9 additions & 0 deletions extensions/amazon-lambda-rest/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/resources/http</directory>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.nio.file.attribute.FileTime;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
Expand All @@ -24,6 +25,7 @@
import java.util.Set;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import org.eclipse.microprofile.config.ConfigProvider;
import org.jboss.logging.Logger;
Expand Down Expand Up @@ -155,7 +157,14 @@ public DevServicesResultBuildItem startKeycloakContainer(
}
}
if (!restartRequired) {
return devService.toBuildItem();
DevServicesResultBuildItem result = devService.toBuildItem();
String usersString = result.getConfig().get(OIDC_USERS);
Map<String, String> users = (usersString == null || usersString.isBlank()) ? Map.of()
: Arrays.stream(usersString.split(","))
.map(s -> s.split("=")).collect(Collectors.toMap(s -> s[0], s -> s[1]));
keycloakBuildItemBuildProducer
.produce(new KeycloakDevServicesConfigBuildItem(result.getConfig(), Map.of(OIDC_USERS, users)));
return result;
}
try {
devService.close();
Expand Down Expand Up @@ -257,6 +266,8 @@ private Map<String, String> prepareConfiguration(
configProperties.put(APPLICATION_TYPE_CONFIG_KEY, oidcApplicationType);
configProperties.put(CLIENT_ID_CONFIG_KEY, oidcClientId);
configProperties.put(CLIENT_SECRET_CONFIG_KEY, oidcClientSecret);
configProperties.put(OIDC_USERS, users.entrySet().stream()
.map(e -> e.toString()).collect(Collectors.joining(",")));

keycloakBuildItemBuildProducer
.produce(new KeycloakDevServicesConfigBuildItem(configProperties, Map.of(OIDC_USERS, users)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,14 @@ public Integer get() {
public ThreadFactory createThreadFactory(LaunchMode launchMode) {
Optional<ClassLoader> nonDevModeTccl = setupThreadFactoryTccl(launchMode);
AtomicInteger threadCount = new AtomicInteger(0);
return runnable -> {
VertxThread thread = createVertxThread(runnable,
"executor-thread-" + threadCount.getAndIncrement(), true, 0, null, launchMode, nonDevModeTccl);
thread.setDaemon(true);
return thread;
return new ThreadFactory() {
@Override
public Thread newThread(Runnable runnable) {
VertxThread thread = createVertxThread(runnable,
"executor-thread-" + threadCount.getAndIncrement(), true, 0, null, launchMode, nonDevModeTccl);
thread.setDaemon(true);
return thread;
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.FORM_PARAM;
import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.HEADER_PARAM;
import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.HTTP_HEADERS;
import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.INSTANT;
import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.INTEGER;
import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.LIST;
import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.LOCAL_DATE;
Expand Down Expand Up @@ -143,7 +144,8 @@ public abstract class EndpointIndexer<T extends EndpointIndexer<T, PARAM, METHOD
DotName.createSimple("org.jboss.resteasy.reactive.server.SimpleResourceInfo"), //TODO: fixme
RESOURCE_INFO)));

private static final Set<DotName> SUPPORT_TEMPORAL_PARAMS = Set.of(LOCAL_DATE, LOCAL_TIME, LOCAL_DATE_TIME, OFFSET_TIME,
private static final Set<DotName> SUPPORT_TEMPORAL_PARAMS = Set.of(INSTANT, LOCAL_DATE, LOCAL_TIME, LOCAL_DATE_TIME,
OFFSET_TIME,
OFFSET_DATE_TIME, ZONED_DATE_TIME);

protected static final Logger log = Logger.getLogger(EndpointIndexer.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.io.OutputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
Expand Down Expand Up @@ -182,6 +183,7 @@ public final class ResteasyReactiveDotNames {
public static final DotName DUMMY_ELEMENT_TYPE = DotName.createSimple(DummyElementType.class.getName());
public static final DotName MULTI_VALUED_MAP = DotName.createSimple(MultivaluedMap.class.getName());
public static final DotName PATH_SEGMENT = DotName.createSimple(PathSegment.class.getName());
public static final DotName INSTANT = DotName.createSimple(Instant.class.getName());
public static final DotName LOCAL_DATE = DotName.createSimple(LocalDate.class.getName());
public static final DotName LOCAL_DATE_TIME = DotName.createSimple(LocalDateTime.class.getName());
public static final DotName LOCAL_TIME = DotName.createSimple(LocalTime.class.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.DATE_FORMAT;
import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.INSTANT;
import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.JAX_RS_ANNOTATIONS_FOR_FIELDS;
import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.JSONP_JSON_ARRAY;
import static org.jboss.resteasy.reactive.common.processor.ResteasyReactiveDotNames.JSONP_JSON_NUMBER;
Expand Down Expand Up @@ -57,6 +58,7 @@
import org.jboss.resteasy.reactive.server.core.parameters.converters.ArrayConverter;
import org.jboss.resteasy.reactive.server.core.parameters.converters.CharParamConverter;
import org.jboss.resteasy.reactive.server.core.parameters.converters.CharacterParamConverter;
import org.jboss.resteasy.reactive.server.core.parameters.converters.InstantParamConverter;
import org.jboss.resteasy.reactive.server.core.parameters.converters.ListConverter;
import org.jboss.resteasy.reactive.server.core.parameters.converters.LoadedParameterConverter;
import org.jboss.resteasy.reactive.server.core.parameters.converters.LocalDateParamConverter;
Expand Down Expand Up @@ -403,6 +405,16 @@ protected void handleTemporalParam(ServerIndexedParameter builder, DotName param
}
}

if (INSTANT.equals(paramType)) {
if (dateFormatInstance != null) {
throw new RuntimeException(contextualizeErrorMessage(
"'java.time.Instant' types must not be annotated with '@DateFormat'",
currentMethodInfo));
}
builder.setConverter(new InstantParamConverter.Supplier());
return;
}

if ((format != null) && (dateTimeFormatterProviderClassName != null)) {
throw new RuntimeException(contextualizeErrorMessage(
"Using both 'format' and 'dateTimeFormatterProvider' is not allowed when using '@DateFormat'",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.jboss.resteasy.reactive.server.core.parameters.converters;

import java.time.Instant;

public class InstantParamConverter implements ParameterConverter {

@Override
public Object convert(Object value) {
return Instant.parse(value.toString());
}

public static class Supplier implements ParameterConverterSupplier {

public Supplier() {
}

@Override
public ParameterConverter get() {
return new InstantParamConverter();
}

@Override
public String getClassName() {
return InstantParamConverter.class.getName();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.jboss.resteasy.reactive.server.vertx.test.simple;

import io.restassured.RestAssured;
import java.time.Duration;
import java.time.Instant;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import org.hamcrest.Matchers;
import org.jboss.resteasy.reactive.RestQuery;
import org.jboss.resteasy.reactive.server.vertx.test.framework.ResteasyReactiveUnitTest;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

public class InstantParamTest {

@RegisterExtension
static ResteasyReactiveUnitTest test = new ResteasyReactiveUnitTest()
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClasses(HelloResource.class));

@Test
public void test() {
RestAssured.get("/hello?instant=1984-08-08T01:02:03Z")
.then().statusCode(200).body(Matchers.equalTo("hello#1984-08-09T01:02:03Z"));
}

@Path("hello")
public static class HelloResource {

@GET
public String helloQuery(@RestQuery Instant instant) {
return "hello#" + instant.plus(Duration.ofDays(1)).toString();
}
}

}

0 comments on commit e4f30c5

Please sign in to comment.