You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/02/12 09:26:13 UTC

[camel] branch master updated (579a810 -> 7488481)

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

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


    from 579a810  Camel-Saxon: Fixed CS
     new efc4d0c  CAMEL-14538: camel-core - Do not load type converters via package scanning by default
     new 7488481  camel-core - Fix concurrency issue with error handlers when using multicast based EIPs. And yeah child service support can use a plain array as it was not the concurrency problem after all.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/impl/engine/AbstractCamelContext.java    |  2 +-
 .../camel/impl/engine/DefaultRouteContext.java     |  5 ++++-
 .../camel/main/DefaultConfigurationProperties.java |  2 +-
 .../apache/camel/support/ChildServiceSupport.java  |  4 ++--
 .../modules/ROOT/pages/camel-3x-upgrade-guide.adoc | 26 ++++++++++++++++++++++
 .../modules/ROOT/pages/type-converter.adoc         | 26 +++++++++++++++++++++-
 6 files changed, 59 insertions(+), 6 deletions(-)


[camel] 01/02: CAMEL-14538: camel-core - Do not load type converters via package scanning by default

Posted by da...@apache.org.
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

commit efc4d0c5da83598fc4adc7d3f3a85251a172491e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Feb 12 10:03:04 2020 +0100

    CAMEL-14538: camel-core - Do not load type converters via package scanning by default
---
 .../camel/impl/engine/AbstractCamelContext.java    |  2 +-
 .../camel/main/DefaultConfigurationProperties.java |  2 +-
 .../modules/ROOT/pages/camel-3x-upgrade-guide.adoc | 26 ++++++++++++++++++++++
 .../modules/ROOT/pages/type-converter.adoc         | 26 +++++++++++++++++++++-
 4 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index 71959a0..1387bad 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -212,7 +212,7 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Ext
     private Boolean logExhaustedMessageBody = Boolean.FALSE;
     private Boolean streamCache = Boolean.FALSE;
     private Boolean disableJMX = Boolean.FALSE;
-    private Boolean loadTypeConverters = Boolean.TRUE;
+    private Boolean loadTypeConverters = Boolean.FALSE;
     private Boolean typeConverterStatisticsEnabled = Boolean.FALSE;
     private Boolean useMDCLogging = Boolean.FALSE;
     private String mdcLoggingKeysPattern;
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
index 1a26864..35135e7 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
@@ -39,7 +39,7 @@ public abstract class DefaultConfigurationProperties<T> {
     private boolean jmxEnabled = true;
     private int producerTemplateCacheSize = 1000;
     private int consumerTemplateCacheSize = 1000;
-    private boolean loadTypeConverters = true;
+    private boolean loadTypeConverters;
     private int logDebugMaxChars;
     private boolean streamCachingEnabled;
     private String streamCachingSpoolDirectory;
diff --git a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc
index 52f398d..ad7fb1f 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc
@@ -147,6 +147,32 @@ of using XML for beans and Camel XML routes. And a few components such as `camel
 
 But at general then Camel is now lighter in classpath dependency by not requiring to have JAXB present.
 
+=== Package scanning @TypeConverter
+
+Camel has now been configured to not package scan for custom `@Converter` classes on startup.
+Type converters are now loaded and registered in faster way via source code generated loader classes
+by having `@Converter(loader = true)` specified. If you have custom converters and have not migrated to use
+source code generated loaders, you can enable package scanning by setting
+
+[source,java]
+----
+camelContext.setLoadTypeConverters(true);
+----
+
+And in XML:
+[source,xml]
+----
+<camelContext loadTypeConverters="true">
+...
+</camelContext>
+----
+
+And in Spring Boot `application.properties`:
+[source,properties]
+----
+camel.loadTypeConverters=true
+----
+
 === Graceful Shutdown Timeout
 
 When shutting down Camel, then the default timeout has changed from 300 seconds (5 minutes) to 45 seconds.
diff --git a/docs/user-manual/modules/ROOT/pages/type-converter.adoc b/docs/user-manual/modules/ROOT/pages/type-converter.adoc
index 9da6bdd..dbd1941 100644
--- a/docs/user-manual/modules/ROOT/pages/type-converter.adoc
+++ b/docs/user-manual/modules/ROOT/pages/type-converter.adoc
@@ -139,7 +139,31 @@ all type converter loader classes (they are automatic source code generated by t
 These _loader_ classes will load the type converters into the Camel type converter registry
 and invoking these type converters is done in a _fast way_ using standard java method calls.
 
-The discover will fallback and discover Camel 2.x compatible type converters by
+=== Discovering Camel 2.x based type converters (not loader)
+
+Camel will not perform additional package scanning for type conveters which has no source code generated loader classes.
+However this can be enabled by setting:
+
+[source,java]
+----
+camelContext.setLoadTypeConverters(true);
+----
+
+And in XML:
+[source,xml]
+----
+<camelContext loadTypeConverters="true">
+...
+</camelContext>
+----
+
+And in Spring Boot `application.properties`:
+[source,properties]
+----
+camel.loadTypeConverters=true
+----
+
+Then Camel will discover discover Camel 2.x compatible type converters by
 search the classpath for a file called `META-INF/services/org/apache/camel/TypeConverter`,
 which lists all the type converter classes. These classes will then automatic
 be registered in the type converter registry. However invoking these type converters


[camel] 02/02: camel-core - Fix concurrency issue with error handlers when using multicast based EIPs. And yeah child service support can use a plain array as it was not the concurrency problem after all.

Posted by da...@apache.org.
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

commit 748848158e0523bb229ce0854c71a059023091b6
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Feb 12 10:25:43 2020 +0100

    camel-core - Fix concurrency issue with error handlers when using multicast based EIPs. And yeah child service support can use a plain array as it was not the concurrency problem after all.
---
 .../main/java/org/apache/camel/impl/engine/DefaultRouteContext.java  | 5 ++++-
 .../src/main/java/org/apache/camel/support/ChildServiceSupport.java  | 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultRouteContext.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultRouteContext.java
index afc8e95..7a5a248 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultRouteContext.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultRouteContext.java
@@ -22,6 +22,8 @@ import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
@@ -78,7 +80,8 @@ public class DefaultRouteContext implements RouteContext {
     private final Map<String, Object> properties = new HashMap<>();
     private ErrorHandlerFactory errorHandlerFactory;
     private Integer startupOrder;
-    private Map<ErrorHandlerFactory, Set<NamedNode>> errorHandlers = new HashMap<>();
+    // must be concurrent as error handlers can be mutated concurrently via multicast/recipientlist EIPs
+    private ConcurrentMap<ErrorHandlerFactory, Set<NamedNode>> errorHandlers = new ConcurrentHashMap<>();
 
     public DefaultRouteContext(CamelContext camelContext, NamedNode route, String routeId) {
         this.camelContext = camelContext;
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ChildServiceSupport.java b/core/camel-support/src/main/java/org/apache/camel/support/ChildServiceSupport.java
index bf1a820..c3bbb30 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/ChildServiceSupport.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/ChildServiceSupport.java
@@ -16,8 +16,8 @@
  */
 package org.apache.camel.support;
 
+import java.util.ArrayList;
 import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.Service;
@@ -127,7 +127,7 @@ public abstract class ChildServiceSupport extends ServiceSupport {
             if (childServices == null) {
                 synchronized (lock) {
                     if (childServices == null) {
-                        childServices = new CopyOnWriteArrayList<>();
+                        childServices = new ArrayList<>();
                     }
                 }
             }