Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions flows/src/main/java/com/softwaremill/jox/flows/Flow.java
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,11 @@ public Flow<T> takeWhile(Predicate<T> f, boolean includeFirstFailing) {
throw new BreakException();
}
});
} catch (JoxScopeExecutionException e) {
if (!(e.getCause() instanceof BreakException)) {
throw e;
}
// done
} catch (BreakException e) {
// done
}
Expand Down
9 changes: 9 additions & 0 deletions flows/src/test/java/com/softwaremill/jox/flows/FlowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,15 @@ void shouldNotTakeIfPredicateFailsForFirstOrMoreElements() throws Exception {
assertEquals(List.of(), flow.runToList());
}

@Test
void shouldTakeWhileFromAsyncFlow() throws Exception {
// given
Flow<Integer> flow = Flows.fromValues(3, 2, 1).buffer().takeWhile(x -> x > 2, false);

// when & then
assertEquals(List.of(3), flow.runToList());
}

@Test
void shouldNotThrottleEmptySource() throws Exception {
// given
Expand Down
Loading