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 2025/01/15 15:43:29 UTC
(camel) 03/10: CAMEL-21620: camel-core - Fix onWhen to not include outputs in model
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch when
in repository https://gitbox.apache.org/repos/asf/camel.git
commit a9d2c7801943cdbe2c9096cd449037da2ae447ff
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jan 15 14:16:59 2025 +0100
CAMEL-21620: camel-core - Fix onWhen to not include outputs in model
---
.../apache/camel/reifier/InterceptFromReifier.java | 30 ++++++++--------------
1 file changed, 11 insertions(+), 19 deletions(-)
diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/InterceptFromReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/InterceptFromReifier.java
index db979549fda..5ed803f7de9 100644
--- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/InterceptFromReifier.java
+++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/InterceptFromReifier.java
@@ -16,8 +16,6 @@
*/
package org.apache.camel.reifier;
-import org.apache.camel.AsyncCallback;
-import org.apache.camel.Exchange;
import org.apache.camel.ExchangePropertyKey;
import org.apache.camel.Predicate;
import org.apache.camel.Processor;
@@ -25,7 +23,7 @@ import org.apache.camel.Route;
import org.apache.camel.model.InterceptFromDefinition;
import org.apache.camel.model.ProcessorDefinition;
import org.apache.camel.processor.FilterProcessor;
-import org.apache.camel.support.processor.DelegateAsyncProcessor;
+import org.apache.camel.processor.Pipeline;
public class InterceptFromReifier extends InterceptReifier<InterceptFromDefinition> {
@@ -37,25 +35,19 @@ public class InterceptFromReifier extends InterceptReifier<InterceptFromDefiniti
public Processor createProcessor() throws Exception {
Processor child = this.createChildProcessor(true);
- // TODO: Pipeline with set property and true filter if onWhen is empty
- child = new DelegateAsyncProcessor(child) {
- @Override
- public boolean process(Exchange exchange, AsyncCallback callback) {
- if (exchange.getFromEndpoint() != null) {
- exchange.setProperty(ExchangePropertyKey.INTERCEPTED_ENDPOINT, exchange.getFromEndpoint().getEndpointUri());
- }
- return super.process(exchange, callback);
- }
- };
-
- Predicate when = null;
+ Predicate when;
if (definition.getOnWhen() != null) {
when = createPredicate(definition.getOnWhen().getExpression());
+ } else {
+ when = e -> true;
}
- if (when != null) {
- child = new FilterProcessor(getCamelContext(), when, child);
- }
- return child;
+ // set property before processing the child
+ Processor p = exchange -> {
+ if (exchange.getFromEndpoint() != null) {
+ exchange.setProperty(ExchangePropertyKey.INTERCEPTED_ENDPOINT, exchange.getFromEndpoint().getEndpointUri());
+ }
+ };
+ return new FilterProcessor(getCamelContext(), when, Pipeline.newInstance(getCamelContext(), p, child));
}
}