Skip to content

Commit

Permalink
Merge pull request #42420 from gsmet/3.13.2-backports-1
Browse files Browse the repository at this point in the history
[3.13] 3.13.2 backports 1
  • Loading branch information
gsmet committed Aug 9, 2024
2 parents 28e1bf1 + 5461839 commit fb443aa
Show file tree
Hide file tree
Showing 96 changed files with 348 additions and 131 deletions.
4 changes: 2 additions & 2 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<opentelemetry.version>1.39.0</opentelemetry.version>
<opentelemetry-alpha.version>2.5.0-alpha</opentelemetry-alpha.version>
<opentelemetry-semconv.version>1.25.0-alpha</opentelemetry-semconv.version>
<quarkus-http.version>5.3.0</quarkus-http.version>
<quarkus-http.version>5.3.1</quarkus-http.version>
<micrometer.version>1.12.5</micrometer.version><!-- keep in sync with hdrhistogram -->
<hdrhistogram.version>2.1.12</hdrhistogram.version><!-- keep in sync with micrometer -->
<google-auth.version>0.22.0</google-auth.version>
Expand All @@ -55,7 +55,7 @@
<smallrye-health.version>4.1.0</smallrye-health.version>
<smallrye-metrics.version>4.0.0</smallrye-metrics.version>
<smallrye-open-api.version>3.10.0</smallrye-open-api.version>
<smallrye-graphql.version>2.9.0</smallrye-graphql.version>
<smallrye-graphql.version>2.9.1</smallrye-graphql.version>
<smallrye-fault-tolerance.version>6.3.0</smallrye-fault-tolerance.version>
<smallrye-jwt.version>4.5.3</smallrye-jwt.version>
<smallrye-context-propagation.version>2.1.2</smallrye-context-propagation.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand All @@ -19,6 +20,10 @@
import org.jboss.jandex.Type;

