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 2021/03/14 18:19:46 UTC

[camel] branch master updated (51daa2c -> bfc78dc)

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 51daa2c  Missing one rename of 'useIAMCredentials' as 'useDefaultCredentialsProvider' with the rename in 3.7
     new 557efba  camel-core - Small optimization on Choice EIP
     new 78ea548  CAMEL-16355: camel-core - Optimize Filter and Choice EIP
     new 4cf3569  camel-core - Optimize exchange properties to create on-demand as camel-core uses only internal properties to store state.
     new bfc78dc  CAMEL-16355: camel-core - Optimize Filter and Choice EIP

The 4 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/catalog/docs/aws2-sqs-component.adoc     |  4 +-
 .../apache/camel/component/aws2/sqs/aws2-sqs.json  |  4 +-
 .../src/main/docs/aws2-sqs-component.adoc          |  4 +-
 .../component/aws2/sqs/Sqs2Configuration.java      |  1 +
 .../camel/component/aws2/sqs/Sqs2Consumer.java     |  4 +-
 .../src/main/java/org/apache/camel/Exchange.java   |  1 +
 .../java/org/apache/camel/ExchangePropertyKey.java |  3 -
 .../dsl/Aws2SqsComponentBuilderFactory.java        |  1 +
 .../apache/camel/processor/ChoiceProcessor.java    | 55 ++++++++----------
 .../apache/camel/processor/FilterProcessor.java    |  4 --
 .../camel/processor/FilterNotMatchedTest.java      |  8 ---
 .../org/apache/camel/processor/FilterNotTest.java  |  2 -
 .../org/apache/camel/processor/FilterTest.java     |  2 -
 .../endpoint/dsl/Sqs2EndpointBuilderFactory.java   |  2 +
 .../org/apache/camel/support/AbstractExchange.java | 65 +++++++++++++---------
 .../camel/support/DefaultPooledExchange.java       |  7 +++
 .../modules/ROOT/pages/aws2-sqs-component.adoc     |  4 +-
 .../ROOT/pages/camel-3x-upgrade-guide-3_9.adoc     |  5 ++
 18 files changed, 89 insertions(+), 87 deletions(-)


[camel] 01/04: camel-core - Small optimization on Choice EIP

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 557efba1617d15082a7f6fb6b81c48102e7d23f7
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Mar 14 17:36:13 2021 +0100

    camel-core - Small optimization on Choice EIP
---
 .../apache/camel/processor/ChoiceProcessor.java    | 32 +++++++++++++---------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/core/camel-core-processor/src/main/java/org/apache/camel/processor/ChoiceProcessor.java b/core/camel-core-processor/src/main/java/org/apache/camel/processor/ChoiceProcessor.java
index bf11759..6fce791 100644
--- a/core/camel-core-processor/src/main/java/org/apache/camel/processor/ChoiceProcessor.java
+++ b/core/camel-core-processor/src/main/java/org/apache/camel/processor/ChoiceProcessor.java
@@ -17,6 +17,7 @@
 package org.apache.camel.processor;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.camel.AsyncCallback;
@@ -46,12 +47,15 @@ public class ChoiceProcessor extends AsyncProcessorSupport implements Navigate<P
 
     private String id;
     private String routeId;
-    private final List<FilterProcessor> filters;
+    // optimize to use an array
+    private final FilterProcessor[] filters;
+    private final int len;
     private final AsyncProcessor otherwise;
     private transient long notFiltered;
 
     public ChoiceProcessor(List<FilterProcessor> filters, Processor otherwise) {
-        this.filters = filters;
+        this.filters = filters.toArray(new FilterProcessor[0]);
+        this.len = filters.size();
         this.otherwise = otherwise != null ? AsyncProcessorConverterHelper.convert(otherwise) : null;
     }
 
@@ -72,7 +76,8 @@ public class ChoiceProcessor extends AsyncProcessorSupport implements Navigate<P
         };
 
         // find the first matching filter and process the exchange using it
