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


##########
core/camel-support/src/main/java/org/apache/camel/support/component/AbstractApiProducer.java:
##########
@@ -114,10 +124,47 @@ public void run() {
             }
         };
 
-        endpoint.getExecutorService().submit(invocation);
+        final ExecutorService executorService;
+        try {
+            executorService = endpoint.getExecutorService();
+        } catch (RejectedExecutionException e) {
+            // the CamelContext has stopped, and has no pool for this endpoint
+            return rejected(exchange, callback, e);
+        }
+        if (executorService.isShutdown()) {
+            // the CallerRuns policy of a shut down pool would drop the task 
without running it, and the exchange would
+            // never complete
+            return rejected(exchange, callback, newRejectedException(method));
+        }
+        try {
+            executorService.submit(invocation);
+        } catch (RejectedExecutionException e) {
+            if (claimed.compareAndSet(false, true)) {
+                return rejected(exchange, callback, e);
+            }
+            // the rejection policy ran the task before it threw, and the task 
completes the exchange

Review Comment:
   Right, thanks: with the JDK policies this branch is not reached 
(`CallerRunsPolicy` drops the task of a shut down pool, `AbortPolicy` throws 
without running it), only a custom handler that runs the task and then throws 
gets here. Reworded the comment in 4c71eebbab28 along your suggestion; comment 
only.
   
   _Claude Code on behalf of allthingssecurity_
   



##########
docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc:
##########
@@ -1191,6 +1191,13 @@ as `camel run` already did. Before, the failure left 
`main()` and only the JVM p
 The JVM no longer prints that same failure a second time. When the application 
logs nothing at ERROR (such as without
 a logging implementation), the JVM prints it as before.
 
+=== camel-support - API components use one thread pool per CamelContext
+
+The producers of the API components (AS2, Box, Braintree, DHIS2, FHIR, Google 
Calendar, Google Drive, Google Mail,
+Google Sheets, Twilio and Zendesk) now use one thread pool per component in 
each CamelContext, instead of one pool
+shared by all the CamelContexts of the JVM. An application with several 
CamelContexts can therefore have more threads,
+and each pool uses the thread pool profile (such as `CamelGoogleDrive`) of its 
own CamelContext.
+

Review Comment:
   I left this one as it is. This section comes from #29999 (CAMEL-26538), now 
on main. For CAMEL-26951 davsclaus agreed in his review that no upgrade guide 
entry is needed, since a call that used to hang now fails. Also, before this 
change the call was not dropped with a result: the task was discarded and the 
exchange never completed. A call made while the CamelContext is stopping still 
completes, as before. If you both prefer a sentence about it, I can add one.
   
   _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]

Reply via email to