public class ClassComparisonUtil {
private static final Set<DotName> IGNORED_ANNOTATIONS = Set.of(
DotName.createSimple("kotlin.jvm.internal.SourceDebugExtension"),
DotName.createSimple("kotlin.Metadata"));

static boolean isSameStructure(ClassInfo clazz, ClassInfo old) {
if (clazz.flags() != old.flags()) {
return false;
Expand Down Expand Up @@ -161,6 +166,9 @@ private static void methodMap(Collection<AnnotationInstance> b, List<AnnotationI
}

private static boolean compareAnnotation(AnnotationInstance a, AnnotationInstance b) {
if (IGNORED_ANNOTATIONS.contains(a.name())) {
return true;
}
List<AnnotationValue> valuesA = a.values();
List<AnnotationValue> valuesB = b.values();
if (valuesA.size() != valuesB.size()) {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/hibernate-orm.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ Since we're targeting CockroachDB here, we're passing the CockroachDB version, n
<2> Set the Hibernate ORM dialect.

[[hibernate-dialect-varying-database]]
== Varying database
==== Varying database

When enabling <<database-approach,database multi-tenancy>>,
Hibernate ORM will use multiple datasources at runtime for the same persistence unit,
Expand Down
6 changes: 3 additions & 3 deletions docs/src/main/asciidoc/security-keycloak-authorization.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ For example:
quarkus.keycloak.policy-enforcer.enable=true
# Default Tenant
quarkus.oidc.auth-server-url=${keycloak.url}/realms/quarkus
quarkus.oidc.auth-server-url=${keycloak.url:replaced-by-test-resource}/realms/quarkus
quarkus.oidc.client-id=quarkus-app
quarkus.oidc.credentials.secret=secret
Expand All @@ -535,7 +535,7 @@ quarkus.keycloak.policy-enforcer.paths.1.claim-information-point.claims.static-c
# Service Tenant
quarkus.oidc.service-tenant.auth-server-url=${keycloak.url}/realms/quarkus
quarkus.oidc.service-tenant.auth-server-url=${keycloak.url:replaced-by-test-resource}/realms/quarkus
quarkus.oidc.service-tenant.client-id=quarkus-app
quarkus.oidc.service-tenant.credentials.secret=secret
Expand All @@ -547,7 +547,7 @@ quarkus.keycloak.service-tenant.policy-enforcer.paths.1.claim-information-point.
# WebApp Tenant
quarkus.oidc.webapp-tenant.auth-server-url=${keycloak.url}/realms/quarkus
quarkus.oidc.webapp-tenant.auth-server-url=${keycloak.url:replaced-by-test-resource}/realms/quarkus
quarkus.oidc.webapp-tenant.client-id=quarkus-app
quarkus.oidc.webapp-tenant.credentials.secret=secret
quarkus.oidc.webapp-tenant.application-type=web-app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ For example:
[source, properties]
----
# keycloak.url is set by OidcWiremockTestResource
quarkus.oidc.auth-server-url=${keycloak.url}/realms/quarkus/
quarkus.oidc.auth-server-url=${keycloak.url:replaced-by-test-resource}/realms/quarkus/
quarkus.oidc.client-id=quarkus-service-app
quarkus.oidc.application-type=service
----
Expand Down Expand Up @@ -914,7 +914,7 @@ Prepare the REST test endpoint and set `application.properties` as outlined in t
[source, properties]
----
# keycloak.url is set by KeycloakTestResourceLifecycleManager
quarkus.oidc.auth-server-url=${keycloak.url}/realms/quarkus/
quarkus.oidc.auth-server-url=${keycloak.url:replaced-by-test-resource}/realms/quarkus/
quarkus.oidc.client-id=quarkus-service-app
quarkus.oidc.credentials=secret
quarkus.oidc.application-type=service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1737,7 +1737,7 @@ For example:
[source, properties]
----
# keycloak.url is set by OidcWiremockTestResource
quarkus.oidc.auth-server-url=${keycloak.url}/realms/quarkus/
quarkus.oidc.auth-server-url=${keycloak.url:replaced-by-test-resource}/realms/quarkus/
quarkus.oidc.client-id=quarkus-web-app
quarkus.oidc.credentials.secret=secret
quarkus.oidc.application-type=web-app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ Set `application.properties`, for example:
[source, properties]
----
# Use the 'keycloak.url' property set by the test KeycloakRealmResourceManager
quarkus.oidc-client.auth-server-url=${keycloak.url}
quarkus.oidc-client.auth-server-url=${keycloak.url:replaced-by-test-resource}
quarkus.oidc-client.discovery-enabled=false
quarkus.oidc-client.token-path=/tokens
quarkus.oidc-client.client-id=quarkus-service-app
Expand Down
2 changes: 2 additions & 0 deletions docs/src/main/asciidoc/websockets-next-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public class ChatWebSocket {
Thus, client can connect to this web socket endpoint using `ws://localhost:8080/chat/your-name`.
If TLS is used, the URL is `wss://localhost:8443/chat/your-name`.

NOTE: The endpoint path is relative to the xref:http-reference.adoc#context-path[root context] configured by the `quarkus.http.root-path` (which is `/` by default). For example, if you add `quarkus.http.root-path=/api` to your `application.properties` then a client can connect to this endpoint using `http://localhost:8080/api/chat/the-name`.

[[client-endpoints]]
=== Client endpoints

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public CheckCrossReferences(Path srcDir, Path referenceIndexPath)

if (!Files.exists(referenceIndexPath) || !Files.isReadable(referenceIndexPath)) {
throw new IllegalStateException(
String.format("Reference index does not exist or is not readable", referenceIndexPath.toAbsolutePath()));
String.format("Reference index %s does not exist or is not readable", referenceIndexPath.toAbsolutePath()));
}

ObjectMapper om = new ObjectMapper(new YAMLFactory().enable(YAMLGenerator.Feature.MINIMIZE_QUOTES));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public String delete() {
AuditReader auditReader = AuditReaderFactory.get(em);
List<Number> revisions = auditReader.getRevisions(MyAuditedEntity.class, entity.getId());
if (revisions.size() != 2) {
throw new IllegalStateException(String.format("found {} revisions", revisions.size()));
throw new IllegalStateException(String.format("found %d revisions", revisions.size()));
}

for (Number revision : revisions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public String save(String name) {
AuditReader auditReader = AuditReaderFactory.get(em);
List<Number> revisions = auditReader.getRevisions(MyAuditedEntity.class, entity.getId());
if (revisions.size() != 2) {
throw new IllegalStateException(String.format("found {} revisions", revisions.size()));
throw new IllegalStateException(String.format("found %d revisions", revisions.size()));
}

MyRevisionEntity revEntity = auditReader.findRevision(MyRevisionEntity.class, revisions.get(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,20 +426,6 @@ enum IdOptimizerType {
* Assumes the value retrieved from the table/sequence is the lower end of the pool.
*
* Upon retrieving value `N`, the new pool of identifiers will go from `N` to `N + <allocation size> - 1`, inclusive.
* `pooled`::
* Assumes the value retrieved from the table/sequence is the higher end of the pool.
* +
* Upon retrieving value `N`, the new pool of identifiers will go from `N - <allocation size>` to `N + <allocation size>
* - 1`, inclusive.
* +
* The first value, `1`, is handled differently to avoid negative identifiers.
* +
* Use this to get the legacy behavior of Quarkus 2 / Hibernate ORM 5 or older.
* `none`::
* No optimizer, resulting in a database call each and every time an identifier value is needed from the generator.
* +
* Not recommended in production environments:
* may result in degraded performance and/or frequent gaps in identifier values.
*
* @asciidoclet
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,21 @@ public void configureRegistries(MicrometerConfig config,
}
}

List<AutoCloseable> autoCloseables = new ArrayList<>();

// Base JVM Metrics
if (config.checkBinderEnabledWithDefault(() -> config.binder.jvm)) {
new ClassLoaderMetrics().bindTo(Metrics.globalRegistry);
new JvmHeapPressureMetrics().bindTo(Metrics.globalRegistry);
JvmHeapPressureMetrics jvmHeapPressureMetrics = new JvmHeapPressureMetrics();
jvmHeapPressureMetrics.bindTo(Metrics.globalRegistry);
autoCloseables.add(jvmHeapPressureMetrics);
new JvmMemoryMetrics().bindTo(Metrics.globalRegistry);
new JvmThreadMetrics().bindTo(Metrics.globalRegistry);
new JVMInfoBinder().bindTo(Metrics.globalRegistry);
if (ImageMode.current() == ImageMode.JVM) {
new JvmGcMetrics().bindTo(Metrics.globalRegistry);
JvmGcMetrics jvmGcMetrics = new JvmGcMetrics();
jvmGcMetrics.bindTo(Metrics.globalRegistry);
autoCloseables.add(jvmGcMetrics);
}
}

Expand Down Expand Up @@ -149,6 +155,14 @@ public void run() {
meterRegistry.close();
Metrics.removeRegistry(meterRegistry);
}
// iterate over the auto-closeables and close them
for (AutoCloseable autoCloseable : autoCloseables) {
try {
autoCloseable.close();
} catch (Exception e) {
log.error("Error closing", e);
}
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ public void startRecoveryService(NarayanaJtaRecorder recorder,
@BuildStep(onlyIf = IsTest.class)
void testTx(BuildProducer<GeneratedBeanBuildItem> generatedBeanBuildItemBuildProducer,
BuildProducer<AdditionalBeanBuildItem> additionalBeans) {

if (!testTransactionOnClassPath()) {
return;
}

//generate the annotated interceptor with gizmo
//all the logic is in the parent, but we don't have access to the
//binding annotation here
Expand All @@ -219,6 +224,15 @@ void testTx(BuildProducer<GeneratedBeanBuildItem> generatedBeanBuildItemBuildPro
.addBeanClass(TEST_TRANSACTION).build());
}

private static boolean testTransactionOnClassPath() {
try {
Class.forName(TEST_TRANSACTION, false, Thread.currentThread().getContextClassLoader());
return true;
} catch (ClassNotFoundException ignored) {
return false;
}
}

@BuildStep
public ContextConfiguratorBuildItem transactionContext(ContextRegistrationPhaseBuildItem contextRegistrationPhase) {
return new ContextConfiguratorBuildItem(contextRegistrationPhase.getContext()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ public static void setHttpClientOptions(OidcCommonConfig oidcConfig, HttpClientO
}
} catch (IOException ex) {
throw new ConfigurationException(String.format(
"OIDC truststore file does not exist or can not be read",
oidcConfig.tls.trustStoreFile.get().toString()), ex);
"OIDC truststore file %s does not exist or can not be read",
oidcConfig.tls.trustStoreFile.get()), ex);
}
}
if (oidcConfig.tls.keyStoreFile.isPresent()) {
Expand All @@ -182,8 +182,8 @@ public static void setHttpClientOptions(OidcCommonConfig oidcConfig, HttpClientO

} catch (IOException ex) {
throw new ConfigurationException(String.format(
"OIDC keystore file does not exist or can not be read",
oidcConfig.tls.keyStoreFile.get().toString()), ex);
"OIDC keystore file %s does not exist or can not be read",
oidcConfig.tls.keyStoreFile.get()), ex);
}
}
Optional<ProxyOptions> proxyOpt = toProxyOptions(oidcConfig.getProxy());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ public int executeUpdate(Class<?> entityClass, String panacheQuery, Object... pa

try {
String updateQuery = PanacheJpaUtil.createUpdateQuery(entityClass, panacheQuery, paramCount(params));
return bindParameters(getSession(DEFAULT_PERSISTENCE_UNIT_NAME).createMutationQuery(updateQuery), params)
return bindParameters(getSession(entityClass).createMutationQuery(updateQuery), params)
.executeUpdate();
} catch (RuntimeException x) {
throw NamedQueryUtil.checkForNamedQueryMistake(x, panacheQuery);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,10 @@ public <T extends Entity> T singleResult() {
public <T extends Entity> Optional<T> singleResultOptional() {
SelectionQuery hibernateQuery = createQuery();
try (NonThrowingCloseable c = applyFilters()) {
return hibernateQuery.uniqueResultOptional();
// Yes, there's a much nicer hibernateQuery.uniqueResultOptional() BUT
// it throws org.hibernate.NonUniqueResultException instead of a jakarta.persistence.NonUniqueResultException
// and at this point changing it would be a breaking change >_<
return Optional.ofNullable((T) hibernateQuery.getSingleResultOrNull());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public final class PanacheJpaCommonResourceProcessor {
@BuildStep(onlyIf = IsTest.class)
void testTx(BuildProducer<GeneratedBeanBuildItem> generatedBeanBuildItemBuildProducer,
BuildProducer<AdditionalBeanBuildItem> additionalBeans) {

if (!testReactiveTransactionOnClassPath()) {
return;
}

//generate the annotated interceptor with gizmo
//all the logic is in the parent, but we don't have access to the
//binding annotation here
Expand All @@ -76,6 +81,15 @@ void testTx(BuildProducer<GeneratedBeanBuildItem> generatedBeanBuildItemBuildPro
.addBeanClass(TEST_REACTIVE_TRANSACTION).build());
}

private static boolean testReactiveTransactionOnClassPath() {
try {
Class.forName(TEST_REACTIVE_TRANSACTION, false, Thread.currentThread().getContextClassLoader());
return true;
} catch (ClassNotFoundException ignored) {
return false;
}
}

@BuildStep
void registerInterceptors(BuildProducer<AdditionalBeanBuildItem> additionalBeans) {
AdditionalBeanBuildItem.Builder builder = AdditionalBeanBuildItem.builder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ boolean isEnumConstantMessageKey(String key, IndexView index, ClassInfo bundleIn
return true;
}
throw new MessageBundleException(
String.format("%s is not an enum constant of %: %s", constant, maybeEnum, key));
String.format("%s is not an enum constant of %s: %s", constant, maybeEnum, key));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class ModifyingQueryWithFlushAndClearTest {
public void setUp() {
final User user = getUser("JOHN");
user.setLoginCounter(0);
user.getLoginEvents().clear();
repo.save(user);
}

Expand Down Expand Up @@ -69,8 +70,9 @@ public void testNoAutoFlush() {

final User verifyUser = getUser("JOHN");
// processLoginEvents did not see the new login event
assertThat(verifyUser.getLoginEvents()).hasSize(1);
final boolean allProcessed = verifyUser.getLoginEvents().stream()
.allMatch(loginEvent -> loginEvent.isProcessed());
.allMatch(LoginEvent::isProcessed);
assertThat(allProcessed).describedAs("all LoginEvents are marked as processed").isFalse();
}

Expand All @@ -83,8 +85,9 @@ public void testAutoFlush() {
repo.processLoginEventsPlainAutoClearAndFlush();

final User verifyUser = getUser("JOHN");
assertThat(verifyUser.getLoginEvents()).hasSize(1);
final boolean allProcessed = verifyUser.getLoginEvents().stream()
.allMatch(loginEvent -> loginEvent.isProcessed());
.allMatch(LoginEvent::isProcessed);
assertThat(allProcessed).describedAs("all LoginEvents are marked as processed").isTrue();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ public static void clear(Class<?> clazz) {
}

public static void flush(Class<?> clazz) {
Panache.getSession(clazz).clear();
Panache.getSession(clazz).flush();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ private static VertxOptions convertToVertxOptions(VertxConfiguration conf, Vertx
.setClassPathResolvingEnabled(conf.classpathResolving());

String fileCacheDir = System.getProperty(CACHE_DIR_BASE_PROP_NAME);
if (fileCacheDir != null) {
if (fileCacheDir == null) {
fileCacheDir = conf.cacheDirectory().orElse(null);
}

Expand Down
Loading

0 comments on commit fb443aa

Please sign in to comment.