Skip to content

Commit

Permalink
Merge branch 'main' into conditionalize-security-content
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfedh authored May 15, 2024
2 parents 91bdad2 + 4c78b89 commit 57a8553
Show file tree
Hide file tree
Showing 67 changed files with 1,634 additions and 812 deletions.
10 changes: 5 additions & 5 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<angus-activation.version>2.0.2</angus-activation.version>
<bouncycastle.version>1.78.1</bouncycastle.version>
<bouncycastle.fips.version>1.0.2.5</bouncycastle.fips.version>
<bouncycastle.tls.fips.version>1.0.18</bouncycastle.tls.fips.version>
<bouncycastle.tls.fips.version>1.0.19</bouncycastle.tls.fips.version>
<expressly.version>5.0.0</expressly.version>
<findbugs.version>3.0.2</findbugs.version>
<jandex.version>3.1.8</jandex.version>
Expand Down Expand Up @@ -166,7 +166,7 @@
<maven-invoker.version>3.2.0</maven-invoker.version>
<awaitility.version>4.2.1</awaitility.version>
<jboss-logmanager.version>3.0.6.Final</jboss-logmanager.version>
<flyway.version>10.12.0</flyway.version>
<flyway.version>10.13.0</flyway.version>
<yasson.version>3.0.3</yasson.version>
<!-- liquibase-mongodb is not released everytime with liquibase anymore, but the two versions need to be compatible -->
<liquibase.version>4.27.0</liquibase.version>
Expand Down Expand Up @@ -194,7 +194,7 @@
<jib-core.version>0.27.0</jib-core.version>
<google-http-client.version>1.44.1</google-http-client.version>
<scram-client.version>2.1</scram-client.version>
<picocli.version>4.7.5</picocli.version>
<picocli.version>4.7.6</picocli.version>
<google-cloud-functions.version>1.1.0</google-cloud-functions.version>
<commons-compress.version>1.26.1</commons-compress.version> <!-- Please check with Java Operator SDK / Fabric8 team before updating -->
<commons-text.version>1.11.0</commons-text.version>
Expand All @@ -205,8 +205,8 @@
<avro.version>1.11.3</avro.version>
<apicurio-registry.version>2.5.10.Final</apicurio-registry.version>
<apicurio-common-rest-client.version>0.1.18.Final</apicurio-common-rest-client.version> <!-- must be the version Apicurio Registry uses -->
<testcontainers.version>1.19.7</testcontainers.version> <!-- Make sure to also update docker-java.version to match its needs -->
<docker-java.version>3.3.5</docker-java.version> <!-- must be the version Testcontainers use -->
<testcontainers.version>1.19.8</testcontainers.version> <!-- Make sure to also update docker-java.version to match its needs -->
<docker-java.version>3.3.6</docker-java.version> <!-- must be the version Testcontainers use -->
<!-- Check the compatibility matrix (https://github.com/opensearch-project/opensearch-testcontainers) before upgrading: -->
<opensearch-testcontainers.version>2.0.0</opensearch-testcontainers.version>
<com.dajudge.kindcontainer>1.4.5</com.dajudge.kindcontainer>
Expand Down
15 changes: 12 additions & 3 deletions bom/dev-ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<description>Dependency management for dev-ui. Importable by third party extension developers.</description>

<properties>
<vaadin.version>24.3.11</vaadin.version>
<vaadin.version>24.3.13</vaadin.version>
<lit.version>3.1.3</lit.version>
<lit-element.version>4.0.5</lit-element.version>
<lit-html.version>3.1.3</lit-html.version>
Expand All @@ -28,10 +28,11 @@
<vaadin-router.version>1.7.5</vaadin-router.version>
<lit-state.version>1.7.0</lit-state.version>
<echarts.version>5.5.0</echarts.version>
<codeblock.version>1.0.13</codeblock.version>
<es-module-shims.version>1.9.0</es-module-shims.version>
<path-to-regexp.version>2.4.0</path-to-regexp.version>

<codeblock.version>1.0.16</codeblock.version>
<qomponent.version>1.0.0</qomponent.version>

<hpcc-js-wasm.version>2.15.3</hpcc-js-wasm.version>
<yargs.version>17.7.2</yargs.version>
<cliui.version>8.0.1</cliui.version>
Expand Down Expand Up @@ -268,6 +269,14 @@
<scope>runtime</scope>
</dependency>

<!-- Qomponent -->
<dependency>
<groupId>org.mvnpm.at.mvnpm</groupId>
<artifactId>qomponent</artifactId>
<version>${qomponent.version}</version>
<scope>runtime</scope>
</dependency>

<!-- Polyfill for importmaps -->
<dependency>
<groupId>org.mvnpm</groupId>
Expand Down
2 changes: 1 addition & 1 deletion build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<kotlin.version>1.9.23</kotlin.version>
<dokka.version>1.9.20</dokka.version>
<scala.version>2.13.12</scala.version>
<scala-maven-plugin.version>4.9.0</scala-maven-plugin.version>
<scala-maven-plugin.version>4.9.1</scala-maven-plugin.version>
<!-- not pretty but this is used in the codestarts and we don't want to break compatibility -->
<scala-plugin.version>${scala-maven-plugin.version}</scala-plugin.version>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1200,20 +1200,17 @@ public void prepare(MethodContext context) {

Set<String> handledProperties = new HashSet<>();
Property[] desc = PropertyUtils.getPropertyDescriptors(param);
FieldsHelper fieldsHelper = new FieldsHelper(param.getClass());
for (Property i : desc) {
if (!i.getDeclaringClass().getPackageName().startsWith("java.")) {
// check if the getter is ignored
if ((i.getReadMethod() != null) && RecordingAnnotationsUtil.isIgnored(i.getReadMethod())) {
continue;
}
// check if the matching field is ignored
try {
Field field = param.getClass().getDeclaredField(i.getName());
if (ignoreField(field)) {
continue;
}
} catch (NoSuchFieldException ignored) {

Field field = fieldsHelper.getDeclaredField(i.getName());
if (field != null && ignoreField(field)) {
continue;
}
}
Integer ctorParamIndex = constructorParamNameMap.remove(i.name);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.quarkus.deployment.recording;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

final class FieldsHelper {

private final Map<String, Field> fields;

public FieldsHelper(final Class<?> aClass) {
final Field[] declaredFields = aClass.getDeclaredFields();
this.fields = new HashMap<>(declaredFields.length);
for (Field field : declaredFields) {
this.fields.put(field.getName(), field);
}
}

//Returns the matching Field, or null if not existing
public Field getDeclaredField(final String name) {
return fields.get(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public Property[] apply(Class<?> type) {
if (existingGetter == null || existingGetter.getReturnType().isAssignableFrom(i.getReturnType())) {
getters.put(name, i);
}
} else if (i.getName().startsWith("is") && i.getName().length() > 3 && i.getParameterCount() == 0
} else if (i.getName().startsWith("is") && i.getName().length() > 2 && i.getParameterCount() == 0
&& (i.getReturnType() == boolean.class || i.getReturnType() == Boolean.class)) {
String name = Character.toLowerCase(i.getName().charAt(2)) + i.getName().substring(3);
isGetters.put(name, i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Constructor;
import java.util.HashSet;
import java.util.List;
import java.util.ServiceLoader;
import java.util.Set;

Expand All @@ -13,8 +12,8 @@

final class RecordingAnnotationsUtil {

static final List<Class<? extends Annotation>> IGNORED_PROPERTY_ANNOTATIONS;
static final List<Class<? extends Annotation>> RECORDABLE_CONSTRUCTOR_ANNOTATIONS;
private static final Class<? extends Annotation>[] IGNORED_PROPERTY_ANNOTATIONS;
private static final Class<? extends Annotation>[] RECORDABLE_CONSTRUCTOR_ANNOTATIONS;

static {
Set<Class<? extends Annotation>> ignoredPropertyAnnotations = new HashSet<>();
Expand All @@ -33,30 +32,32 @@ final class RecordingAnnotationsUtil {
}
}

IGNORED_PROPERTY_ANNOTATIONS = List.copyOf(ignoredPropertyAnnotations);
RECORDABLE_CONSTRUCTOR_ANNOTATIONS = List.copyOf(recordableConstructorAnnotations);
IGNORED_PROPERTY_ANNOTATIONS = ignoredPropertyAnnotations.toArray(new Class[0]);
RECORDABLE_CONSTRUCTOR_ANNOTATIONS = recordableConstructorAnnotations.toArray(new Class[0]);
}

private RecordingAnnotationsUtil() {
}

static boolean isIgnored(AccessibleObject object) {
for (int i = 0; i < IGNORED_PROPERTY_ANNOTATIONS.size(); i++) {
Class<? extends Annotation> annotation = IGNORED_PROPERTY_ANNOTATIONS.get(i);
if (object.isAnnotationPresent(annotation)) {
return true;
}
}
return false;
static boolean isIgnored(final AccessibleObject object) {
return annotationsMatch(object.getDeclaredAnnotations(), IGNORED_PROPERTY_ANNOTATIONS);
}

static boolean isRecordableConstructor(Constructor<?> ctor) {
for (int i = 0; i < RECORDABLE_CONSTRUCTOR_ANNOTATIONS.size(); i++) {
Class<? extends Annotation> annotation = RECORDABLE_CONSTRUCTOR_ANNOTATIONS.get(i);
if (ctor.isAnnotationPresent(annotation)) {
return true;
static boolean isRecordableConstructor(final Constructor<?> ctor) {
return annotationsMatch(ctor.getDeclaredAnnotations(), RECORDABLE_CONSTRUCTOR_ANNOTATIONS);
}

private static boolean annotationsMatch(
final Annotation[] declaredAnnotations,
final Class<? extends Annotation>[] typesToCheck) {
for (Class<? extends Annotation> annotation : typesToCheck) {
for (Annotation declaredAnnotation : declaredAnnotations) {
if (declaredAnnotation.annotationType().equals(annotation)) {
return true;
}
}
}
return false;
}

}
41 changes: 41 additions & 0 deletions docs/src/main/asciidoc/cdi-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,47 @@ public class NoopAsyncObserverExceptionHandler implements AsyncObserverException
}
----

[[reactive_pitfalls]]
== Pitfalls with Reactive Programming

CDI is a purely synchronous framework.
Its notion of asynchrony is very limited and based solely on thread pools and thread offloading.
Therefore, there is a number of pitfalls when using CDI together with reactive programming.

=== Detecting When Blocking Is Allowed

The `io.quarkus.runtime.BlockingOperationControl#isBlockingAllowed()` method can be used to detect whether blocking is allowed on the current thread.
When it is not, and you need to perform a blocking operation, you have to offload it to another thread.
The easiest way is to use the `Vertx.executeBlocking()` method:

[source,java]
----
import io.quarkus.runtime.BlockingOperationControl;
@ApplicationScoped
public class MyBean {
@Inject
Vertx vertx;
@PostConstruct
void init() {
if (BlockingOperationControl.isBlockingAllowed()) {
somethingThatBlocks();
} else {
vertx.executeBlocking(() -> {
somethingThatBlocks();
return null;
});
}
}
void somethingThatBlocks() {
// use the file system or JDBC, call a REST service, etc.
Thread.sleep(5000);
}
}
----

[[build_time_apis]]
== Build Time Extensions

Expand Down
Loading

0 comments on commit 57a8553

Please sign in to comment.