This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-3.x by this push:
     new 8c03e10db06 CAMEL-19353: camel-jbang - Reload on demand should use ACL 
classloader so using what Camel was used during boostrap to be consistent.
8c03e10db06 is described below

commit 8c03e10db06ee0f59d760f7735b0eb55a8382825
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon May 15 16:53:05 2023 +0200

    CAMEL-19353: camel-jbang - Reload on demand should use ACL classloader so 
using what Camel was used during boostrap to be consistent.
---
 .../org/apache/camel/support/RouteOnDemandReloadStrategy.java  | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git 
a/core/camel-support/src/main/java/org/apache/camel/support/RouteOnDemandReloadStrategy.java
 
b/core/camel-support/src/main/java/org/apache/camel/support/RouteOnDemandReloadStrategy.java
index 0e300322d29..fd71e22782f 100644
--- 
a/core/camel-support/src/main/java/org/apache/camel/support/RouteOnDemandReloadStrategy.java
+++ 
b/core/camel-support/src/main/java/org/apache/camel/support/RouteOnDemandReloadStrategy.java
@@ -64,7 +64,13 @@ public class RouteOnDemandReloadStrategy extends 
RouteWatcherReloadStrategy {
      */
     @Override
     public void onReload(Object source) {
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
         try {
+            // use bootstrap classloader from camel so its consistent
+            ClassLoader acl = 
getCamelContext().getApplicationContextClassLoader();
+            if (acl != null) {
+                Thread.currentThread().setContextClassLoader(acl);
+            }
             doOnReload(source);
             incSucceededCounter();
         } catch (Exception e) {
@@ -72,6 +78,10 @@ public class RouteOnDemandReloadStrategy extends 
RouteWatcherReloadStrategy {
             LOG.warn("Error reloading routes due " + e.getMessage()
                      + ". This exception is ignored.",
                     e);
+        } finally {
+            if (cl != null) {
+                Thread.currentThread().setContextClassLoader(cl);
+            }
         }
     }
 

Reply via email to