Skip to content

Commit 5a33cc3

Browse files
committed
Improvements to ThenComposeAsyncTest for exception propagations
1 parent eb4b35c commit 5a33cc3

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/main/java/net/tascalate/concurrent/AbstractCompletableTask.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,7 @@ public <U> Promise<U> thenComposeAsync(Function<? super T, ? extends CompletionS
287287
moveToNextStage.accept(null, ex);
288288
}
289289
}),
290-
e -> {
291-
moveToNextStage.accept(null, e);
292-
return null;
293-
},
290+
consumerAsFunction(e -> moveToNextStage.accept(null, e)),
294291
executor
295292
);
296293

src/test/java/net/tascalate/concurrent/ThenComposeAsyncTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
import static org.junit.Assert.fail;
1919

20+
import java.util.concurrent.ExecutionException;
21+
import java.util.concurrent.TimeUnit;
22+
import java.util.concurrent.TimeoutException;
2023
import java.util.concurrent.atomic.AtomicBoolean;
2124
import org.junit.After;
2225
import org.junit.Assert;
@@ -86,8 +89,11 @@ public void testThenComposeException() {
8689
throw new IllegalStateException("oh no!");
8790
});
8891
try {
89-
p.get();
90-
} catch (Exception ex) {
92+
p.get(1L, TimeUnit.SECONDS);
93+
} catch (TimeoutException ex) {
94+
fail("thenCompose* hanged");
95+
} catch (InterruptedException | ExecutionException ex) {
96+
// System.out.println(ex);
9197
// expected
9298
return;
9399
}

0 commit comments

Comments
 (0)