-        for (FilterProcessor filter : filters) {
+        for (int i = 0; i < len; i++) {
+            FilterProcessor filter = filters[i];
             // evaluate the predicate on filter predicate early to be faster
             // and avoid issues when having nested choices
             // as we should only pick one processor
@@ -121,7 +126,7 @@ public class ChoiceProcessor extends AsyncProcessorSupport implements Navigate<P
     }
 
     public List<FilterProcessor> getFilters() {
-        return filters;
+        return Arrays.asList(filters);
     }
 
     public Processor getOtherwise() {
@@ -139,8 +144,8 @@ public class ChoiceProcessor extends AsyncProcessorSupport implements Navigate<P
      * Reset counters.
      */
     public void reset() {
-        for (FilterProcessor filter : filters) {
-            filter.reset();
+        for (int i = 0; i < len; i++) {
+            filters[i].reset();
         }
         notFiltered = 0;
     }
@@ -151,8 +156,8 @@ public class ChoiceProcessor extends AsyncProcessorSupport implements Navigate<P
             return null;
         }
         List<Processor> answer = new ArrayList<>();
-        if (!filters.isEmpty()) {
-            answer.addAll(filters);
+        if (len > 0) {
+            answer.addAll(Arrays.asList(filters));
         }
         if (otherwise != null) {
             answer.add(otherwise);
@@ -162,7 +167,7 @@ public class ChoiceProcessor extends AsyncProcessorSupport implements Navigate<P
 
     @Override
     public boolean hasNext() {
-        return otherwise != null || !filters.isEmpty();
+        return otherwise != null || len > 0;
     }
 
     @Override
@@ -187,21 +192,22 @@ public class ChoiceProcessor extends AsyncProcessorSupport implements Navigate<P
 
     @Override
     protected void doInit() throws Exception {
-        ServiceHelper.initService(filters, otherwise);
+        ServiceHelper.initService(Arrays.asList(filters), otherwise);
     }
 
     @Override
     protected void doStart() throws Exception {
-        ServiceHelper.startService(filters, otherwise);
+        ServiceHelper.startService(Arrays.asList(filters), otherwise);
     }
 
     @Override
     protected void doStop() throws Exception {
-        ServiceHelper.stopService(otherwise, filters);
+        ServiceHelper.stopService(otherwise, Arrays.asList(filters));
     }
 
     @Override
     protected void doShutdown() throws Exception {
-        ServiceHelper.stopAndShutdownServices(otherwise, filters);
+        ServiceHelper.stopAndShutdownServices(otherwise, Arrays.asList(filters));
     }
+
 }


[camel] 02/04: CAMEL-16355: camel-core - Optimize Filter and Choice EIP

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 78ea548cb166c8657c4226d339e516a6b8b4c0bd
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Mar 14 17:52:04 2021 +0100

    CAMEL-16355: camel-core - Optimize Filter and Choice EIP
---
 .../camel/catalog/docs/aws2-sqs-component.adoc     |  4 ++--
 .../apache/camel/component/aws2/sqs/aws2-sqs.json  |  4 ++--
 .../src/main/docs/aws2-sqs-component.adoc          |  4 ++--
 .../component/aws2/sqs/Sqs2Configuration.java      |  1 +
 .../camel/component/aws2/sqs/Sqs2Consumer.java     |  4 ++--
 .../src/main/java/org/apache/camel/Exchange.java   |  1 +
 .../java/org/apache/camel/ExchangePropertyKey.java |  3 ---
 .../dsl/Aws2SqsComponentBuilderFactory.java        |  1 +
 .../apache/camel/processor/ChoiceProcessor.java    | 23 ++++------------------
 .../apache/camel/processor/FilterProcessor.java    |  4 ----
 .../camel/processor/FilterNotMatchedTest.java      |  8 --------
 .../org/apache/camel/processor/FilterNotTest.java  |  2 --
 .../org/apache/camel/processor/FilterTest.java     |  2 --
 .../endpoint/dsl/Sqs2EndpointBuilderFactory.java   |  2 ++
 .../modules/ROOT/pages/aws2-sqs-component.adoc     |  4 ++--
 15 files changed, 19 insertions(+), 48 deletions(-)

diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-sqs-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-sqs-component.adoc
index 6955a7d..4e5675c 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-sqs-component.adoc
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-sqs-component.adoc
@@ -67,7 +67,7 @@ The AWS 2 Simple Queue Service (SQS) component supports 43 options, which are li
 | *concurrentConsumers* (consumer) | Allows you to use multiple threads to poll the sqs queue to increase throughput | 1 | int
 | *defaultVisibilityTimeout* (consumer) | The default visibility timeout (in seconds) |  | Integer
 | *deleteAfterRead* (consumer) | Delete message from SQS after it has been read | true | boolean
-| *deleteIfFiltered* (consumer) | Whether or not to send the DeleteMessage to the SQS queue if an exchange fails to get through a filter. If 'false' and exchange does not make it through a Camel filter upstream in the route, then don't send DeleteMessage. | true | boolean
+| *deleteIfFiltered* (consumer) | *Deprecated* Whether or not to send the DeleteMessage to the SQS queue if an exchange fails to get through a filter. If 'false' and exchange does not make it through a Camel filter upstream in the route, then don't send DeleteMessage. | true | boolean
 | *extendMessageVisibility* (consumer) | If enabled then a scheduled background task will keep extending the message visibility on SQS. This is needed if it takes a long time to process the message. If set to true defaultVisibilityTimeout must be set. See details at Amazon docs. | false | boolean
 | *kmsDataKeyReusePeriodSeconds* (consumer) | The length of time, in seconds, for which Amazon SQS can reuse a data key to encrypt or decrypt messages before calling AWS KMS again. An integer representing seconds, between 60 seconds (1 minute) and 86,400 seconds (24 hours). Default: 300 (5 minutes). |  | Integer
 | *kmsMasterKeyId* (consumer) | The ID of an AWS-managed customer master key (CMK) for Amazon SQS or a custom CMK. |  | String
@@ -145,7 +145,7 @@ with the following path and query parameters:
 | *concurrentConsumers* (consumer) | Allows you to use multiple threads to poll the sqs queue to increase throughput | 1 | int
 | *defaultVisibilityTimeout* (consumer) | The default visibility timeout (in seconds) |  | Integer
 | *deleteAfterRead* (consumer) | Delete message from SQS after it has been read | true | boolean
-| *deleteIfFiltered* (consumer) | Whether or not to send the DeleteMessage to the SQS queue if an exchange fails to get through a filter. If 'false' and exchange does not make it through a Camel filter upstream in the route, then don't send DeleteMessage. | true | boolean
+| *deleteIfFiltered* (consumer) | *Deprecated* Whether or not to send the DeleteMessage to the SQS queue if an exchange fails to get through a filter. If 'false' and exchange does not make it through a Camel filter upstream in the route, then don't send DeleteMessage. | true | boolean
 | *extendMessageVisibility* (consumer) | If enabled then a scheduled background task will keep extending the message visibility on SQS. This is needed if it takes a long time to process the message. If set to true defaultVisibilityTimeout must be set. See details at Amazon docs. | false | boolean
 | *kmsDataKeyReusePeriodSeconds* (consumer) | The length of time, in seconds, for which Amazon SQS can reuse a data key to encrypt or decrypt messages before calling AWS KMS again. An integer representing seconds, between 60 seconds (1 minute) and 86,400 seconds (24 hours). Default: 300 (5 minutes). |  | Integer
 | *kmsMasterKeyId* (consumer) | The ID of an AWS-managed customer master key (CMK) for Amazon SQS or a custom CMK. |  | String
diff --git a/components/camel-aws/camel-aws2-sqs/src/generated/resources/org/apache/camel/component/aws2/sqs/aws2-sqs.json b/components/camel-aws/camel-aws2-sqs/src/generated/resources/org/apache/camel/component/aws2/sqs/aws2-sqs.json
index 426106a..e4e37be 100644
--- a/components/camel-aws/camel-aws2-sqs/src/generated/resources/org/apache/camel/component/aws2/sqs/aws2-sqs.json
+++ b/components/camel-aws/camel-aws2-sqs/src/generated/resources/org/apache/camel/component/aws2/sqs/aws2-sqs.json
@@ -39,7 +39,7 @@
     "concurrentConsumers": { "kind": "property", "displayName": "Concurrent Consumers", "group": "consumer", "label": "consumer", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 1, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Allows you to use multiple threads to poll the sqs queue to increase throughput" },
     "defaultVisibilityTimeout": { "kind": "property", "displayName": "Default Visibility Timeout", "group": "consumer", "label": "consumer", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "The default visibility timeout (in seconds)" },
     "deleteAfterRead": { "kind": "property", "displayName": "Delete After Read", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Delete message from SQS after it has been read" },
-    "deleteIfFiltered": { "kind": "property", "displayName": "Delete If Filtered", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Whether or not to send the DeleteMessage to the SQS queue if an exchange fails to get throug [...]
+    "deleteIfFiltered": { "kind": "property", "displayName": "Delete If Filtered", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": true, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Whether or not to send the DeleteMessage to the SQS queue if an exchange fails to get through [...]
     "extendMessageVisibility": { "kind": "property", "displayName": "Extend Message Visibility", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "If enabled then a scheduled background task will keep extending the message v [...]
     "kmsDataKeyReusePeriodSeconds": { "kind": "property", "displayName": "Kms Data Key Reuse Period Seconds", "group": "consumer", "label": "consumer", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "The length of time, in seconds, for which Amazon SQS can reuse a data key to  [...]
     "kmsMasterKeyId": { "kind": "property", "displayName": "Kms Master Key Id", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "The ID of an AWS-managed customer master key (CMK) for Amazon SQS or a custom CMK." },
@@ -85,7 +85,7 @@
     "concurrentConsumers": { "kind": "parameter", "displayName": "Concurrent Consumers", "group": "consumer", "label": "consumer", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 1, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Allows you to use multiple threads to poll the sqs queue to increase throughput" },
     "defaultVisibilityTimeout": { "kind": "parameter", "displayName": "Default Visibility Timeout", "group": "consumer", "label": "consumer", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "The default visibility timeout (in seconds)" },
     "deleteAfterRead": { "kind": "parameter", "displayName": "Delete After Read", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Delete message from SQS after it has been read" },
-    "deleteIfFiltered": { "kind": "parameter", "displayName": "Delete If Filtered", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Whether or not to send the DeleteMessage to the SQS queue if an exchange fails to get throu [...]
+    "deleteIfFiltered": { "kind": "parameter", "displayName": "Delete If Filtered", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": true, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "Whether or not to send the DeleteMessage to the SQS queue if an exchange fails to get throug [...]
     "extendMessageVisibility": { "kind": "parameter", "displayName": "Extend Message Visibility", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "If enabled then a scheduled background task will keep extending the message  [...]
     "kmsDataKeyReusePeriodSeconds": { "kind": "parameter", "displayName": "Kms Data Key Reuse Period Seconds", "group": "consumer", "label": "consumer", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "The length of time, in seconds, for which Amazon SQS can reuse a data key to [...]
     "kmsMasterKeyId": { "kind": "parameter", "displayName": "Kms Master Key Id", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.sqs.Sqs2Configuration", "configurationField": "configuration", "description": "The ID of an AWS-managed customer master key (CMK) for Amazon SQS or a custom CMK." },
diff --git a/components/camel-aws/camel-aws2-sqs/src/main/docs/aws2-sqs-component.adoc b/components/camel-aws/camel-aws2-sqs/src/main/docs/aws2-sqs-component.adoc
index 6955a7d..4e5675c 100644
--- a/components/camel-aws/camel-aws2-sqs/src/main/docs/aws2-sqs-component.adoc
+++ b/components/camel-aws/camel-aws2-sqs/src/main/docs/aws2-sqs-component.adoc
@@ -67,7 +67,7 @@ The AWS 2 Simple Queue Service (SQS) component supports 43 options, which are li
 | *concurrentConsumers* (consumer) | Allows you to use multiple threads to poll the sqs queue to increase throughput | 1 | int
 | *defaultVisibilityTimeout* (consumer) | The default visibility timeout (in seconds) |  | Integer
 | *deleteAfterRead* (consumer) | Delete message from SQS after it has been read | true | boolean
-| *deleteIfFiltered* (consumer) | Whether or not to send the DeleteMessage to the SQS queue if an exchange fails to get through a filter. If 'false' and exchange does not make it through a Camel filter upstream in the route, then don't send DeleteMessage. | true | boolean
+| *deleteIfFiltered* (consumer) | *Deprecated* Whether or not to send the DeleteMessage to the SQS queue if an exchange fails to get through a filter. If 'false' and exchange does not make it through a Camel filter upstream in the route, then don't send DeleteMessage. | true | boolean
 | *extendMessageVisibility* (consumer) | If enabled then a scheduled background task will keep extending the message visibility on SQS. This is needed if it takes a long time to process the message. If set to true defaultVisibilityTimeout must be set. See details at Amazon docs. | false | boolean
 | *kmsDataKeyReusePeriodSeconds* (consumer) | The length of time, in seconds, for which Amazon SQS can reuse a data key to encrypt or decrypt messages before calling AWS KMS again. An integer representing seconds, between 60 seconds (1 minute) and 86,400 seconds (24 hours). Default: 300 (5 minutes). |  | Integer
 | *kmsMasterKeyId* (consumer) | The ID of an AWS-managed customer master key (CMK) for Amazon SQS or a custom CMK. |  | String
@@ -145,7 +145,7 @@ with the following path and query parameters:
 | *concurrentConsumers* (consumer) | Allows you to use multiple threads to poll the sqs queue to increase throughput | 1 | int
 | *defaultVisibilityTimeout* (consumer) | The default visibility timeout (in seconds) |  | Integer
 | *deleteAfterRead* (consumer) | Delete message from SQS after it has been read | true | boolean
-| *deleteIfFiltered* (consumer) | Whether or not to send the DeleteMessage to the SQS queue if an exchange fails to get through a filter. If 'false' and exchange does not make it through a Camel filter upstream in the route, then don't send DeleteMessage. | true | boolean
+| *deleteIfFiltered* (consumer) | *Deprecated* Whether or not to send the DeleteMessage to the SQS queue if an exchange fails to get through a filter. If 'false' and exchange does not make it through a Camel filter upstream in the route, then don't send DeleteMessage. | true | boolean
 | *extendMessageVisibility* (consumer) | If enabled then a scheduled background task will keep extending the message visibility on SQS. This is needed if it takes a long time to process the message. If set to true defaultVisibilityTimeout must be set. See details at Amazon docs. | false | boolean
 | *kmsDataKeyReusePeriodSeconds* (consumer) | The length of time, in seconds, for which Amazon SQS can reuse a data key to encrypt or decrypt messages before calling AWS KMS again. An integer representing seconds, between 60 seconds (1 minute) and 86,400 seconds (24 hours). Default: 300 (5 minutes). |  | Integer
 | *kmsMasterKeyId* (consumer) | The ID of an AWS-managed customer master key (CMK) for Amazon SQS or a custom CMK. |  | String
diff --git a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Configuration.java b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Configuration.java
index df7d02d..3ba8bb1 100644
--- a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Configuration.java
+++ b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Configuration.java
@@ -60,6 +60,7 @@ public class Sqs2Configuration implements Cloneable {
     @UriParam(label = "consumer", defaultValue = "true")
     private boolean deleteAfterRead = true;
     @UriParam(label = "consumer", defaultValue = "true")
+    @Deprecated
     private boolean deleteIfFiltered = true;
     @UriParam(label = "consumer")
     private Integer visibilityTimeout;
diff --git a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Consumer.java b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Consumer.java
index 9e9d2f2..9d06355 100644
--- a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Consumer.java
+++ b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Consumer.java
@@ -250,14 +250,14 @@ public class Sqs2Consumer extends ScheduledBatchPollingConsumer {
     }
 
     private boolean shouldDelete(Exchange exchange) {
-        boolean shouldDeleteByFilter = exchange.getProperty(ExchangePropertyKey.FILTER_MATCHED) != null
+        boolean shouldDeleteByFilter = exchange.getProperty(Exchange.FILTER_MATCHED) != null
                 && getConfiguration().isDeleteIfFiltered() && passedThroughFilter(exchange);
 
         return getConfiguration().isDeleteAfterRead() || shouldDeleteByFilter;
     }
 
     private boolean passedThroughFilter(Exchange exchange) {
-        return exchange.getProperty(ExchangePropertyKey.FILTER_MATCHED, false, Boolean.class);
+        return exchange.getProperty(Exchange.FILTER_MATCHED, false, Boolean.class);
     }
 
     /**
diff --git a/core/camel-api/src/main/java/org/apache/camel/Exchange.java b/core/camel-api/src/main/java/org/apache/camel/Exchange.java
index 0c20528..a8bcd31 100644
--- a/core/camel-api/src/main/java/org/apache/camel/Exchange.java
+++ b/core/camel-api/src/main/java/org/apache/camel/Exchange.java
@@ -136,6 +136,7 @@ public interface Exchange {
     String FILE_LOCK_EXCLUSIVE_LOCK = "CamelFileLockExclusiveLock";
     String FILE_LOCK_RANDOM_ACCESS_FILE = "CamelFileLockRandomAccessFile";
     String FILE_LOCK_CHANNEL_FILE = "CamelFileLockChannelFile";
+    @Deprecated
     String FILTER_MATCHED = "CamelFilterMatched";
     String FILTER_NON_XML_CHARS = "CamelFilterNonXmlChars";
 
diff --git a/core/camel-api/src/main/java/org/apache/camel/ExchangePropertyKey.java b/core/camel-api/src/main/java/org/apache/camel/ExchangePropertyKey.java
index af2ae97..5bac8ad 100644
--- a/core/camel-api/src/main/java/org/apache/camel/ExchangePropertyKey.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ExchangePropertyKey.java
@@ -43,7 +43,6 @@ public enum ExchangePropertyKey {
     FAILURE_HANDLED(Exchange.FAILURE_HANDLED),
     FAILURE_ROUTE_ID(Exchange.FAILURE_ROUTE_ID),
     FATAL_FALLBACK_ERROR_HANDLER(Exchange.FATAL_FALLBACK_ERROR_HANDLER),
-    FILTER_MATCHED(Exchange.FILTER_MATCHED),
     GROUPED_EXCHANGE(Exchange.GROUPED_EXCHANGE),
     INTERCEPT_SEND_TO_ENDPOINT_WHEN_MATCHED(Exchange.INTERCEPT_SEND_TO_ENDPOINT_WHEN_MATCHED),
     LOOP_INDEX(Exchange.LOOP_INDEX),
@@ -123,8 +122,6 @@ public enum ExchangePropertyKey {
                 return FAILURE_ROUTE_ID;
             case Exchange.FATAL_FALLBACK_ERROR_HANDLER:
                 return FATAL_FALLBACK_ERROR_HANDLER;
-            case Exchange.FILTER_MATCHED:
-                return FILTER_MATCHED;
             case Exchange.GROUPED_EXCHANGE:
                 return GROUPED_EXCHANGE;
             case Exchange.INTERCEPT_SEND_TO_ENDPOINT_WHEN_MATCHED:
diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2SqsComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2SqsComponentBuilderFactory.java
index ea05f87..d4b219b 100644
--- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2SqsComponentBuilderFactory.java
+++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2SqsComponentBuilderFactory.java
@@ -344,6 +344,7 @@ public interface Aws2SqsComponentBuilderFactory {
          * @param deleteIfFiltered the value to set
          * @return the dsl builder
          */
+        @Deprecated
         default Aws2SqsComponentBuilder deleteIfFiltered(
                 boolean deleteIfFiltered) {
             doSetProperty("deleteIfFiltered", deleteIfFiltered);
diff --git a/core/camel-core-processor/src/main/java/org/apache/camel/processor/ChoiceProcessor.java b/core/camel-core-processor/src/main/java/org/apache/camel/processor/ChoiceProcessor.java
index 6fce791..be781ec 100644
--- a/core/camel-core-processor/src/main/java/org/apache/camel/processor/ChoiceProcessor.java
+++ b/core/camel-core-processor/src/main/java/org/apache/camel/processor/ChoiceProcessor.java
@@ -23,7 +23,6 @@ import java.util.List;
 import org.apache.camel.AsyncCallback;
 import org.apache.camel.AsyncProcessor;
 import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePropertyKey;
 import org.apache.camel.Navigate;
 import org.apache.camel.Processor;
 import org.apache.camel.Traceable;
@@ -61,20 +60,6 @@ public class ChoiceProcessor extends AsyncProcessorSupport implements Navigate<P
 
     @Override
     public boolean process(final Exchange exchange, final AsyncCallback callback) {
-        // callback to restore existing FILTER_MATCHED property on the Exchange
-        final Object existing = exchange.getProperty(ExchangePropertyKey.FILTER_MATCHED);
-        final AsyncCallback choiceCallback = new AsyncCallback() {
-            @Override
-            public void done(boolean doneSync) {
-                if (existing != null) {
-                    exchange.setProperty(ExchangePropertyKey.FILTER_MATCHED, existing);
-                } else {
-                    exchange.removeProperty(ExchangePropertyKey.FILTER_MATCHED);
-                }
-                callback.done(doneSync);
-            }
-        };
-
         // find the first matching filter and process the exchange using it
         for (int i = 0; i < len; i++) {
             FilterProcessor filter = filters[i];
@@ -91,7 +76,7 @@ public class ChoiceProcessor extends AsyncProcessorSupport implements Navigate<P
             // check for error if so we should break out
             if (!continueProcessing(exchange, "so breaking out of choice", LOG)) {
                 // okay there was an error in the predicate so we should exit
-                choiceCallback.done(true);
+                callback.done(true);
                 return true;
             }
 
@@ -101,16 +86,16 @@ public class ChoiceProcessor extends AsyncProcessorSupport implements Navigate<P
             }
 
             // okay we found a filter then process it directly via its processor as we have already done the matching
-            return filter.getProcessor().process(exchange, choiceCallback);
+            return filter.getProcessor().process(exchange, callback);
         }
 
         if (otherwise != null) {
             // no filter matched then use otherwise
             notFiltered++;
-            return otherwise.process(exchange, choiceCallback);
+            return otherwise.process(exchange, callback);
         } else {
             // when no filter matches and there is no otherwise, then just continue
-            choiceCallback.done(true);
+            callback.done(true);
             return true;
         }
     }
diff --git a/core/camel-core-processor/src/main/java/org/apache/camel/processor/FilterProcessor.java b/core/camel-core-processor/src/main/java/org/apache/camel/processor/FilterProcessor.java
index 71b6466..ae41e5b 100644
--- a/core/camel-core-processor/src/main/java/org/apache/camel/processor/FilterProcessor.java
+++ b/core/camel-core-processor/src/main/java/org/apache/camel/processor/FilterProcessor.java
@@ -19,7 +19,6 @@ package org.apache.camel.processor;
 import org.apache.camel.AsyncCallback;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePropertyKey;
 import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
 import org.apache.camel.Traceable;
@@ -79,9 +78,6 @@ public class FilterProcessor extends DelegateAsyncProcessor implements Traceable
 
         LOG.debug("Filter matches: {} for exchange: {}", matches, exchange);
 
-        // set property whether the filter matches or not
-        exchange.setProperty(ExchangePropertyKey.FILTER_MATCHED, matches);
-
         if (matches) {
             filtered++;
         }
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/FilterNotMatchedTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/FilterNotMatchedTest.java
index f24d07a..f473e56 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/FilterNotMatchedTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/FilterNotMatchedTest.java
@@ -17,7 +17,6 @@
 package org.apache.camel.processor;
 
 import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.jupiter.api.Test;
@@ -28,10 +27,6 @@ public class FilterNotMatchedTest extends ContextTestSupport {
     public void testSendMatchingMessage() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
-        mock.message(0).exchangeProperty(Exchange.FILTER_MATCHED).isEqualTo(true);
-
-        getMockEndpoint("mock:end").message(0).exchangeProperty(Exchange.FILTER_MATCHED).isNotNull();
-        getMockEndpoint("mock:end").message(0).exchangeProperty(Exchange.FILTER_MATCHED).isEqualTo(true);
 
         template.sendBodyAndHeader("direct:start", "<matched/>", "foo", "bar");
 
@@ -43,9 +38,6 @@ public class FilterNotMatchedTest extends ContextTestSupport {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(0);
 
-        getMockEndpoint("mock:end").message(0).exchangeProperty(Exchange.FILTER_MATCHED).isNotNull();
-        getMockEndpoint("mock:end").message(0).exchangeProperty(Exchange.FILTER_MATCHED).isEqualTo(false);
-
         template.sendBodyAndHeader("direct:start", "<notMatched/>", "foo", "notMatchedHeaderValue");
 
         assertMockEndpointsSatisfied();
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/FilterNotTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/FilterNotTest.java
index 7b81792..954ffe4 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/FilterNotTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/FilterNotTest.java
@@ -17,7 +17,6 @@
 package org.apache.camel.processor;
 
 import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.jupiter.api.Test;
@@ -40,7 +39,6 @@ public class FilterNotTest extends ContextTestSupport {
     public void testSendNotMatchingMessage() throws Exception {
         MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
         resultEndpoint.expectedMessageCount(1);
-        resultEndpoint.message(0).exchangeProperty(Exchange.FILTER_MATCHED).isEqualTo(true);
 
         template.sendBody("direct:start", "<notMatched/>");
 
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/FilterTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/FilterTest.java
index c0cc004..b579da9 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/FilterTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/FilterTest.java
@@ -17,7 +17,6 @@
 package org.apache.camel.processor;
 
 import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.jupiter.api.Test;
@@ -30,7 +29,6 @@ public class FilterTest extends ContextTestSupport {
     public void testSendMatchingMessage() throws Exception {
         MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
         resultEndpoint.expectedMessageCount(1);
-        resultEndpoint.message(0).exchangeProperty(Exchange.FILTER_MATCHED).isEqualTo(true);
 
         template.sendBodyAndHeader("direct:start", "<matched/>", "foo", "bar");
 
diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Sqs2EndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Sqs2EndpointBuilderFactory.java
index 1f200ad..7c8b0d7 100644
--- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Sqs2EndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Sqs2EndpointBuilderFactory.java
@@ -536,6 +536,7 @@ public interface Sqs2EndpointBuilderFactory {
          * @param deleteIfFiltered the value to set
          * @return the dsl builder
          */
+        @Deprecated
         default Sqs2EndpointConsumerBuilder deleteIfFiltered(
                 boolean deleteIfFiltered) {
             doSetProperty("deleteIfFiltered", deleteIfFiltered);
@@ -556,6 +557,7 @@ public interface Sqs2EndpointBuilderFactory {
          * @param deleteIfFiltered the value to set
          * @return the dsl builder
          */
+        @Deprecated
         default Sqs2EndpointConsumerBuilder deleteIfFiltered(
                 String deleteIfFiltered) {
             doSetProperty("deleteIfFiltered", deleteIfFiltered);
diff --git a/docs/components/modules/ROOT/pages/aws2-sqs-component.adoc b/docs/components/modules/ROOT/pages/aws2-sqs-component.adoc
index 84706a4..5b50203 100644
--- a/docs/components/modules/ROOT/pages/aws2-sqs-component.adoc
+++ b/docs/components/modules/ROOT/pages/aws2-sqs-component.adoc
@@ -69,7 +69,7 @@ The AWS 2 Simple Queue Service (SQS) component supports 43 options, which are li
 | *concurrentConsumers* (consumer) | Allows you to use multiple threads to poll the sqs queue to increase throughput | 1 | int
 | *defaultVisibilityTimeout* (consumer) | The default visibility timeout (in seconds) |  | Integer
 | *deleteAfterRead* (consumer) | Delete message from SQS after it has been read | true | boolean
-| *deleteIfFiltered* (consumer) | Whether or not to send the DeleteMessage to the SQS queue if an exchange fails to get through a filter. If 'false' and exchange does not make it through a Camel filter upstream in the route, then don't send DeleteMessage. | true | boolean
+| *deleteIfFiltered* (consumer) | *Deprecated* Whether or not to send the DeleteMessage to the SQS queue if an exchange fails to get through a filter. If 'false' and exchange does not make it through a Camel filter upstream in the route, then don't send DeleteMessage. | true | boolean
 | *extendMessageVisibility* (consumer) | If enabled then a scheduled background task will keep extending the message visibility on SQS. This is needed if it takes a long time to process the message. If set to true defaultVisibilityTimeout must be set. See details at Amazon docs. | false | boolean
 | *kmsDataKeyReusePeriodSeconds* (consumer) | The length of time, in seconds, for which Amazon SQS can reuse a data key to encrypt or decrypt messages before calling AWS KMS again. An integer representing seconds, between 60 seconds (1 minute) and 86,400 seconds (24 hours). Default: 300 (5 minutes). |  | Integer
 | *kmsMasterKeyId* (consumer) | The ID of an AWS-managed customer master key (CMK) for Amazon SQS or a custom CMK. |  | String
@@ -147,7 +147,7 @@ with the following path and query parameters:
 | *concurrentConsumers* (consumer) | Allows you to use multiple threads to poll the sqs queue to increase throughput | 1 | int
 | *defaultVisibilityTimeout* (consumer) | The default visibility timeout (in seconds) |  | Integer
 | *deleteAfterRead* (consumer) | Delete message from SQS after it has been read | true | boolean
-| *deleteIfFiltered* (consumer) | Whether or not to send the DeleteMessage to the SQS queue if an exchange fails to get through a filter. If 'false' and exchange does not make it through a Camel filter upstream in the route, then don't send DeleteMessage. | true | boolean
+| *deleteIfFiltered* (consumer) | *Deprecated* Whether or not to send the DeleteMessage to the SQS queue if an exchange fails to get through a filter. If 'false' and exchange does not make it through a Camel filter upstream in the route, then don't send DeleteMessage. | true | boolean
 | *extendMessageVisibility* (consumer) | If enabled then a scheduled background task will keep extending the message visibility on SQS. This is needed if it takes a long time to process the message. If set to true defaultVisibilityTimeout must be set. See details at Amazon docs. | false | boolean
 | *kmsDataKeyReusePeriodSeconds* (consumer) | The length of time, in seconds, for which Amazon SQS can reuse a data key to encrypt or decrypt messages before calling AWS KMS again. An integer representing seconds, between 60 seconds (1 minute) and 86,400 seconds (24 hours). Default: 300 (5 minutes). |  | Integer
 | *kmsMasterKeyId* (consumer) | The ID of an AWS-managed customer master key (CMK) for Amazon SQS or a custom CMK. |  | String


[camel] 03/04: camel-core - Optimize exchange properties to create on-demand as camel-core uses only internal properties to store state.

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 4cf3569a1d044f107c867944517d171bdd1a402b
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Mar 14 18:30:07 2021 +0100

    camel-core - Optimize exchange properties to create on-demand as camel-core uses only internal properties to store state.
---
 .../org/apache/camel/support/AbstractExchange.java | 65 +++++++++++++---------
 .../camel/support/DefaultPooledExchange.java       |  7 +++
 2 files changed, 46 insertions(+), 26 deletions(-)

diff --git a/core/camel-support/src/main/java/org/apache/camel/support/AbstractExchange.java b/core/camel-support/src/main/java/org/apache/camel/support/AbstractExchange.java
index 714a01b..37282a6 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/AbstractExchange.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/AbstractExchange.java
@@ -58,8 +58,7 @@ class AbstractExchange implements ExtendedExchange {
     static final Object[] EMPTY_INTERNAL_PROPERTIES = new Object[INTERNAL_LENGTH];
 
     final CamelContext context;
-    // optimize to create properties always and with a reasonable small size
-    final Map<String, Object> properties = new ConcurrentHashMap<>(8);
+    Map<String, Object> properties; // create properties on-demand as we use internal properties mostly
     // optimize for internal exchange properties (not intended for end users)
     final Object[] internalProperties = new Object[INTERNAL_LENGTH];
     long created;
@@ -265,7 +264,7 @@ class AbstractExchange implements ExtendedExchange {
             answer = internalProperties[key.ordinal()];
             // if the property is not an internal then fallback to lookup in the properties map
         }
-        if (answer == null) {
+        if (answer == null && properties != null) {
             answer = properties.get(name);
         }
         return answer;
@@ -329,8 +328,11 @@ class AbstractExchange implements ExtendedExchange {
             setProperty(key, value);
         } else if (value != null) {
             // avoid the NullPointException
+            if (properties == null) {
+                this.properties = new ConcurrentHashMap<>(8);
+            }
             properties.put(name, value);
-        } else {
+        } else if (properties != null) {
             // if the value is null, we just remove the key from the map
             properties.remove(name);
         }
@@ -338,7 +340,11 @@ class AbstractExchange implements ExtendedExchange {
 
     @Override
     public void setProperties(Map<String, Object> properties) {
-        this.properties.clear();
+        if (this.properties == null) {
+            this.properties = new ConcurrentHashMap<>(8);
+        } else {
+            this.properties.clear();
+        }
         this.properties.putAll(properties);
     }
 
@@ -363,7 +369,9 @@ class AbstractExchange implements ExtendedExchange {
     public boolean removeProperties(String pattern, String... excludePatterns) {
         // special optimized
         if (excludePatterns == null && "*".equals(pattern)) {
-            properties.clear();
+            if (properties != null) {
+                properties.clear();
+            }
             // reset array by copying over from empty which is a very fast JVM optimized operation
             System.arraycopy(EMPTY_INTERNAL_PROPERTIES, 0, this.internalProperties, 0, INTERNAL_LENGTH);
             return true;
@@ -382,27 +390,29 @@ class AbstractExchange implements ExtendedExchange {
         }
 
         // store keys to be removed as we cannot loop and remove at the same time in implementations such as HashMap
-        Set<String> toBeRemoved = null;
-        for (String key : properties.keySet()) {
-            if (PatternHelper.matchPattern(key, pattern)) {
-                if (excludePatterns != null && PatternHelper.isExcludePatternMatch(key, excludePatterns)) {
-                    continue;
-                }
-                matches = true;
-                if (toBeRemoved == null) {
-                    toBeRemoved = new HashSet<>();
+        if (properties != null) {
+            Set<String> toBeRemoved = null;
+            for (String key : properties.keySet()) {
+                if (PatternHelper.matchPattern(key, pattern)) {
+                    if (excludePatterns != null && PatternHelper.isExcludePatternMatch(key, excludePatterns)) {
+                        continue;
+                    }
+                    matches = true;
+                    if (toBeRemoved == null) {
+                        toBeRemoved = new HashSet<>();
+                    }
+                    toBeRemoved.add(key);
                 }
-                toBeRemoved.add(key);
             }
-        }
 
-        if (matches && toBeRemoved != null) {
-            if (toBeRemoved.size() == properties.size()) {
-                // special optimization when all should be removed
-                properties.clear();
-            } else {
-                for (String key : toBeRemoved) {
-                    properties.remove(key);
+            if (matches && toBeRemoved != null) {
+                if (toBeRemoved.size() == properties.size()) {
+                    // special optimization when all should be removed
+                    properties.clear();
+                } else {
+                    for (String key : toBeRemoved) {
+                        properties.remove(key);
+                    }
                 }
             }
         }
@@ -412,6 +422,9 @@ class AbstractExchange implements ExtendedExchange {
 
     @Override
     public Map<String, Object> getProperties() {
+        if (properties == null) {
+            this.properties = new ConcurrentHashMap<>(8);
+        }
         return properties;
     }
 
@@ -419,7 +432,7 @@ class AbstractExchange implements ExtendedExchange {
     public Map<String, Object> getAllProperties() {
         // include also internal properties (creates a new map)
         Map<String, Object> map = getInternalProperties();
-        if (!properties.isEmpty()) {
+        if (properties != null && !properties.isEmpty()) {
             map.putAll(properties);
         }
         return map;
@@ -427,7 +440,7 @@ class AbstractExchange implements ExtendedExchange {
 
     @Override
     public boolean hasProperties() {
-        return !properties.isEmpty();
+        return properties != null && !properties.isEmpty();
     }
 
     @Override
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/DefaultPooledExchange.java b/core/camel-support/src/main/java/org/apache/camel/support/DefaultPooledExchange.java
index 0ffd66b4..43bdf31 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/DefaultPooledExchange.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/DefaultPooledExchange.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.support;
 
+import java.util.concurrent.ConcurrentHashMap;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
@@ -37,26 +39,31 @@ public final class DefaultPooledExchange extends AbstractExchange implements Poo
     public DefaultPooledExchange(CamelContext context) {
         super(context);
         this.originalPattern = getPattern();
+        this.properties = new ConcurrentHashMap<>(8);
     }
 
     public DefaultPooledExchange(CamelContext context, ExchangePattern pattern) {
         super(context, pattern);
         this.originalPattern = pattern;
+        this.properties = new ConcurrentHashMap<>(8);
     }
 
     public DefaultPooledExchange(Exchange parent) {
         super(parent);
         this.originalPattern = parent.getPattern();
+        this.properties = new ConcurrentHashMap<>(8);
     }
 
     public DefaultPooledExchange(Endpoint fromEndpoint) {
         super(fromEndpoint);
         this.originalPattern = getPattern();
+        this.properties = new ConcurrentHashMap<>(8);
     }
 
     public DefaultPooledExchange(Endpoint fromEndpoint, ExchangePattern pattern) {
         super(fromEndpoint, pattern);
         this.originalPattern = pattern;
+        this.properties = new ConcurrentHashMap<>(8);
     }
 
     public boolean isAutoRelease() {


[camel] 04/04: CAMEL-16355: camel-core - Optimize Filter and Choice EIP

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 bfc78dc12ec88dae491096cd6cea55ff63ec2d91
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Mar 14 19:10:13 2021 +0100

    CAMEL-16355: camel-core - Optimize Filter and Choice EIP
---
 docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_9.adoc | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_9.adoc b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_9.adoc
index 2d5e48e..55658be 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_9.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_9.adoc
@@ -45,6 +45,11 @@ These keys are used in camel-core such as the routing engine, EIPs and others th
 state on the `Exchange` which is done as exchange properties. Because Camel end users can also store
 exchange properties then before they would get mixed together. What we have done now is to separate them.
 
+=== Choice and Filter EIP
+
+The `choice` and `filter` EIPs no longer store exchange property `Exchange.FILTER_MATCHED`.
+The reason is the information is seldom in use, and by removing we were able to optimize camel-core.
+
 === Modularized camel-spring
 
 The `camel-spring` component has been modularized into: