Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pass empty contexts rather than null to UniAwait #1458

Merged
merged 1 commit into from
Dec 7, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public UniOnItemOrFailure<T> onItemOrFailure() {

@Override
public UniAwait<T> await() {
return awaitUsing(null);
return awaitUsing(Context.empty());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,20 @@ void checkForbid() throws InterruptedException {
.isInstanceOf(IllegalStateException.class)
.hasMessage("The current thread cannot be blocked: my-forbidden-thread");
}

@Test
void checkImplicitContextPassing() {
AtomicBoolean contextPassed = new AtomicBoolean();
Integer res = Uni.createFrom().item(123)
.withContext((uni, ctx) -> {
ctx.put("foo", "bar");
return uni;
})
.withContext((uni, ctx) -> uni.onItem()
.invoke(() -> contextPassed.set(ctx.getOrElse("foo", () -> "n/a").equals("bar"))))
.await().indefinitely();
assertThat(res).isEqualTo(123);
assertThat(contextPassed).isTrue();
}
}
}