Skip to content

Commit

Permalink
Merge pull request #44984 from gsmet/3.17.4-backports-1
Browse files Browse the repository at this point in the history
[3.17] 3.17.4 backports 1
  • Loading branch information
gsmet authored Dec 8, 2024
2 parents 67e79d6 + bbfba99 commit 040947e
Show file tree
Hide file tree
Showing 16 changed files with 109 additions and 25 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
<dekorate.version>4.1.4</dekorate.version> <!-- Please check with Java Operator SDK team before updating -->
<maven-invoker.version>3.2.0</maven-invoker.version>
<awaitility.version>4.2.2</awaitility.version>
<jboss-logmanager.version>3.1.0.Final</jboss-logmanager.version>
<jboss-logmanager.version>3.1.1.Final</jboss-logmanager.version>
<flyway.version>10.21.0</flyway.version>
<yasson.version>3.0.4</yasson.version>
<!-- liquibase-mongodb is not released everytime with liquibase anymore, but the two versions need to be compatible -->
Expand Down
4 changes: 2 additions & 2 deletions docs/src/main/asciidoc/rest-virtual-threads.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ and in particular, adds the following dependencies:
.build.gradle
----
implementation("io.quarkus:quarkus-rest-jackson")
implementation("quarkus-rest-client-jackson")
implementation("io.quarkus:quarkus-rest-client-jackson")
----

[NOTE]
Expand Down Expand Up @@ -300,4 +300,4 @@ Learn more about virtual threads support on:

- xref:./messaging-virtual-threads.adoc[@RunOnVirtualThread in messaging applications] (this guide covers Apache Kafka)
- xref:./grpc-virtual-threads.adoc[@RunOnVirtualThread in gRPC services]
- xref:./virtual-threads.adoc[the virtual thread reference guide] (include native compilation and containerization)
- xref:./virtual-threads.adoc[the virtual thread reference guide] (include native compilation and containerization)
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.jboss.logging.Logger;
import org.keycloak.representations.idm.RealmRepresentation;
Expand All @@ -24,6 +25,7 @@ public final class KeycloakDevServicesRequiredBuildItem extends MultiBuildItem {

private static final Logger LOG = Logger.getLogger(KeycloakDevServicesProcessor.class);
public static final String OIDC_AUTH_SERVER_URL_CONFIG_KEY = "quarkus.oidc.auth-server-url";
private static final String OIDC_PROVIDER_CONFIG_KEY = "quarkus.oidc.provider";

private final KeycloakDevServicesConfigurator devServicesConfigurator;
private final String authServerUrl;
Expand All @@ -39,8 +41,17 @@ String getAuthServerUrl() {
}

public static KeycloakDevServicesRequiredBuildItem of(KeycloakDevServicesConfigurator devServicesConfigurator,
String authServerUrl, String... dontStartConfigProperties) {
if (shouldStartDevService(dontStartConfigProperties, authServerUrl)) {
String authServerUrl, String... additionalDontStartConfigProperties) {
final Set<String> dontStartConfigProperties = new HashSet<>(Arrays.asList(additionalDontStartConfigProperties));
dontStartConfigProperties.add(authServerUrl);
dontStartConfigProperties.add(OIDC_AUTH_SERVER_URL_CONFIG_KEY);
dontStartConfigProperties.add(OIDC_PROVIDER_CONFIG_KEY);
return of(devServicesConfigurator, authServerUrl, dontStartConfigProperties);
}

private static KeycloakDevServicesRequiredBuildItem of(KeycloakDevServicesConfigurator devServicesConfigurator,
String authServerUrl, Set<String> dontStartConfigProperties) {
if (shouldStartDevService(dontStartConfigProperties)) {
return new KeycloakDevServicesRequiredBuildItem(devServicesConfigurator, authServerUrl);
}
return null;
Expand Down Expand Up @@ -69,10 +80,8 @@ public void customizeDefaultRealm(RealmRepresentation realmRepresentation) {
};
}

private static boolean shouldStartDevService(String[] dontStartConfigProperties, String authServerUrl) {
return Stream
.concat(Stream.of(authServerUrl), Arrays.stream(dontStartConfigProperties))
.allMatch(KeycloakDevServicesRequiredBuildItem::shouldStartDevService);
private static boolean shouldStartDevService(Set<String> dontStartConfigProperties) {
return dontStartConfigProperties.stream().allMatch(KeycloakDevServicesRequiredBuildItem::shouldStartDevService);
}

private static boolean shouldStartDevService(String dontStartConfigProperty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import io.vertx.core.net.PemTrustOptions;
import io.vertx.core.net.SocketAddress;
import io.vertx.grpc.client.GrpcClientChannel;
import io.vertx.grpc.client.GrpcClientOptions;

@SuppressWarnings({ "OptionalIsPresent" })
public class Channels {
Expand Down Expand Up @@ -335,7 +336,9 @@ public static Channel createChannel(String name, Set<String> perClientIntercepto
options.setMetricsName("grpc|" + name);

Vertx vertx = container.instance(Vertx.class).get();
io.vertx.grpc.client.GrpcClient client = io.vertx.grpc.client.GrpcClient.client(vertx, options);
io.vertx.grpc.client.GrpcClient client = io.vertx.grpc.client.GrpcClient.client(vertx,
new GrpcClientOptions().setTransportOptions(options)
.setMaxMessageSize(config.maxInboundMessageSize.orElse(DEFAULT_MAX_MESSAGE_SIZE)));
Channel channel;
if (stork) {
ManagedExecutor executor = container.instance(ManagedExecutor.class).get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ void registerKotlinReflection(final BuildProducer<ReflectiveClassBuildItem> refl
reflectiveClass.produce(ReflectiveClassBuildItem.builder("kotlin.KotlinVersion$Companion[]").constructors(false)
.build());
reflectiveClass.produce(
ReflectiveClassBuildItem.builder("kotlin.collections.EmptyList", "kotlin.collections.EmptyMap").build());
ReflectiveClassBuildItem
.builder("kotlin.collections.EmptyList", "kotlin.collections.EmptyMap", "kotlin.collections.EmptySet")
.build());

nativeResourcePatterns.produce(builder().includePatterns(
"META-INF/.*.kotlin_module$",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.quarkus.oidc.client.registration.deployment.devservices.keycloak;

import static io.quarkus.devservices.keycloak.KeycloakDevServicesRequiredBuildItem.OIDC_AUTH_SERVER_URL_CONFIG_KEY;

import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -55,8 +53,7 @@ public void customizeDefaultRealm(RealmRepresentation realmRepresentation) {
}
};

return KeycloakDevServicesRequiredBuildItem.of(devServicesConfigurator,
OIDC_CLIENT_REG_AUTH_SERVER_URL_CONFIG_KEY, OIDC_AUTH_SERVER_URL_CONFIG_KEY);
return KeycloakDevServicesRequiredBuildItem.of(devServicesConfigurator, OIDC_CLIENT_REG_AUTH_SERVER_URL_CONFIG_KEY);
}

@BuildStep(onlyIf = IsDevelopment.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.quarkus.oidc.client.deployment.devservices.keycloak;

import static io.quarkus.devservices.keycloak.KeycloakDevServicesRequiredBuildItem.OIDC_AUTH_SERVER_URL_CONFIG_KEY;

import java.util.HashMap;

import io.quarkus.deployment.IsDevelopment;
Expand Down Expand Up @@ -35,7 +33,7 @@ KeycloakDevServicesRequiredBuildItem requireKeycloakDevService(KeycloakDevServic
configProperties.put(OIDC_CLIENT_SECRET_CONFIG_KEY, ctx.oidcClientSecret());
}
return configProperties;
}, OIDC_CLIENT_AUTH_SERVER_URL_CONFIG_KEY, OIDC_CLIENT_TOKEN_PATH_CONFIG_KEY, OIDC_AUTH_SERVER_URL_CONFIG_KEY);
}, OIDC_CLIENT_AUTH_SERVER_URL_CONFIG_KEY, OIDC_CLIENT_TOKEN_PATH_CONFIG_KEY);
}

@BuildStep(onlyIf = IsDevelopment.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.quarkus.oidc.client;

import static org.junit.jupiter.api.Assertions.assertTrue;

import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;

/**
* Test Keycloak Dev Service is not started when known social provider is configured
* in Quarkus OIDC extension.
*/
public class OidcClientKeycloakDevServiceStartupTest {

@RegisterExtension
static final QuarkusUnitTest test = new QuarkusUnitTest()
.withApplicationRoot(jar -> jar
.addAsResource(new StringAsset("""
quarkus.oidc.provider=slack
quarkus.oidc.client-id=irrelevant-client-id
"""), "application.properties"))
.setLogRecordPredicate(logRecord -> logRecord != null && logRecord.getMessage() != null
&& logRecord.getMessage().contains("Dev Services for Keycloak started"))
.assertLogRecords(logRecords -> assertTrue(logRecords.isEmpty()));

@Test
public void testDevServiceNotStarted() {
// needs to be here so that log asserter runs after all tests
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.quarkus.oidc.common;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class OidcRequestContextProperties {
Expand All @@ -16,7 +17,7 @@ public OidcRequestContextProperties() {
}

public OidcRequestContextProperties(Map<String, Object> properties) {
this.properties = properties;
this.properties = new HashMap<>(properties);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.quarkus.oidc.common.runtime;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import java.util.Map;

import org.junit.jupiter.api.Test;

import io.quarkus.oidc.common.OidcRequestContextProperties;

public class OidcRequestContextPropertiesTest {

@Test
public void testModifyPropertiesDefaultConstructor() throws Exception {
OidcRequestContextProperties props = new OidcRequestContextProperties();
assertNull(props.get("a"));
props.put("a", "value");
assertEquals("value", props.get("a"));
}

@Test
public void testModifyExistinProperties() throws Exception {
OidcRequestContextProperties props = new OidcRequestContextProperties(Map.of("a", "value"));
assertEquals("value", props.get("a"));
props.put("a", "avalue");
assertEquals("avalue", props.get("a"));
props.put("b", "bvalue");
assertEquals("bvalue", props.get("b"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class KeycloakDevServiceRequiredBuildStep {
private static final Logger LOG = Logger.getLogger(KeycloakDevServiceRequiredBuildStep.class);
private static final String CONFIG_PREFIX = "quarkus.oidc.";
private static final String TENANT_ENABLED_CONFIG_KEY = CONFIG_PREFIX + "tenant-enabled";
private static final String PROVIDER_CONFIG_KEY = CONFIG_PREFIX + "provider";
private static final String APPLICATION_TYPE_CONFIG_KEY = CONFIG_PREFIX + "application-type";
private static final String CLIENT_ID_CONFIG_KEY = CONFIG_PREFIX + "client-id";
private static final String CLIENT_SECRET_CONFIG_KEY = CONFIG_PREFIX + "credentials.secret";
Expand All @@ -42,7 +41,7 @@ KeycloakDevServicesRequiredBuildItem requireKeycloakDevService(KeycloakDevServic
configProperties.put(CLIENT_SECRET_CONFIG_KEY, ctx.oidcClientSecret());
}
return configProperties;
}, OIDC_AUTH_SERVER_URL_CONFIG_KEY, PROVIDER_CONFIG_KEY);
}, OIDC_AUTH_SERVER_URL_CONFIG_KEY);
}

private static boolean isOidcTenantEnabled() {
Expand Down
2 changes: 1 addition & 1 deletion independent-projects/bootstrap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<guava.failureaccess.version>1.0.1</guava.failureaccess.version><!-- keep in sync with guava.version -->
<j2objc.annotations.version>2.8</j2objc.annotations.version><!-- keep in sync with guava.version -->
<shrinkwrap-depchain.version>1.2.6</shrinkwrap-depchain.version>
<jboss-logmanager.version>3.1.0.Final</jboss-logmanager.version>
<jboss-logmanager.version>3.1.1.Final</jboss-logmanager.version>
<slf4j-jboss-logmanager.version>1.1.0.Final</slf4j-jboss-logmanager.version>
<slf4j-api.version>2.0.6</slf4j-api.version>
<graal-sdk.version>23.1.0</graal-sdk.version>
Expand Down
2 changes: 1 addition & 1 deletion independent-projects/resteasy-reactive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<maven.version>3.9.9</maven.version>
<assertj.version>3.26.3</assertj.version>
<jboss-logging.version>3.6.1.Final</jboss-logging.version>
<jboss-logmanager.version>3.1.0.Final</jboss-logmanager.version>
<jboss-logmanager.version>3.1.1.Final</jboss-logmanager.version>
<jakarta.annotation-api.version>3.0.0</jakarta.annotation-api.version>
<gizmo.version>1.8.0</gizmo.version>
<jakarta.persistence-api.version>3.1.0</jakarta.persistence-api.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,11 @@ class GreetingResource {
return emptyMap<String, String>()
}

@GET
@Path("emptySet")
fun emptySet(): Set<String> {
return emptySet<String>()
}

fun reflect() = "hello, world"
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,9 @@ open class ResourceTest {
fun testEmptyMap() {
When { get("/emptyList") } Then { statusCode(200) }
}

@Test
fun testEmptySet() {
When { get("/emptySet") } Then { statusCode(200) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void testGetAccessTokenWithConfiguredExpiresIn() {
long expectedExpiresAt = now + 5;
long accessTokenExpiresAt = Long.valueOf(data[1]);
assertTrue(accessTokenExpiresAt >= expectedExpiresAt
&& accessTokenExpiresAt <= expectedExpiresAt + 2);
&& accessTokenExpiresAt <= expectedExpiresAt + 4);
}

@Test
Expand Down

0 comments on commit 040947e

Please sign in to comment.