davsclaus commented on code in PR #19402:
URL: https://github.com/apache/camel/pull/19402#discussion_r2398966397


##########
core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultContextServiceLoaderPlugin.java:
##########
@@ -58,13 +59,22 @@ public class DefaultContextServiceLoaderPlugin extends 
ServiceSupport implements
      */
     @Override
     protected void doStart() throws Exception {
-        ServiceLoader<ContextServicePlugin> contextServicePlugins = 
ServiceLoader.load(ContextServicePlugin.class,
+        contextServicePlugins = ServiceLoader.load(ContextServicePlugin.class,
                 camelContext.getApplicationContextClassLoader());
         for (ContextServicePlugin plugin : contextServicePlugins) {
             plugin.load(camelContext);
         }
     }
 
+    @Override
+    protected void doStop() throws Exception {
+        if (contextServicePlugins != null) {
+            for (ContextServicePlugin plugin : contextServicePlugins) {

Review Comment:
   You may want to do a try .. catch and LOG warn about ignoring this exception 
so all the plugins can do their stop logic as that is more important than if 
one fails then the others are not unloaded.



##########
core/camel-api/src/main/java/org/apache/camel/spi/ContextServicePlugin.java:
##########
@@ -66,4 +66,11 @@ public interface ContextServicePlugin {
      * @param camelContext the CamelContext being initialized, never {@code 
null}
      */
     void load(CamelContext camelContext);
+
+    /**
+     * Called during CamelContext stop. Use it to free allocated resources.
+     */
+    default void unload() {

Review Comment:
   Maybe add CamelContext so its same as load



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