diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/FromDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/FromDefinition.java index fe08df54a36fd..63a6f9230f291 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/FromDefinition.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/FromDefinition.java @@ -61,6 +61,22 @@ public FromDefinition(EndpointConsumerBuilder endpointConsumerBuilder) { setEndpointConsumerBuilder(endpointConsumerBuilder); } + FromDefinition copy() { + FromDefinition copy = new FromDefinition(); + copy.parent = this.parent; + copy.endpoint = this.endpoint; + copy.endpointConsumerBuilder = this.endpointConsumerBuilder; + copy.uri = this.uri; + copy.variableReceive = this.variableReceive; + copy.setCamelContext(this.getCamelContext()); + copy.setId(this.getId()); + copy.setCustomId(this.getCustomId()); + copy.setDescription(this.getDescription()); + copy.setLineNumber(this.getLineNumber()); + copy.setLocation(this.getLocation()); + return copy; + } + @Override public String toString() { return "From[" + getLabel() + "]"; diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/RouteTemplateDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/RouteTemplateDefinition.java index 7434e13177df5..0d92463d802ab 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/RouteTemplateDefinition.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/RouteTemplateDefinition.java @@ -409,7 +409,8 @@ public RouteDefinition asRouteDefinition() { copy.setDelayer(route.getDelayer()); copy.setGroup(route.getGroup()); copy.setInheritErrorHandler(route.isInheritErrorHandler()); - copy.setInput(route.getInput()); + // make a defensive copy of the input as input can be adviced during testing or other changes + copy.setInput(route.getInput().copy()); copy.setInputType(route.getInputType()); copy.setLogMask(route.getLogMask()); copy.setMessageHistory(route.getMessageHistory());