You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jo...@apache.org on 2017/10/05 03:51:30 UTC
geronimo-safeguard git commit: GERONIMO-6591 - Adding fallback
support.
Repository: geronimo-safeguard
Updated Branches:
refs/heads/master adee0a94c -> 0f811c373
GERONIMO-6591 - Adding fallback support.
Project: http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/repo
Commit: http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/commit/0f811c37
Tree: http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/tree/0f811c37
Diff: http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/diff/0f811c37
Branch: refs/heads/master
Commit: 0f811c373a782d40f87da7fc736289b80b7f5f12
Parents: adee0a9
Author: John D. Ament <jo...@apache.org>
Authored: Wed Oct 4 21:55:09 2017 -0400
Committer: John D. Ament <jo...@apache.org>
Committed: Wed Oct 4 23:51:04 2017 -0400
----------------------------------------------------------------------
.../impl/FailsafeExecutionManager.java | 8 +-
.../AsyncFailsafeExecutionPlan.java | 11 +-
.../executionPlans/AsyncOnlyExecutionPlan.java | 3 +-
.../AsyncTimeoutExecutionPlan.java | 3 +-
.../impl/executionPlans/ExecutionPlan.java | 3 +-
.../executionPlans/ExecutionPlanFactory.java | 19 +++-
.../SyncFailsafeExecutionPlan.java | 17 +++-
.../safeguard/impl/fallback/FallbackRunner.java | 102 +++++++++++++++++++
.../AsyncOnlyExecutionPlanTest.java | 2 +-
.../AsyncTimeoutExecutionPlanTest.java | 4 +-
.../SyncFailsafeExecutionPlanTest.java | 2 +-
safeguard-tck-tests/pom.xml | 37 +++++--
12 files changed, 178 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/0f811c37/safeguard-impl/src/main/java/org/apache/safeguard/impl/FailsafeExecutionManager.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/FailsafeExecutionManager.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/FailsafeExecutionManager.java
index 35d3fa9..4424d06 100644
--- a/safeguard-impl/src/main/java/org/apache/safeguard/impl/FailsafeExecutionManager.java
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/FailsafeExecutionManager.java
@@ -44,20 +44,20 @@ public class FailsafeExecutionManager implements ExecutionManager {
public Object execute(InvocationContext invocationContext) {
Method method = invocationContext.getMethod();
- return executionPlanFactory.locateExecutionPlan(method).execute(invocationContext::proceed);
+ return executionPlanFactory.locateExecutionPlan(method).execute(invocationContext::proceed, invocationContext);
}
@Override
public <T> T execute(String name, Callable<T> callable) {
- return executionPlanFactory.locateExecutionPlan(name, null, false).execute(callable);
+ return executionPlanFactory.locateExecutionPlan(name, null, false).execute(callable, null);
}
public <T> T executeAsync(String name, Callable<T> callable) {
- return executionPlanFactory.locateExecutionPlan(name, null, true).execute(callable);
+ return executionPlanFactory.locateExecutionPlan(name, null, true).execute(callable, null);
}
public <T> T executeAsync(String name, Callable<T> callable, Duration timeout) {
- return executionPlanFactory.locateExecutionPlan(name, timeout, true).execute(callable);
+ return executionPlanFactory.locateExecutionPlan(name, timeout, true).execute(callable, null);
}
public ExecutionPlanFactory getExecutionPlanFactory() {
http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/0f811c37/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncFailsafeExecutionPlan.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncFailsafeExecutionPlan.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncFailsafeExecutionPlan.java
index a93531e..6ee1309 100644
--- a/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncFailsafeExecutionPlan.java
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncFailsafeExecutionPlan.java
@@ -22,14 +22,14 @@ package org.apache.safeguard.impl.executionPlans;
import net.jodah.failsafe.AsyncFailsafe;
import net.jodah.failsafe.CircuitBreakerOpenException;
import org.apache.safeguard.impl.circuitbreaker.FailsafeCircuitBreaker;
+import org.apache.safeguard.impl.fallback.FallbackRunner;
import org.apache.safeguard.impl.retry.FailsafeRetryDefinition;
+import javax.interceptor.InvocationContext;
import java.time.Duration;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
public class AsyncFailsafeExecutionPlan extends SyncFailsafeExecutionPlan {
private final ScheduledExecutorService executorService;
@@ -37,16 +37,17 @@ public class AsyncFailsafeExecutionPlan extends SyncFailsafeExecutionPlan {
public AsyncFailsafeExecutionPlan(FailsafeRetryDefinition retryDefinition,
FailsafeCircuitBreaker failsafeCircuitBreaker,
+ FallbackRunner fallback,
ScheduledExecutorService executorService,
Duration timeout) {
- super(retryDefinition, failsafeCircuitBreaker);
+ super(retryDefinition, failsafeCircuitBreaker, fallback);
this.executorService = executorService;
this.timeout = timeout;
}
@Override
- public <T> T execute(Callable<T> callable) {
- AsyncFailsafe<?> asyncFailsafe = getSyncFailsafe().with(executorService);
+ public <T> T execute(Callable<T> callable, InvocationContext invocationContext) {
+ AsyncFailsafe<?> asyncFailsafe = getSyncFailsafe(invocationContext).with(executorService);
try {
if (this.timeout == null) {
return asyncFailsafe.get(callable).get();
http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/0f811c37/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncOnlyExecutionPlan.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncOnlyExecutionPlan.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncOnlyExecutionPlan.java
index 9af94c2..e1a708b 100644
--- a/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncOnlyExecutionPlan.java
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncOnlyExecutionPlan.java
@@ -21,6 +21,7 @@ package org.apache.safeguard.impl.executionPlans;
import org.apache.safeguard.exception.AsyncException;
+import javax.interceptor.InvocationContext;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
@@ -34,7 +35,7 @@ class AsyncOnlyExecutionPlan implements ExecutionPlan {
}
@Override
- public <T> T execute(Callable<T> callable) {
+ public <T> T execute(Callable<T> callable, InvocationContext invocationContext) {
Future<T> submitted = executorService.submit(callable);
try {
return submitted.get();
http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/0f811c37/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncTimeoutExecutionPlan.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncTimeoutExecutionPlan.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncTimeoutExecutionPlan.java
index 5a351ac..97c76b3 100644
--- a/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncTimeoutExecutionPlan.java
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/AsyncTimeoutExecutionPlan.java
@@ -19,6 +19,7 @@
package org.apache.safeguard.impl.executionPlans;
+import javax.interceptor.InvocationContext;
import java.time.Duration;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@@ -37,7 +38,7 @@ class AsyncTimeoutExecutionPlan implements ExecutionPlan {
}
@Override
- public <T> T execute(Callable<T> callable) {
+ public <T> T execute(Callable<T> callable, InvocationContext invocationContext) {
Future<T> future = executorService.submit(callable);
try {
return future.get(timeout.toMillis(), TimeUnit.MILLISECONDS);
http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/0f811c37/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/ExecutionPlan.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/ExecutionPlan.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/ExecutionPlan.java
index 01c3271..f8092b8 100644
--- a/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/ExecutionPlan.java
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/ExecutionPlan.java
@@ -19,8 +19,9 @@
package org.apache.safeguard.impl.executionPlans;
+import javax.interceptor.InvocationContext;
import java.util.concurrent.Callable;
public interface ExecutionPlan {
- <T> T execute(Callable<T> callable);
+ <T> T execute(Callable<T> function, InvocationContext invocationContext);
}
http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/0f811c37/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/ExecutionPlanFactory.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/ExecutionPlanFactory.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/ExecutionPlanFactory.java
index e3c0642..6c15bb0 100644
--- a/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/ExecutionPlanFactory.java
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/ExecutionPlanFactory.java
@@ -22,6 +22,7 @@ package org.apache.safeguard.impl.executionPlans;
import org.apache.safeguard.impl.circuitbreaker.FailsafeCircuitBreaker;
import org.apache.safeguard.impl.circuitbreaker.FailsafeCircuitBreakerBuilder;
import org.apache.safeguard.impl.circuitbreaker.FailsafeCircuitBreakerManager;
+import org.apache.safeguard.impl.fallback.FallbackRunner;
import org.apache.safeguard.impl.retry.FailsafeRetryBuilder;
import org.apache.safeguard.impl.retry.FailsafeRetryDefinition;
import org.apache.safeguard.impl.retry.FailsafeRetryManager;
@@ -29,6 +30,7 @@ import org.apache.safeguard.impl.util.AnnotationUtil;
import org.apache.safeguard.impl.util.NamingUtil;
import org.eclipse.microprofile.faulttolerance.Asynchronous;
import org.eclipse.microprofile.faulttolerance.CircuitBreaker;
+import org.eclipse.microprofile.faulttolerance.Fallback;
import org.eclipse.microprofile.faulttolerance.Retry;
import org.eclipse.microprofile.faulttolerance.Timeout;
@@ -36,6 +38,7 @@ import java.lang.reflect.Method;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import static org.apache.safeguard.impl.executionPlans.MicroprofileAnnotationMapper.mapCircuitBreaker;
@@ -58,7 +61,7 @@ public class ExecutionPlanFactory {
if (circuitBreaker == null && retryDefinition == null) {
return null;
} else {
- return new SyncFailsafeExecutionPlan(retryDefinition, circuitBreaker);
+ return new SyncFailsafeExecutionPlan(retryDefinition, circuitBreaker, null);
}
});
}
@@ -76,6 +79,7 @@ public class ExecutionPlanFactory {
}
boolean isAsync = isAsync(method);
Duration timeout = readTimeout(method);
+ FallbackRunner fallbackRunner = this.createFallback(method);
if(circuitBreaker == null && retryDefinition == null && isAsync) {
if(timeout == null) {
return new AsyncOnlyExecutionPlan(null);
@@ -90,9 +94,9 @@ public class ExecutionPlanFactory {
}
else {
if (isAsync || timeout != null) {
- return new AsyncFailsafeExecutionPlan(retryDefinition, circuitBreaker, Executors.newScheduledThreadPool(5), timeout);
+ return new AsyncFailsafeExecutionPlan(retryDefinition, circuitBreaker, fallbackRunner, Executors.newScheduledThreadPool(5), timeout);
} else {
- return new SyncFailsafeExecutionPlan(retryDefinition, circuitBreaker);
+ return new SyncFailsafeExecutionPlan(retryDefinition, circuitBreaker, fallbackRunner);
}
}
});
@@ -116,6 +120,15 @@ public class ExecutionPlanFactory {
return new FailsafeCircuitBreaker(mapCircuitBreaker(circuitBreaker, circuitBreakerBuilder));
}
+ private FallbackRunner createFallback(Method method) {
+ Fallback fallback = AnnotationUtil.getAnnotation(method, Fallback.class);
+ if(fallback == null) {
+ return null;
+ }
+ String methodName = "".equals(fallback.fallbackMethod()) ? null : fallback.fallbackMethod();
+ return new FallbackRunner(fallback.value(), methodName);
+ }
+
private boolean isAsync(Method method) {
return AnnotationUtil.getAnnotation(method, Asynchronous.class) != null;
}
http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/0f811c37/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/SyncFailsafeExecutionPlan.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/SyncFailsafeExecutionPlan.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/SyncFailsafeExecutionPlan.java
index 7a53dea..f4fe8ee 100644
--- a/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/SyncFailsafeExecutionPlan.java
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/executionPlans/SyncFailsafeExecutionPlan.java
@@ -23,17 +23,22 @@ import net.jodah.failsafe.CircuitBreakerOpenException;
import net.jodah.failsafe.Failsafe;
import net.jodah.failsafe.SyncFailsafe;
import org.apache.safeguard.impl.circuitbreaker.FailsafeCircuitBreaker;
+import org.apache.safeguard.impl.fallback.FallbackRunner;
import org.apache.safeguard.impl.retry.FailsafeRetryDefinition;
+import javax.interceptor.InvocationContext;
import java.util.concurrent.Callable;
+import java.util.function.Function;
public class SyncFailsafeExecutionPlan implements ExecutionPlan {
private final FailsafeRetryDefinition retryDefinition;
private final FailsafeCircuitBreaker failsafeCircuitBreaker;
+ private final FallbackRunner fallback;
- SyncFailsafeExecutionPlan(FailsafeRetryDefinition retryDefinition, FailsafeCircuitBreaker failsafeCircuitBreaker) {
+ SyncFailsafeExecutionPlan(FailsafeRetryDefinition retryDefinition, FailsafeCircuitBreaker failsafeCircuitBreaker, FallbackRunner fallback) {
this.retryDefinition = retryDefinition;
this.failsafeCircuitBreaker = failsafeCircuitBreaker;
+ this.fallback = fallback;
validateConfig();
}
@@ -44,8 +49,8 @@ public class SyncFailsafeExecutionPlan implements ExecutionPlan {
}
@Override
- public <T> T execute(Callable<T> callable) {
- SyncFailsafe<?> syncFailsafe = getSyncFailsafe();
+ public <T> T execute(Callable<T> callable, InvocationContext invocationContext) {
+ SyncFailsafe<?> syncFailsafe = getSyncFailsafe(invocationContext);
try {
return syncFailsafe.get(callable);
} catch (CircuitBreakerOpenException e) {
@@ -53,8 +58,9 @@ public class SyncFailsafeExecutionPlan implements ExecutionPlan {
}
}
- SyncFailsafe<?> getSyncFailsafe() {
+ SyncFailsafe<?> getSyncFailsafe(InvocationContext invocationContext) {
SyncFailsafe<?> syncFailsafe;
+ Callable callable = () -> fallback.executeFallback(invocationContext);
if(retryDefinition == null) {
syncFailsafe = Failsafe.with(failsafeCircuitBreaker.getDefinition().getCircuitBreaker());
}
@@ -67,6 +73,9 @@ public class SyncFailsafeExecutionPlan implements ExecutionPlan {
.with(failsafeCircuitBreaker.getDefinition().getCircuitBreaker());
}
}
+ if(this.fallback != null) {
+ syncFailsafe = syncFailsafe.withFallback(callable);
+ }
return syncFailsafe;
}
}
http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/0f811c37/safeguard-impl/src/main/java/org/apache/safeguard/impl/fallback/FallbackRunner.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/main/java/org/apache/safeguard/impl/fallback/FallbackRunner.java b/safeguard-impl/src/main/java/org/apache/safeguard/impl/fallback/FallbackRunner.java
new file mode 100644
index 0000000..26e376e
--- /dev/null
+++ b/safeguard-impl/src/main/java/org/apache/safeguard/impl/fallback/FallbackRunner.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.safeguard.impl.fallback;
+
+import org.eclipse.microprofile.faulttolerance.ExecutionContext;
+import org.eclipse.microprofile.faulttolerance.FallbackHandler;
+
+import javax.enterprise.inject.spi.CDI;
+import javax.interceptor.InvocationContext;
+import java.lang.reflect.Method;
+import java.lang.reflect.Parameter;
+
+public class FallbackRunner {
+ private final Class<? extends FallbackHandler<?>> handlerClass;
+ private final String method;
+
+ public FallbackRunner(Class<? extends FallbackHandler<?>> handlerClass, String method) {
+ this.handlerClass = handlerClass;
+ this.method = method;
+ }
+
+ public Object executeFallback(InvocationContext invocationContext) {
+ if(method != null) {
+ try {
+ Method method = getMethod(invocationContext.getTarget().getClass());
+ Parameter[] parameters = method.getParameters();
+ if(parameters.length == 0) {
+ return method.invoke(invocationContext.getTarget());
+ }
+ else {
+ return method.invoke(invocationContext.getTarget(), invocationContext.getParameters());
+ }
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ else {
+ SafeguardExecutionContext executionContext = new SafeguardExecutionContext(invocationContext.getMethod(),
+ invocationContext.getParameters());
+ CDI<Object> cdi = CDI.current();
+ FallbackHandler fallbackHandler = null;
+ try {
+ fallbackHandler = cdi.select(handlerClass).get();
+ }
+ catch (Exception e) {
+ try {
+ fallbackHandler = handlerClass.newInstance();
+ } catch (InstantiationException | IllegalAccessException e1) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ return fallbackHandler.handle(executionContext);
+ }
+ }
+
+ private Method getMethod(Class<?> aClass) {
+ for(Method method : aClass.getMethods()) {
+ if(method.getName().equals(this.method)) {
+ return method;
+ }
+ }
+ return null;
+ }
+
+ private static class SafeguardExecutionContext implements ExecutionContext {
+
+ private final Method method;
+ private final Object[] parameters;
+
+ private SafeguardExecutionContext(Method method, Object[] parameters) {
+ this.method = method;
+ this.parameters = parameters;
+ }
+
+ @Override
+ public Method getMethod() {
+ return method;
+ }
+
+ @Override
+ public Object[] getParameters() {
+ return parameters;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/0f811c37/safeguard-impl/src/test/java/org/apache/safeguard/impl/executionPlans/AsyncOnlyExecutionPlanTest.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/test/java/org/apache/safeguard/impl/executionPlans/AsyncOnlyExecutionPlanTest.java b/safeguard-impl/src/test/java/org/apache/safeguard/impl/executionPlans/AsyncOnlyExecutionPlanTest.java
index 4c52faf..1484f99 100644
--- a/safeguard-impl/src/test/java/org/apache/safeguard/impl/executionPlans/AsyncOnlyExecutionPlanTest.java
+++ b/safeguard-impl/src/test/java/org/apache/safeguard/impl/executionPlans/AsyncOnlyExecutionPlanTest.java
@@ -32,7 +32,7 @@ public class AsyncOnlyExecutionPlanTest {
public void shouldExecuteAsncWithoutTimeout() {
AsyncOnlyExecutionPlan asyncOnlyExecutionPlan = new AsyncOnlyExecutionPlan(Executors.newFixedThreadPool(2));
MyCallable callable = new MyCallable();
- asyncOnlyExecutionPlan.execute(callable);
+ asyncOnlyExecutionPlan.execute(callable, null);
assertThat(callable.calledThread).isNotEqualTo(Thread.currentThread().getName());
}
http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/0f811c37/safeguard-impl/src/test/java/org/apache/safeguard/impl/executionPlans/AsyncTimeoutExecutionPlanTest.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/test/java/org/apache/safeguard/impl/executionPlans/AsyncTimeoutExecutionPlanTest.java b/safeguard-impl/src/test/java/org/apache/safeguard/impl/executionPlans/AsyncTimeoutExecutionPlanTest.java
index b45727a..9bf2ffe 100644
--- a/safeguard-impl/src/test/java/org/apache/safeguard/impl/executionPlans/AsyncTimeoutExecutionPlanTest.java
+++ b/safeguard-impl/src/test/java/org/apache/safeguard/impl/executionPlans/AsyncTimeoutExecutionPlanTest.java
@@ -35,7 +35,7 @@ public class AsyncTimeoutExecutionPlanTest {
AsyncTimeoutExecutionPlan asyncTimeoutExecutionPlan = new AsyncTimeoutExecutionPlan(Duration.ofMillis(1000), Executors.newSingleThreadExecutor());
DelayedCaller callable = new DelayedCaller(200);
- asyncTimeoutExecutionPlan.execute(callable);
+ asyncTimeoutExecutionPlan.execute(callable, null);
String myThreadName = Thread.currentThread().getName();
assertThat(callable.executedThread).isNotEqualTo(myThreadName);
@@ -46,7 +46,7 @@ public class AsyncTimeoutExecutionPlanTest {
AsyncTimeoutExecutionPlan asyncTimeoutExecutionPlan = new AsyncTimeoutExecutionPlan(Duration.ofMillis(100), Executors.newSingleThreadExecutor());
DelayedCaller callable = new DelayedCaller(200);
- assertThatThrownBy(() -> asyncTimeoutExecutionPlan.execute(callable)).isInstanceOf(TimeoutException.class);
+ assertThatThrownBy(() -> asyncTimeoutExecutionPlan.execute(callable, null)).isInstanceOf(TimeoutException.class);
}
private static class DelayedCaller implements Callable<Object> {
http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/0f811c37/safeguard-impl/src/test/java/org/apache/safeguard/impl/executionPlans/SyncFailsafeExecutionPlanTest.java
----------------------------------------------------------------------
diff --git a/safeguard-impl/src/test/java/org/apache/safeguard/impl/executionPlans/SyncFailsafeExecutionPlanTest.java b/safeguard-impl/src/test/java/org/apache/safeguard/impl/executionPlans/SyncFailsafeExecutionPlanTest.java
index 66876e3..016cdef 100644
--- a/safeguard-impl/src/test/java/org/apache/safeguard/impl/executionPlans/SyncFailsafeExecutionPlanTest.java
+++ b/safeguard-impl/src/test/java/org/apache/safeguard/impl/executionPlans/SyncFailsafeExecutionPlanTest.java
@@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
public class SyncFailsafeExecutionPlanTest {
@Test
public void shouldThrowExceptionWithInvalidConfig() {
- assertThatThrownBy(() -> new SyncFailsafeExecutionPlan(null, null))
+ assertThatThrownBy(() -> new SyncFailsafeExecutionPlan(null, null, null))
.isInstanceOf(IllegalStateException.class)
.hasMessage("For non-async invocations, must have at least one of RetryDefintion or CircuitBreaker defined");
}
http://git-wip-us.apache.org/repos/asf/geronimo-safeguard/blob/0f811c37/safeguard-tck-tests/pom.xml
----------------------------------------------------------------------
diff --git a/safeguard-tck-tests/pom.xml b/safeguard-tck-tests/pom.xml
index 631ebc3..bdff948 100644
--- a/safeguard-tck-tests/pom.xml
+++ b/safeguard-tck-tests/pom.xml
@@ -66,16 +66,33 @@
<dependenciesToScan>
<dependency>org.eclipse.microprofile.fault-tolerance:microprofile-fault-tolerance-tck</dependency>
</dependenciesToScan>
- <includes>
- <include>org.eclipse.microprofile.fault.tolerance.tck.CircuitBreakerTest</include>
- <!--<include>org.eclipse.microprofile.fault.tolerance.tck.CircuitBreakerRetryTest</include>-->
- <!--<include>org.eclipse.microprofile.fault.tolerance.tck.ConfigTest</include>-->
- <!--<include>org.eclipse.microprofile.fault.tolerance.tck.FallbackTest</include>-->
- <include>org.eclipse.microprofile.fault.tolerance.tck.RetryConditionTest</include>
- <include>org.eclipse.microprofile.fault.tolerance.tck.RetryTest</include>
- <include>org.eclipse.microprofile.fault.tolerance.tck.RetryTimeoutTest</include>
- <include>org.eclipse.microprofile.fault.tolerance.tck.TimeoutTest</include>
- </includes>
+ <excludes>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.CircuitBreakerRetryTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.ConfigTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.bulkhead.BulkheadAsynchRetryTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.bulkhead.BulkheadAsynchTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.bulkhead.BulkheadFutureTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.bulkhead.BulkheadSynchRetryTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.bulkhead.BulkheadSynchTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.disableEnv.DisableTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.illegalConfig.IncompatibleFallbackMethodTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.illegalConfig.IncompatibleFallbackMethodWithArgsTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.illegalConfig.IncompatibleFallbackTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.invalidParameters.InvalidBulkheadAsynchQueueTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.invalidParameters.InvalidCircuitBreakerFailureRatioPosTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.invalidParameters.InvalidCircuitBreakerFailureReqVol0Test</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.invalidParameters.InvalidRetryJitterTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.invalidParameters.InvalidCircuitBreakerFailureSuccess0Test</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.invalidParameters.InvalidCircuitBreakerDelayTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.invalidParameters.InvalidRetryDelayTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.invalidParameters.InvalidCircuitBreakerFailureRatioNegTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.invalidParameters.InvalidBulkheadValueTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.invalidParameters.InvalidCircuitBreakerFailureReqVolNegTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.invalidParameters.InvalidRetryDelayDurationTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.invalidParameters.InvalidTimeoutValueTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.invalidParameters.InvalidCircuitBreakerFailureSuccessNegTest</exclude>
+ <exclude>org.eclipse.microprofile.fault.tolerance.tck.invalidParameters.InvalidRetryMaxRetriesTest</exclude>
+ </excludes>
</configuration>
</plugin>
</plugins>