This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new c2ac4c4 CAMEL-17630: camel-microprofile - Update to newer releases
c2ac4c4 is described below
commit c2ac4c44a136fc8512a9bc90d72a182069e4b220
Author: James Netherton <[email protected]>
AuthorDate: Fri Feb 11 09:58:06 2022 +0000
CAMEL-17630: camel-microprofile - Update to newer releases
---
camel-dependencies/pom.xml | 7 ++-
.../faulttolerance/FaultToleranceProcessor.java | 8 +--
.../camel-microprofile-health/pom.xml | 32 ------------
.../CamelMicroProfileHealthCheckRegistry.java | 28 ++++------
.../health/CamelMicroProfileHealthHelper.java | 59 ----------------------
.../health/CamelMicroProfileHealthTestSupport.java | 37 +++++++++++---
parent/pom.xml | 7 ++-
7 files changed, 48 insertions(+), 130 deletions(-)
diff --git a/camel-dependencies/pom.xml b/camel-dependencies/pom.xml
index 939f02b..b6bfd08 100644
--- a/camel-dependencies/pom.xml
+++ b/camel-dependencies/pom.xml
@@ -443,7 +443,7 @@
<openjpa-version>3.2.1</openjpa-version>
<openstack4j-version>3.10</openstack4j-version>
<opentelemetry-alpha-version>${opentelemetry-version}-alpha</opentelemetry-alpha-version>
- <opentelemetry-version>1.10.1</opentelemetry-version>
+ <opentelemetry-version>1.11.0</opentelemetry-version>
<opentracing-tracerresolver-version>0.1.8</opentracing-tracerresolver-version>
<opentracing-version>0.33.0</opentracing-version>
<optaplanner-version>8.16.1.Final</optaplanner-version>
@@ -500,8 +500,8 @@
<slf4j-version>1.7.35</slf4j-version>
<smack-version>4.3.5</smack-version>
<smallrye-config-version>2.8.2</smallrye-config-version>
- <smallrye-fault-tolerance-version>5.2.1</smallrye-fault-tolerance-version>
- <smallrye-health-version>3.1.2</smallrye-health-version>
+ <smallrye-fault-tolerance-version>5.3.0</smallrye-fault-tolerance-version>
+ <smallrye-health-version>3.2.0</smallrye-health-version>
<smallrye-metrics-version>3.0.4</smallrye-metrics-version>
<snakeyaml-engine-version>2.3</snakeyaml-engine-version>
<snakeyaml-version>1.30</snakeyaml-version>
@@ -550,7 +550,6 @@
<vysper-version>0.7</vysper-version>
<web3j-quorum-version>0.8.0</web3j-quorum-version>
<web3j-version>3.6.0</web3j-version>
- <weld-junit5-version>2.0.2.Final</weld-junit5-version>
<weld3-version>3.1.8.Final</weld3-version>
<wildfly-elytron>1.11.4.Final</wildfly-elytron>
<wiremock-version>2.32.0</wiremock-version>
diff --git
a/components/camel-microprofile/camel-microprofile-fault-tolerance/src/main/java/org/apache/camel/component/microprofile/faulttolerance/FaultToleranceProcessor.java
b/components/camel-microprofile/camel-microprofile-fault-tolerance/src/main/java/org/apache/camel/component/microprofile/faulttolerance/FaultToleranceProcessor.java
index b29ead5..5e6c3a2 100644
---
a/components/camel-microprofile/camel-microprofile-fault-tolerance/src/main/java/org/apache/camel/component/microprofile/faulttolerance/FaultToleranceProcessor.java
+++
b/components/camel-microprofile/camel-microprofile-fault-tolerance/src/main/java/org/apache/camel/component/microprofile/faulttolerance/FaultToleranceProcessor.java
@@ -31,7 +31,7 @@ import
io.smallrye.faulttolerance.core.stopwatch.SystemStopwatch;
import io.smallrye.faulttolerance.core.timeout.ScheduledExecutorTimeoutWatcher;
import io.smallrye.faulttolerance.core.timeout.Timeout;
import io.smallrye.faulttolerance.core.timeout.TimeoutWatcher;
-import io.smallrye.faulttolerance.core.util.SetOfThrowables;
+import io.smallrye.faulttolerance.core.util.ExceptionDecision;
import org.apache.camel.AsyncCallback;
import org.apache.camel.CamelContext;
import org.apache.camel.CamelContextAware;
@@ -254,7 +254,7 @@ public class FaultToleranceProcessor extends
AsyncProcessorSupport
target = new Fallback(target, "fallback", fallbackContext -> {
exchange.setException(fallbackContext.failure);
return fFallbackTask.call();
- }, SetOfThrowables.ALL, SetOfThrowables.EMPTY);
+ }, ExceptionDecision.ALWAYS_FAILURE);
}
try {
@@ -331,8 +331,8 @@ public class FaultToleranceProcessor extends
AsyncProcessorSupport
ObjectHelper.notNull(camelContext, "CamelContext", this);
if (circuitBreaker == null) {
circuitBreaker = new CircuitBreaker(
- invocation(), id, SetOfThrowables.ALL,
- SetOfThrowables.EMPTY, config.getDelay(),
config.getRequestVolumeThreshold(), config.getFailureRatio(),
+ invocation(), id, ExceptionDecision.ALWAYS_FAILURE,
config.getDelay(), config.getRequestVolumeThreshold(),
+ config.getFailureRatio(),
config.getSuccessThreshold(), new SystemStopwatch());
}
diff --git a/components/camel-microprofile/camel-microprofile-health/pom.xml
b/components/camel-microprofile/camel-microprofile-health/pom.xml
index a375337..ba930e0 100644
--- a/components/camel-microprofile/camel-microprofile-health/pom.xml
+++ b/components/camel-microprofile/camel-microprofile-health/pom.xml
@@ -56,26 +56,12 @@
<version>${smallrye-config-version}</version>
</dependency>
- <!-- smallrye health uses CDI api -->
- <dependency>
- <groupId>javax.enterprise</groupId>
- <artifactId>cdi-api</artifactId>
- <version>${cdi-api-2.0-version}</version>
- <scope>provided</scope>
- </dependency>
-
<!-- testing -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-junit5</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.jboss.weld</groupId>
- <artifactId>weld-junit5</artifactId>
- <version>${weld-junit5-version}</version>
- <scope>test</scope>
- </dependency>
<!-- JSON support for smallrye-health -->
<dependency>
@@ -104,22 +90,4 @@
</dependencies>
- <profiles>
- <profile>
- <id>jdk17-build</id>
- <activation>
- <jdk>[17,)</jdk>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <argLine>--add-opens
java.base/java.lang=ALL-UNNAMED</argLine>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
</project>
diff --git
a/components/camel-microprofile/camel-microprofile-health/src/main/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthCheckRegistry.java
b/components/camel-microprofile/camel-microprofile-health/src/main/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthCheckRegistry.java
index 6773cd7..a7fcbdd 100644
---
a/components/camel-microprofile/camel-microprofile-health/src/main/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthCheckRegistry.java
+++
b/components/camel-microprofile/camel-microprofile-health/src/main/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthCheckRegistry.java
@@ -20,6 +20,8 @@ import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import io.smallrye.health.api.HealthRegistry;
+import io.smallrye.health.api.HealthType;
+import io.smallrye.health.registry.HealthRegistries;
import org.apache.camel.CamelContext;
import org.apache.camel.StartupListener;
import org.apache.camel.health.HealthCheck;
@@ -41,8 +43,6 @@ public class CamelMicroProfileHealthCheckRegistry extends
DefaultHealthCheckRegi
public static final String ROUTES_CHECK_NAME = "camel-routes";
private static final Logger LOG =
LoggerFactory.getLogger(CamelMicroProfileHealthCheckRegistry.class);
private final Set<HealthCheckRepository> repositories = new
CopyOnWriteArraySet<>();
- private HealthRegistry livenessRegistry;
- private HealthRegistry readinessRegistry;
public CamelMicroProfileHealthCheckRegistry() {
this(null);
@@ -119,7 +119,7 @@ public class CamelMicroProfileHealthCheckRegistry extends
DefaultHealthCheckRegi
}
}
- private void registerRepositoryChecks(HealthCheckRepository repository) {
+ protected void registerRepositoryChecks(HealthCheckRepository repository) {
if (repository.isEnabled()) {
// Since the number of potential checks for consumers / routes is
non-deterministic
// avoid registering each one with SmallRye health and instead
aggregate the results so
@@ -140,7 +140,7 @@ public class CamelMicroProfileHealthCheckRegistry extends
DefaultHealthCheckRegi
}
}
- private void registerMicroProfileHealthCheck(HealthCheck camelHealthCheck)
{
+ protected void registerMicroProfileHealthCheck(HealthCheck
camelHealthCheck) {
org.eclipse.microprofile.health.HealthCheck microProfileHealthCheck
= new CamelMicroProfileHealthCheck(camelHealthCheck);
@@ -153,7 +153,7 @@ public class CamelMicroProfileHealthCheckRegistry extends
DefaultHealthCheckRegi
}
}
- private void removeMicroProfileHealthCheck(HealthCheck camelHealthCheck) {
+ protected void removeMicroProfileHealthCheck(HealthCheck camelHealthCheck)
{
if (camelHealthCheck.isReadiness()) {
try {
getReadinessRegistry().remove(camelHealthCheck.getId());
@@ -175,21 +175,11 @@ public class CamelMicroProfileHealthCheckRegistry extends
DefaultHealthCheckRegi
}
}
- private HealthRegistry getLivenessRegistry() {
- synchronized (this) {
- if (livenessRegistry == null) {
- livenessRegistry =
CamelMicroProfileHealthHelper.getLivenessRegistry();
- }
- }
- return livenessRegistry;
+ protected HealthRegistry getLivenessRegistry() {
+ return HealthRegistries.getRegistry(HealthType.LIVENESS);
}
- private HealthRegistry getReadinessRegistry() {
- synchronized (this) {
- if (readinessRegistry == null) {
- readinessRegistry =
CamelMicroProfileHealthHelper.getReadinessRegistry();
- }
- }
- return readinessRegistry;
+ protected HealthRegistry getReadinessRegistry() {
+ return HealthRegistries.getRegistry(HealthType.READINESS);
}
}
diff --git
a/components/camel-microprofile/camel-microprofile-health/src/main/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthHelper.java
b/components/camel-microprofile/camel-microprofile-health/src/main/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthHelper.java
index ecd9fff..4571c52 100644
---
a/components/camel-microprofile/camel-microprofile-health/src/main/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthHelper.java
+++
b/components/camel-microprofile/camel-microprofile-health/src/main/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthHelper.java
@@ -18,21 +18,11 @@ package org.apache.camel.microprofile.health;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.lang.annotation.Annotation;
import java.util.Set;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.CDI;
-
-import io.smallrye.health.api.HealthRegistry;
-import io.smallrye.health.registry.LivenessHealthRegistry;
-import io.smallrye.health.registry.ReadinessHealthRegistry;
import org.apache.camel.health.HealthCheck;
import org.apache.camel.health.HealthCheck.Result;
import org.eclipse.microprofile.health.HealthCheckResponseBuilder;
-import org.eclipse.microprofile.health.Liveness;
-import org.eclipse.microprofile.health.Readiness;
/**
* Helper utility class for MicroProfile health checks.
@@ -70,53 +60,4 @@ final class CamelMicroProfileHealthHelper {
}
});
}
-
- /**
- * Retrieves the {@link LivenessHealthRegistry} bean instance.
- *
- * @return The {@link LivenessHealthRegistry} bean.
- */
- public static HealthRegistry getLivenessRegistry() {
- return getHealthRegistryBean(LivenessHealthRegistry.class,
Liveness.Literal.INSTANCE);
- }
-
- /**
- * Retrieves the {@link ReadinessHealthRegistry} bean instance.
- *
- * @return The {@link ReadinessHealthRegistry} bean.
- */
- public static HealthRegistry getReadinessRegistry() {
- return getHealthRegistryBean(ReadinessHealthRegistry.class,
Readiness.Literal.INSTANCE);
- }
-
- /**
- * Retrieves a {@link HealthRegistry} bean from the CDI bean manager for
the given type and qualifier.
- *
- * Registry beans are looked up from the CDI {@link BeanManager} to avoid
CDI injection in
- * {@link CamelMicroProfileHealthCheckRegistry} and also avoid having to
add CDI bean defining annotations to
- * {@link CamelMicroProfileHealthCheckRegistry}.
- *
- * Eventually this can be removed when upgrading to a future SmallRye
Health release where static health registry
- * lookups will be supported.
- *
- * https://github.com/smallrye/smallrye-health/issues/172
- *
- * @param type The implementation class of the {@link
HealthRegistry} bean
- * @param qualifier The annotation qualifier applied to the
{@link HealthRegistry} bean
- * @return The {@link HealthRegistry} bean
- * @throws IllegalStateException if no beans matching the {@link
HealthRegistry} bean type and annotation qualifier
- * were found
- */
- private static HealthRegistry getHealthRegistryBean(Class<? extends
HealthRegistry> type, Annotation qualifier) {
- BeanManager beanManager = CDI.current().getBeanManager();
- Set<Bean<?>> beans = beanManager.getBeans(type, qualifier);
- if (beans.isEmpty()) {
- throw new IllegalStateException(
- "Beans for type " + type.getName() + " with qualifier " +
qualifier + " could not be found.");
- }
-
- Bean<?> bean = beanManager.resolve(beans);
- Object reference = beanManager.getReference(bean, type,
beanManager.createCreationalContext(bean));
- return type.cast(reference);
- }
}
diff --git
a/components/camel-microprofile/camel-microprofile-health/src/test/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthTestSupport.java
b/components/camel-microprofile/camel-microprofile-health/src/test/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthTestSupport.java
index 4d472bc..acd9317 100644
---
a/components/camel-microprofile/camel-microprofile-health/src/test/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthTestSupport.java
+++
b/components/camel-microprofile/camel-microprofile-health/src/test/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthTestSupport.java
@@ -18,18 +18,22 @@ package org.apache.camel.microprofile.health;
import java.io.ByteArrayOutputStream;
import java.io.StringReader;
+import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.function.Consumer;
+import java.util.stream.Stream;
-import javax.inject.Inject;
import javax.json.Json;
import javax.json.JsonObject;
import javax.json.stream.JsonParser;
-import io.smallrye.config.inject.ConfigExtension;
import io.smallrye.health.SmallRyeHealth;
import io.smallrye.health.SmallRyeHealthReporter;
+import io.smallrye.health.api.HealthType;
+import io.smallrye.health.registry.HealthRegistries;
+import io.smallrye.health.registry.HealthRegistryImpl;
+import io.smallrye.mutiny.Uni;
import org.apache.camel.CamelContext;
import org.apache.camel.health.HealthCheck;
import org.apache.camel.health.HealthCheckRegistry;
@@ -37,18 +41,35 @@ import org.apache.camel.health.HealthCheckResultBuilder;
import org.apache.camel.impl.health.AbstractHealthCheck;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.eclipse.microprofile.health.HealthCheckResponse;
-import org.jboss.weld.junit5.auto.AddExtensions;
-import org.jboss.weld.junit5.auto.EnableAutoWeld;
+import org.junit.jupiter.api.AfterEach;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
-@EnableAutoWeld
-@AddExtensions(ConfigExtension.class)
public class CamelMicroProfileHealthTestSupport extends CamelTestSupport {
- @Inject
- SmallRyeHealthReporter reporter;
+ protected SmallRyeHealthReporter reporter = new SmallRyeHealthReporter();
+
+ @SuppressWarnings("unchecked")
+ @AfterEach
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+ // Hack to clean up all registered checks
+ Stream.of(HealthType.LIVENESS, HealthType.READINESS)
+ .forEach(type -> {
+ HealthRegistryImpl registry = (HealthRegistryImpl)
HealthRegistries.getRegistry(type);
+ try {
+ Field field =
registry.getClass().getDeclaredField("checks");
+ field.setAccessible(true);
+ Map<String, Uni<HealthCheckResponse>> checks
+ = (Map<String, Uni<HealthCheckResponse>>)
field.get(registry);
+ checks.clear();
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ });
+ }
@Override
protected CamelContext createCamelContext() throws Exception {
diff --git a/parent/pom.xml b/parent/pom.xml
index 5ce043b..d7580a9 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -429,7 +429,7 @@
<ognl-version>3.1.12</ognl-version>
<openjpa-version>3.2.1</openjpa-version>
<openstack4j-version>3.10</openstack4j-version>
- <opentelemetry-version>1.10.1</opentelemetry-version>
+ <opentelemetry-version>1.11.0</opentelemetry-version>
<opentelemetry-alpha-version>${opentelemetry-version}-alpha</opentelemetry-alpha-version>
<opentracing-version>0.33.0</opentracing-version>
<opentracing-tracerresolver-version>0.1.8</opentracing-tracerresolver-version>
@@ -488,8 +488,8 @@
<smack-version>4.3.5</smack-version>
<smallrye-config-version>2.8.2</smallrye-config-version>
<smallrye-metrics-version>3.0.4</smallrye-metrics-version>
- <smallrye-health-version>3.1.2</smallrye-health-version>
-
<smallrye-fault-tolerance-version>5.2.1</smallrye-fault-tolerance-version>
+ <smallrye-health-version>3.2.0</smallrye-health-version>
+
<smallrye-fault-tolerance-version>5.3.0</smallrye-fault-tolerance-version>
<snakeyaml-version>1.30</snakeyaml-version>
<snakeyaml-engine-version>2.3</snakeyaml-engine-version>
<snmp4j-version>2.6.3_1</snmp4j-version>
@@ -538,7 +538,6 @@
<web3j-version>3.6.0</web3j-version>
<web3j-quorum-version>0.8.0</web3j-quorum-version>
<weld3-version>3.1.8.Final</weld3-version>
- <weld-junit5-version>2.0.2.Final</weld-junit5-version>
<wildfly-elytron>1.11.4.Final</wildfly-elytron>
<wiremock-version>2.32.0</wiremock-version>
<woodstox-version>4.4.1</woodstox-version>