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

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


The following commit(s) were added to refs/heads/master by this push:
     new bb00de2  CAMEL-16353: camel-core - Force eager classloading in build 
phase
bb00de2 is described below

commit bb00de276bdfcdd93e024407745c5ff6eee487ac
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Sun Mar 14 13:05:09 2021 +0100

    CAMEL-16353: camel-core - Force eager classloading in build phase
---
 .../org/apache/camel/impl/engine/PrototypeExchangeFactory.java     | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PrototypeExchangeFactory.java
 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PrototypeExchangeFactory.java
index d8e0c3f..da06d70 100644
--- 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PrototypeExchangeFactory.java
+++ 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PrototypeExchangeFactory.java
@@ -51,6 +51,13 @@ public class PrototypeExchangeFactory extends 
PooledObjectFactorySupport<Exchang
     protected void doBuild() throws Exception {
         super.doBuild();
         this.exchangeFactoryManager = 
camelContext.adapt(ExtendedCamelContext.class).getExchangeFactoryManager();
+        // force to create and load the class during build time so the JVM 
does not
+        // load the class on first exchange to be created
+        DefaultExchange dummy = new DefaultExchange(camelContext);
+        // force message init to load classes
+        dummy.getIn();
+        dummy.getIn().getHeaders();
+        LOG.trace("Warming up PrototypeExchangeFactory loaded class: {}", 
dummy.getClass().getName());
     }
 
     @Override

Reply via email to