fixing fallbackhandler type check
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/fallback/FallbackInterceptor.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/fallback/FallbackInterceptor.java
index c939059..33804a6 100644
--- a/safeguard-impl/src/main/java/org/apache/safeguard/impl/fallback/FallbackInterceptor.java
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/fallback/FallbackInterceptor.java
@@ -43,6 +43,7 @@
import org.apache.safeguard.impl.annotation.AnnotationFinder;
import org.apache.safeguard.impl.cdi.SafeguardExtension;
+import org.apache.safeguard.impl.config.ConfigurationMapper;
import org.apache.safeguard.impl.metrics.FaultToleranceMetrics;
import org.eclipse.microprofile.faulttolerance.ExecutionContext;
import org.eclipse.microprofile.faulttolerance.Fallback;
@@ -107,6 +108,9 @@
@Inject
private FaultToleranceMetrics metrics;
+ @Inject
+ private ConfigurationMapper mapper;
+
private final Collection<CreationalContext<?>> contexts = new ArrayList<>();
@PreDestroy
@@ -119,7 +123,7 @@
}
public FallbackHandler<?> create(final InvocationContext context) {
- final Fallback fallback = finder.findAnnotation(Fallback.class, context);
+ final Fallback fallback = mapper.map(finder.findAnnotation(Fallback.class, context), context.getMethod(), Fallback.class);
final Class<? extends FallbackHandler<?>> value = fallback.value();
final String method = fallback.fallbackMethod();
if (!method.isEmpty() && value != Fallback.DEFAULT.class) {
@@ -128,9 +132,11 @@
FallbackHandler<?> handler;
if (value != Fallback.DEFAULT.class) {
- Stream.of(value.getInterfaces()).filter(it -> it == FallbackHandler.class)
+ Stream.of(value.getGenericInterfaces())
+ .filter(ParameterizedType.class::isInstance)
+ .map(ParameterizedType.class::cast)
+ .filter(it -> FallbackHandler.class == it.getRawType())
.findFirst()
- .map(it -> ParameterizedType.class.cast(it))
.filter(it -> it.getActualTypeArguments().length == 1)
.map(it -> extension.toClass(context.getMethod().getReturnType()).isAssignableFrom(extension.toClass(it.getActualTypeArguments()[0])))
.orElseThrow(() -> new FaultToleranceDefinitionException("handler does not match method: " + context.getMethod()));
diff --git a/safeguard-impl/src/test/resources/dev.xml b/safeguard-impl/src/test/resources/dev.xml
index aef1391..f392d51 100644
--- a/safeguard-impl/src/test/resources/dev.xml
+++ b/safeguard-impl/src/test/resources/dev.xml
@@ -19,23 +19,14 @@
<suite name="Dev Manual Test Run" verbose="2" configfailurepolicy="continue" >
<test name="Manual Run">
<packages> <!-- all TCK -->
- <package name="org.eclipse.microprofile.fault.tolerance.tck" />
+ <!--<package name="org.eclipse.microprofile.fault.tolerance.tck" />-->
</packages>
<classes> <!-- for dev you can filter them out -->
- <!--
- <class name="org.eclipse.microprofile.fault.tolerance.tck.config.ConfigPropertyGlobalVsClassVsMethodTest">
- </class>
- <class name="org.eclipse.microprofile.fault.tolerance.tck.metrics.RetryMetricTest">
+ <class name="org.eclipse.microprofile.fault.tolerance.tck.FallbackTest">
<methods>
- <include name="testRetryMetricUnsuccessful" />
+ <include name="testClassLevelFallbackSuccess" />
</methods>
</class>
- <class name="org.eclipse.microprofile.fault.tolerance.tck.bulkhead.BulkheadSynchRetryTest">
- <methods>
- <include name="testIgnoreWaitingTaskQueueBulkhead"/>
- </methods>
- </class>
- -->
</classes>
</test>
</suite>