Add test for delayed error on error recovery branch
diff --git a/itests/src/main/java/org/apache/aries/component/dsl/test/DSLTest.java b/itests/src/main/java/org/apache/aries/component/dsl/test/DSLTest.java
index e24d630..4cc6144 100644
--- a/itests/src/main/java/org/apache/aries/component/dsl/test/DSLTest.java
+++ b/itests/src/main/java/org/apache/aries/component/dsl/test/DSLTest.java
@@ -1591,6 +1591,61 @@
}
@Test
+ public void testNestedRecoverWithDelayedErrorOnRecoverBranch() {
+ ArrayList<Integer> result = new ArrayList<>();
+
+ ArrayList<ProbeImpl<Integer>> probes = new ArrayList<>();
+
+ OSGi<Integer> program = recoverWith(
+ recoverWith(
+ just(Arrays.asList(1, 2, 3, 4, 5, 6)).
+ effects(
+ t -> {
+ if (t % 5 == 0) {
+ throw new IllegalArgumentException();
+ }
+ }
+ , __ -> {
+ }
+ ),
+ (t, e) -> just(2).flatMap(s -> {
+ ProbeImpl<Integer> probe = new ProbeImpl<>();
+
+ probes.add(probe);
+
+ return probe.then(
+ just(0).effects(
+ __ -> {
+ throw (RuntimeException)e;
+ },
+ __ -> {}
+ ));
+ })).
+ effects(t -> {
+ if (t % 2 == 0) {
+ throw new IllegalArgumentException();
+ }
+ }
+ , __ -> {
+ }),
+ (t, e) -> just(8));
+
+ try (OSGiResult run = program.run(bundleContext, e -> {
+ result.add(e);
+
+ return NOOP;
+ })) {
+ assertEquals(Arrays.asList(1, 8, 3, 8, 8), result);
+
+ for (ProbeImpl<Integer> probe : probes) {
+ probe.getPublisher().publish(0);
+ }
+
+ assertEquals(Arrays.asList(1, 8, 3, 8, 8, 8), result);
+ }
+ }
+
+ @Test
public void testRegister() {
assertNull(bundleContext.getServiceReference(Service.class));