Simon Wong opened SPR-15895 and commented
When I set the SimpleAsyncTaskExecutor setConcurrencyLimit with value ConcurrencyThrottleSupport.NO_CONCURRENCY (i.e. value = 0), the execute of SimpleAsyncTaskExecutor will not take NO_CONCURRENCY in consideration. The Runnable will always be executed in all cases.
public void execute(Runnable task, long startTimeout) {
Assert.notNull(task, "Runnable must not be null");
Runnable taskToUse = (this.taskDecorator != null ? this.taskDecorator.decorate(task) : task);
if (isThrottleActive() && startTimeout > TIMEOUT_IMMEDIATE) {
this.concurrencyThrottle.beforeAccess();
doExecute(new ConcurrencyThrottlingRunnable(taskToUse));
}
else {
doExecute(taskToUse);
}
}
The root cause is isThrottleActive() will always returns false as the concurrent limit = 0 in this case, hence ConcurrencyThrottleAdapter will not be processed.
This is also the reason why the 1st test case SimpleAsyncTaskExecutorTests cannotExecuteWhenConcurrencyIsSwitchedOff is disabled by the SPF committer.
The current workaround is SimpleAsyncTaskExecutor.setConcurrencyLimit(1).
BTW, NO_CONCURRENCY = 0 is somehow wrong in definition. No currency should means there should be one invocation of method at a time, other invocations should be waited. That means NO_CONCURRENCY should have a value of 1 instead.
Affects: 4.3.10
Issue Links:
Referenced from: commits f3a2f57, 204ddeb
Simon Wong opened SPR-15895 and commented
When I set the
SimpleAsyncTaskExecutorsetConcurrencyLimitwith valueConcurrencyThrottleSupport.NO_CONCURRENCY(i.e. value = 0), theexecuteofSimpleAsyncTaskExecutorwill not takeNO_CONCURRENCYin consideration. TheRunnablewill always be executed in all cases.The root cause is
isThrottleActive()will always returnsfalseas the concurrent limit = 0 in this case, henceConcurrencyThrottleAdapterwill not be processed.This is also the reason why the 1st test case
SimpleAsyncTaskExecutorTestscannotExecuteWhenConcurrencyIsSwitchedOffis disabled by the SPF committer.The current workaround is
SimpleAsyncTaskExecutor.setConcurrencyLimit(1).BTW,
NO_CONCURRENCY = 0is somehow wrong in definition. No currency should means there should be one invocation of method at a time, other invocations should be waited. That meansNO_CONCURRENCYshould have a value of1instead.Affects: 4.3.10
Issue Links:
Referenced from: commits f3a2f57, 204ddeb