Skip to content

Commit

Permalink
Merge pull request #1458 from smallrye/bug/UniAwait-null-context
Browse files Browse the repository at this point in the history
fix: pass empty contexts rather than null to UniAwait
  • Loading branch information
jponge authored Dec 7, 2023
2 parents 8429724 + 303bdab commit efc3d0c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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();
}
}
}

0 comments on commit efc3d0c

Please sign in to comment.