Fix ignored target assertions in ConcurrencyLimitTests

The rejection tests verified the exception target with
`satisfies(ex -> assertThat(ex.getTarget() == target))`, which never
asserts anything as the boolean `assertThat` is not followed by a
check.

Assert the target via `extracting(...).isSameAs(...)` instead, against
the proxy, since the concurrency throttle is applied at the AOP proxy
level and the proxy is what gets passed as the exception target.

Closes gh-37411

Signed-off-by: Tim te Beek <tim@moderne.io>
This commit is contained in:
Tim te Beek
2026-10-07 11:50:12 +02:00
committed by GitHub
parent b2181e7da4
commit 11d2c457e7
@@ -137,7 +137,7 @@ class ConcurrencyLimitTests {
futures.add(CompletableFuture.runAsync(() ->
assertThatExceptionOfType(InvocationRejectedException.class).isThrownBy(proxy::rejectingOperation)
.withMessageContaining(AnnotatedMethodBean.class.getName() + ".rejectingOperation")
.satisfies(ex -> assertThat(ex.getTarget() == target))));
.extracting(InvocationRejectedException::getTarget).isSameAs(proxy)));
}
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
assertThat(target.current).hasValue(2);
@@ -178,11 +178,11 @@ class ConcurrencyLimitTests {
futures.add(CompletableFuture.runAsync(() ->
assertThatExceptionOfType(InvocationRejectedException.class).isThrownBy(proxy::concurrentOperation)
.withMessageContaining(AnnotatedClassBeanWithRejection.class.getName())
.satisfies(ex -> assertThat(ex.getTarget() == target))));
.extracting(InvocationRejectedException::getTarget).isSameAs(proxy)));
futures.add(CompletableFuture.runAsync(() ->
assertThatExceptionOfType(InvocationRejectedException.class).isThrownBy(proxy::otherOperation)
.withMessageContaining(AnnotatedClassBeanWithRejection.class.getName())
.satisfies(ex -> assertThat(ex.getTarget() == target))));
.extracting(InvocationRejectedException::getTarget).isSameAs(proxy)));
for (int i = 0; i < 4; i++) {
futures.add(CompletableFuture.runAsync(proxy::overrideOperation));
}