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 2026/07/15 14:56:15 UTC
(camel) 01/01: CAMEL-24078: camel-jms/camel-amqp - Fix medium findings from code review
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch fix/CAMEL-24078
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 087d3c0ff4935a101f79d102e3f5c0174131729c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Jul 15 16:55:56 2026 +0200
CAMEL-24078: camel-jms/camel-amqp - Fix medium findings from code review
- M3: endpoint-level includeAllJMSXProperties=true was silently ignored because the
header filter strategy was set before URI options were applied. Reset cached strategy
when includeAllJMSXProperties changes.
- M4: component-level messageListenerContainerFactory was silently ignored because
consumerType was not set to Custom. Align with endpoint-level setter behavior.
- M6: asyncStartListener=true defeated autoStartup=false due to a race on the
initialized flag. Move flag assignment into prepareAndStartListenerContainer().
- M9: setting username/password on AMQP component clobbered an explicitly configured
connectionFactory. Guard factory creation with a null check.
Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
Signed-off-by: Claus Ibsen <cl...@gmail.com>
---
.../main/java/org/apache/camel/component/amqp/AMQPComponent.java | 5 +++--
.../src/main/java/org/apache/camel/component/jms/JmsComponent.java | 1 +
.../src/main/java/org/apache/camel/component/jms/JmsConsumer.java | 6 +++---
.../src/main/java/org/apache/camel/component/jms/JmsEndpoint.java | 5 +++++
4 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPComponent.java b/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPComponent.java
index fff7f6204dd2..b5c22d04bba7 100644
--- a/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPComponent.java
+++ b/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/AMQPComponent.java
@@ -110,8 +110,9 @@ public class AMQPComponent extends JmsComponent {
connectionFactory.setTopicPrefix("topic://");
}
getConfiguration().setConnectionFactory(connectionFactory);
- } else if (host != null || port != null || getUsername() != null || getPassword() != null || useTopicPrefix != null
- || useSsl != null) {
+ } else if (getConfiguration().getConnectionFactory() == null
+ && (host != null || port != null || getUsername() != null || getPassword() != null || useTopicPrefix != null
+ || useSsl != null)) {
StringBuilder sb = new StringBuilder();
sb.append(useSsl == Boolean.TRUE ? "amqps://" : "amqp://");
sb.append(host == null ? AMQP_DEFAULT_HOST : host).append(":").append(port == null ? AMQP_DEFAULT_PORT : port);
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
index 397a282cef7c..e2447cc1dee9 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
@@ -998,6 +998,7 @@ public class JmsComponent extends HeaderFilterStrategyComponent {
public void setMessageListenerContainerFactory(MessageListenerContainerFactory messageListenerContainerFactory) {
configuration.setMessageListenerContainerFactory(messageListenerContainerFactory);
+ configuration.setConsumerType(ConsumerType.Custom);
}
public boolean isIncludeSentJMSMessageID() {
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java
index e906bb71f6e0..7be15c1e46d2 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConsumer.java
@@ -171,9 +171,6 @@ public class JmsConsumer extends DefaultConsumer implements Suspendable {
} else {
prepareAndStartListenerContainer();
}
-
- // mark as initialized for the first time
- initialized = true;
}
protected void prepareAndStartListenerContainer() {
@@ -187,6 +184,9 @@ public class JmsConsumer extends DefaultConsumer implements Suspendable {
}
startListenerContainer();
}
+
+ // mark as initialized after the auto-startup check
+ initialized = true;
}
protected void stopAndDestroyListenerContainer() {
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
index de8eecab077f..8c18b428ee57 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
@@ -1216,6 +1216,11 @@ public class JmsEndpoint extends DefaultEndpoint
@ManagedAttribute
public void setIncludeAllJMSXProperties(boolean includeAllJMSXProperties) {
configuration.setIncludeAllJMSXProperties(includeAllJMSXProperties);
+ // Reset the default header filter strategy so it gets re-created
+ // with the updated includeAllJMSXProperties value
+ if (this.headerFilterStrategy instanceof JmsHeaderFilterStrategy) {
+ this.headerFilterStrategy = null;
+ }
}
@ManagedAttribute