diff --git a/implementation/src/main/java/io/smallrye/mutiny/operators/AbstractUni.java b/implementation/src/main/java/io/smallrye/mutiny/operators/AbstractUni.java index eed2551c7..ccfe8be87 100644 --- a/implementation/src/main/java/io/smallrye/mutiny/operators/AbstractUni.java +++ b/implementation/src/main/java/io/smallrye/mutiny/operators/AbstractUni.java @@ -81,7 +81,7 @@ public UniOnItemOrFailure onItemOrFailure() { @Override public UniAwait await() { - return awaitUsing(null); + return awaitUsing(Context.empty()); } @Override diff --git a/implementation/src/test/java/io/smallrye/mutiny/operators/UniAwaitTest.java b/implementation/src/test/java/io/smallrye/mutiny/operators/UniAwaitTest.java index 5d39e7aec..f037254b4 100644 --- a/implementation/src/test/java/io/smallrye/mutiny/operators/UniAwaitTest.java +++ b/implementation/src/test/java/io/smallrye/mutiny/operators/UniAwaitTest.java @@ -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(); + } } }