allthingssecurity commented on code in PR #30628:
URL: https://github.com/apache/camel/pull/30628#discussion_r4660949208


##########
components/camel-netty/src/main/java/org/apache/camel/component/netty/TimeoutCorrelationManagerSupport.java:
##########
@@ -239,6 +258,22 @@ private void onEviction(Type type, String key, 
NettyCamelState value) {
                 }
                 callback.done(false);
             }
-        });
+        };
+        ExecutorService pool = workerPool;
+        if (pool != null) {
+            try {
+                pool.submit(task);
+            } catch (RejectedExecutionException e) {
+                LOG.debug("The worker pool rejected the timeout of correlation 
id: {}. Running it in this thread.", key);
+                task.run();
+                return;
+            }
+        }
+        if (pool == null || pool.isShutdown()) {

Review Comment:
   Thanks. I kept the fall-through on purpose. The worker pool that Camel 
creates uses CallerRunsPolicy, and when that pool is shut down the policy drops 
the task without throwing: submit returns normally and the task never runs. 
With a return after the submit, the timeout of an entry evicted during the stop 
would be lost and the request would never complete. When the pool accepted the 
task and also runs it, the second run does nothing, as markDone lets only one 
of them complete the exchange.
   
   The existing test only covered a pool that throws 
RejectedExecutionException, so I added 
testTimeoutDiscardedByShutDownCallerRunsWorkerPoolCompletesTheRequest (a 
shut-down pool with CallerRunsPolicy). It fails with the return after submit 
and passes as is. I also made the code comment say this plainly (96869bf7472).



-- 
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]

Reply via email to