diff --git a/appserver/payara-appserver-modules/microprofile/fault-tolerance/src/main/java/fish/payara/microprofile/faulttolerance/interceptors/RetryInterceptor.java b/appserver/payara-appserver-modules/microprofile/fault-tolerance/src/main/java/fish/payara/microprofile/faulttolerance/interceptors/RetryInterceptor.java index 583abd1c6d5..3175285badc 100644 --- a/appserver/payara-appserver-modules/microprofile/fault-tolerance/src/main/java/fish/payara/microprofile/faulttolerance/interceptors/RetryInterceptor.java +++ b/appserver/payara-appserver-modules/microprofile/fault-tolerance/src/main/java/fish/payara/microprofile/faulttolerance/interceptors/RetryInterceptor.java @@ -241,21 +241,21 @@ private Object retry(InvocationContext invocationContext) throws Exception { .orElse(retry.delay()); // Look for a String and cast to ChronoUnit - Use the Common Sense Convertor ChronoUnit delayUnit = FaultToleranceCdiUtils.getOverrideValue( - config, Retry.class, "delayUnit", invocationContext, ChronoUnit.class) + config, Retry.class, "delayUnit", invocationContext, String.class).map(ChronoUnit::valueOf) .orElse(retry.delayUnit()); long maxDuration = FaultToleranceCdiUtils.getOverrideValue( config, Retry.class, "maxDuration", invocationContext, Long.class) .orElse(retry.maxDuration()); // Look for a String and cast to ChronoUnit - Use the Common Sense Convertor ChronoUnit durationUnit = FaultToleranceCdiUtils.getOverrideValue( - config, Retry.class, "durationUnit", invocationContext, ChronoUnit.class) + config, Retry.class, "durationUnit", invocationContext, String.class).map(ChronoUnit::valueOf) .orElse(retry.durationUnit()); long jitter = FaultToleranceCdiUtils.getOverrideValue( config, Retry.class, "jitter", invocationContext, Long.class) .orElse(retry.jitter()); // Look for a String and cast to ChronoUnit - Use the Common Sense Convertor ChronoUnit jitterDelayUnit = FaultToleranceCdiUtils.getOverrideValue( - config, Retry.class, "jitterDelayUnit", invocationContext, ChronoUnit.class) + config, Retry.class, "jitterDelayUnit", invocationContext, String.class).map(ChronoUnit::valueOf) .orElse(retry.jitterDelayUnit()); long delayMillis = Duration.of(delay, delayUnit).toMillis(); diff --git a/appserver/payara-appserver-modules/microprofile/fault-tolerance/src/main/java/fish/payara/microprofile/faulttolerance/interceptors/TimeoutInterceptor.java b/appserver/payara-appserver-modules/microprofile/fault-tolerance/src/main/java/fish/payara/microprofile/faulttolerance/interceptors/TimeoutInterceptor.java index 6541f27cb7c..315c8e4da13 100644 --- a/appserver/payara-appserver-modules/microprofile/fault-tolerance/src/main/java/fish/payara/microprofile/faulttolerance/interceptors/TimeoutInterceptor.java +++ b/appserver/payara-appserver-modules/microprofile/fault-tolerance/src/main/java/fish/payara/microprofile/faulttolerance/interceptors/TimeoutInterceptor.java @@ -194,7 +194,7 @@ private Object timeout(InvocationContext invocationContext) throws Exception { .orElse(timeout.value()); // Look for a String and cast to ChronoUnit - Use the Common Sense Convertor ChronoUnit unit = FaultToleranceCdiUtils.getOverrideValue( - config, Timeout.class, "unit", invocationContext, ChronoUnit.class) + config, Timeout.class, "unit", invocationContext, String.class).map(ChronoUnit::valueOf) .orElse(timeout.unit()); Future timeoutFuture = null; diff --git a/appserver/payara-appserver-modules/microprofile/fault-tolerance/src/main/java/fish/payara/microprofile/faulttolerance/interceptors/fallback/FallbackPolicy.java b/appserver/payara-appserver-modules/microprofile/fault-tolerance/src/main/java/fish/payara/microprofile/faulttolerance/interceptors/fallback/FallbackPolicy.java index b3669a0d732..6d68bfddbca 100644 --- a/appserver/payara-appserver-modules/microprofile/fault-tolerance/src/main/java/fish/payara/microprofile/faulttolerance/interceptors/fallback/FallbackPolicy.java +++ b/appserver/payara-appserver-modules/microprofile/fault-tolerance/src/main/java/fish/payara/microprofile/faulttolerance/interceptors/fallback/FallbackPolicy.java @@ -43,6 +43,7 @@ import static fish.payara.microprofile.faulttolerance.FaultToleranceService.FALLBACK_HANDLER_METHOD_NAME; import fish.payara.microprofile.faulttolerance.cdi.FaultToleranceCdiUtils; import java.lang.reflect.Method; +import java.util.Optional; import java.util.logging.Level; import java.util.logging.Logger; import javax.interceptor.InvocationContext; @@ -72,11 +73,12 @@ public class FallbackPolicy { @SuppressWarnings("unchecked") public FallbackPolicy(Fallback fallback, Config config, InvocationContext invocationContext) throws ClassNotFoundException { - fallbackClass = (Class>) Thread.currentThread().getContextClassLoader().loadClass( - FaultToleranceCdiUtils.getOverrideValue(config, Fallback.class, "value", - invocationContext, Class.class) - .orElse(fallback.value()).getName()); - + Optional className = FaultToleranceCdiUtils.getOverrideValue(config, Fallback.class, "value", + invocationContext, String.class); + fallbackClass = className.isPresent() + ? (Class>) Thread.currentThread().getContextClassLoader() + .loadClass(className.get()) + : fallback.value(); fallbackMethod = FaultToleranceCdiUtils.getOverrideValue(config, Fallback.class, "fallbackMethod", invocationContext, String.class) .orElse(fallback.fallbackMethod()); diff --git a/appserver/payara-appserver-modules/microprofile/fault-tolerance/src/main/java/fish/payara/microprofile/faulttolerance/validators/FallbackValidator.java b/appserver/payara-appserver-modules/microprofile/fault-tolerance/src/main/java/fish/payara/microprofile/faulttolerance/validators/FallbackValidator.java index 1859f71b15a..e50acdc68c1 100644 --- a/appserver/payara-appserver-modules/microprofile/fault-tolerance/src/main/java/fish/payara/microprofile/faulttolerance/validators/FallbackValidator.java +++ b/appserver/payara-appserver-modules/microprofile/fault-tolerance/src/main/java/fish/payara/microprofile/faulttolerance/validators/FallbackValidator.java @@ -40,6 +40,9 @@ package fish.payara.microprofile.faulttolerance.validators; import static fish.payara.microprofile.faulttolerance.FaultToleranceService.FALLBACK_HANDLER_METHOD_NAME; + +import java.util.Optional; + import fish.payara.microprofile.faulttolerance.cdi.FaultToleranceCdiUtils; import javax.enterprise.inject.spi.AnnotatedMethod; import org.eclipse.microprofile.config.Config; @@ -71,13 +74,15 @@ public static void validateAnnotation(Fallback fallback, AnnotatedMethod anno .orElse(fallback.fallbackMethod()); // Get the fallbackClass, and check that it can be found - @SuppressWarnings("unchecked") - Class> fallbackClass = (Class>) Thread.currentThread() - .getContextClassLoader().loadClass(FaultToleranceCdiUtils + Optional fallbackClassName = FaultToleranceCdiUtils .getOverrideValue(config, Fallback.class, "value", annotatedMethod.getJavaMember().getName(), - annotatedMethod.getJavaMember().getDeclaringClass().getCanonicalName(), Class.class) - .orElse(fallback.value()).getName()); - + annotatedMethod.getJavaMember().getDeclaringClass().getCanonicalName(), String.class); + @SuppressWarnings("unchecked") + Class> fallbackClass = fallbackClassName.isPresent() + ? (Class>) Thread.currentThread().getContextClassLoader() + .loadClass(fallbackClassName.get()) + : fallback.value(); + // Validate the annotated method if (fallbackMethod != null && !fallbackMethod.isEmpty()) { if (fallbackClass != null && fallbackClass != Fallback.DEFAULT.class) {