allthingssecurity commented on code in PR #30304:
URL: https://github.com/apache/camel/pull/30304#discussion_r4611019771
##########
core/camel-core-processor/src/main/java/org/apache/camel/processor/ConcurrentRequestsThrottler.java:
##########
@@ -183,14 +183,16 @@ private static void doThrottle(Exchange exchange,
ThrottlingState throttlingStat
*/
protected boolean processAsynchronously(
final Exchange exchange, final AsyncCallback callback,
ThrottlingState throttlingState) {
+ AsyncCall call = newAsyncCall(exchange, callback);
try {
if (LOG.isTraceEnabled()) {
exchange.setProperty(PROPERTY_EXCHANGE_QUEUED_TIME,
TimeSource.nanoTime());
}
exchange.setProperty(PROPERTY_EXCHANGE_STATE, State.ASYNC);
- asyncExecutor.submit(() -> process(exchange, callback));
+ asyncExecutor.submit(call);
return false;
} catch (final RejectedExecutionException e) {
+ call.rejected();
Review Comment:
Fixed in c61883f: `AsyncCall.rejected()` now returns the result of the
remove, and the catch block returns `false` when `doShutdown` already claimed
the call. Covered by `AsyncDelayedShutdownRaceTest`.
_Claude Code on behalf of allthingssecurity_
##########
core/camel-core-processor/src/main/java/org/apache/camel/processor/ConcurrentRequestsThrottler.java:
##########
@@ -183,14 +183,16 @@ private static void doThrottle(Exchange exchange,
ThrottlingState throttlingStat
*/
protected boolean processAsynchronously(
final Exchange exchange, final AsyncCallback callback,
ThrottlingState throttlingState) {
+ AsyncCall call = newAsyncCall(exchange, callback);
try {
if (LOG.isTraceEnabled()) {
exchange.setProperty(PROPERTY_EXCHANGE_QUEUED_TIME,
TimeSource.nanoTime());
}
exchange.setProperty(PROPERTY_EXCHANGE_STATE, State.ASYNC);
- asyncExecutor.submit(() -> process(exchange, callback));
+ asyncExecutor.submit(call);
return false;
} catch (final RejectedExecutionException e) {
+ call.rejected();
if (isCallerRunsWhenRejected()) {
Review Comment:
Fixed in c61883f: `AsyncCall.rejected()` now returns the result of the
remove, and the catch block returns `false` when `doShutdown` already claimed
the call. Covered by `AsyncDelayedShutdownRaceTest`.
_Claude Code on behalf of allthingssecurity_
##########
core/camel-core-processor/src/main/java/org/apache/camel/processor/TotalRequestsThrottler.java:
##########
@@ -201,9 +202,10 @@ protected boolean processAsynchronously(
// exchanges and not yet returned, so try again after one period
long delay = next != null
? next.getDelay(TimeUnit.NANOSECONDS) :
TimeUnit.MILLISECONDS.toNanos(getTimePeriodMillis());
- asyncExecutor.schedule(() -> process(exchange, callback), delay,
TimeUnit.NANOSECONDS);
+ asyncExecutor.schedule(call, delay, TimeUnit.NANOSECONDS);
return false;
} catch (final RejectedExecutionException e) {
+ call.rejected();
if (isCallerRunsWhenRejected()) {
Review Comment:
Fixed in c61883f: `AsyncCall.rejected()` now returns the result of the
remove, and the catch block returns `false` when `doShutdown` already claimed
the call. Covered by `AsyncDelayedShutdownRaceTest`.
_Claude Code on behalf of allthingssecurity_
##########
core/camel-core-processor/src/main/java/org/apache/camel/processor/DelayProcessorSupport.java:
##########
@@ -130,6 +140,7 @@ protected boolean processDelay(Exchange exchange,
AsyncCallback callback, long d
return false;
} catch (RejectedExecutionException e) {
// we were not allowed to run the ProcessCall, so need to
decrement the counter here
+ scheduledCalls.remove(call);
Review Comment:
Fixed in c61883f: the catch block returns `false` before the decrement when
`scheduledCalls.remove(call)` is false, so `delayedCount` is decremented once.
Covered by `AsyncDelayedShutdownRaceTest`.
_Claude Code on behalf of allthingssecurity_
##########
core/camel-core-processor/src/main/java/org/apache/camel/processor/DelayProcessorSupport.java:
##########
@@ -130,6 +140,7 @@ protected boolean processDelay(Exchange exchange,
AsyncCallback callback, long d
return false;
} catch (RejectedExecutionException e) {
// we were not allowed to run the ProcessCall, so need to
decrement the counter here
+ scheduledCalls.remove(call);
delayedCount.decrementAndGet();
Review Comment:
Fixed in c61883f: the catch block returns `false` before the decrement when
`scheduledCalls.remove(call)` is false, so `delayedCount` is decremented once.
Covered by `AsyncDelayedShutdownRaceTest`.
_Claude Code on behalf of allthingssecurity_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]