Consistently throw Task/InvocationRejectedException on access rejected

Closes gh-36167
This commit is contained in:
Juergen Hoeller
2026-01-18 15:39:58 +01:00
parent 3f390d55f0
commit 2d2809f45c
5 changed files with 53 additions and 21 deletions
@@ -21,12 +21,9 @@ import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Test;
import org.springframework.util.ConcurrencyThrottleSupport;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.willCallRealMethod;
@@ -61,9 +58,9 @@ class SimpleAsyncTaskExecutorTests {
@Test
void cannotExecuteWhenConcurrencyIsSwitchedOff() {
try (SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor()) {
executor.setConcurrencyLimit(ConcurrencyThrottleSupport.NO_CONCURRENCY);
executor.setConcurrencyLimit(SimpleAsyncTaskExecutor.NO_CONCURRENCY);
assertThat(executor.isThrottleActive()).isTrue();
assertThatIllegalStateException().isThrownBy(() -> executor.execute(new NoOpRunnable()));
assertThatExceptionOfType(TaskRejectedException.class).isThrownBy(() -> executor.execute(new NoOpRunnable()));
}
}