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 2024/12/26 13:16:11 UTC

(camel) branch inline created (now 19c58323f39)

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

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


      at 19c58323f39 CAMEL-21495: rest-dsl - Mark route as inlined by rest-dsl to avoid duplicate that cause side-effects.

This branch includes the following new commits:

     new 19c58323f39 CAMEL-21495: rest-dsl - Mark route as inlined by rest-dsl to avoid duplicate that cause side-effects.

The 1 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.



(camel) 01/01: CAMEL-21495: rest-dsl - Mark route as inlined by rest-dsl to avoid duplicate that cause side-effects.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 19c58323f39e0ece14e3e743602b6fd16bd2c01a
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Dec 26 14:08:41 2024 +0100

    CAMEL-21495: rest-dsl - Mark route as inlined by rest-dsl to avoid duplicate that cause side-effects.
---
 .../main/java/org/apache/camel/impl/DefaultModel.java   |  4 +++-
 .../java/org/apache/camel/model/RouteDefinition.java    | 17 +++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultModel.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultModel.java
index fdb09b8e1cf..03db1eb3f9a 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultModel.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultModel.java
@@ -205,7 +205,8 @@ public class DefaultModel implements Model {
             for (RouteDefinition r : allRoutes) {
                 // loop all rest routes
                 FromDefinition from = r.getInput();
-                if (from != null) {
+                if (from != null && !r.isInlined()) {
+                    // only attempt to inline if not already inlined
                     String uri = from.getEndpointUri();
                     if (uri != null && uri.startsWith("rest:")) {
                         // find first EIP in the outputs (skip abstract which are onException/intercept etc)
@@ -267,6 +268,7 @@ public class DefaultModel implements Model {
                                 if (toBeInlined.isErrorHandlerFactorySet()) {
                                     r.setErrorHandler(toBeInlined.getErrorHandler());
                                 }
+                                r.markInlined();
                             }
                         }
                     }
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/RouteDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/RouteDefinition.java
index fd684283697..a388b1ba90b 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/RouteDefinition.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/RouteDefinition.java
@@ -62,6 +62,7 @@ import org.apache.camel.spi.RoutePolicy;
 public class RouteDefinition extends OutputDefinition<RouteDefinition>
         implements NamedRoute, PreconditionContainer, ResourceAware {
     private final AtomicBoolean prepared = new AtomicBoolean();
+    private final AtomicBoolean inlined = new AtomicBoolean();
     private FromDefinition input;
     private String routeConfigurationId;
     private transient Set<String> appliedRouteConfigurationIds;
@@ -147,6 +148,22 @@ public class RouteDefinition extends OutputDefinition<RouteDefinition>
         prepared.set(false);
     }
 
+    /**
+     * Check if the route has been inlined by rest-dsl
+     *
+     * @return whether the route has been inlined by rest-dsl or not
+     */
+    public boolean isInlined() {
+        return inlined.get();
+    }
+
+    /**
+     * Marks the route definition as inlined by rest-dsl
+     */
+    public void markInlined() {
+        inlined.set(true);
+    }
+
     /**
      * Reset internal state before preparing route
      */