This is an automated email from the ASF dual-hosted git repository. christophd pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 2059cf2a25437bcb0e9980d870d568d7af4a1e4c Author: Christoph Deppisch <[email protected]> AuthorDate: Thu Oct 15 11:15:43 2026 +0200 CAMEL-25378: Remove dead name field and guard supplier against NPE - Remove shadowing `name` field from CitrusEndpoint — MockEndpoint already declares @UriPath name, and the inherited getName()/setName() handle the runtime value. The local field was never written to. - Extract createTestContext() method with null guard to prevent NPE if the supplier is invoked after doStop() nulls citrusContext. Co-Authored-By: Claude Opus 4.6 <[email protected]> --- .../org/apache/camel/catalog/components/citrus.json | 2 +- .../component/citrus/CitrusEndpointUriFactory.java | 2 +- .../org/apache/camel/component/citrus/citrus.json | 2 +- .../apache/camel/component/citrus/CitrusEndpoint.java | 18 +++++++++++------- .../camel/builder/endpoint/StaticEndpointBuilders.java | 10 ++++------ .../endpoint/dsl/CitrusEndpointBuilderFactory.java | 10 ++++------ 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/citrus.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/citrus.json index 058471240c86..76941d15c7f3 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/citrus.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/citrus.json @@ -31,7 +31,7 @@ }, "properties": { "operation": { "index": 0, "kind": "path", "displayName": "Operation", "group": "producer", "label": "", "required": true, "type": "enum", "javaType": "java.lang.String", "enum": [ "validate", "receive" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation to perform. 'validate' validates exchanges without modifying them. 'receive' validates exchanges and returns a simulated response." }, - "name": { "index": 1, "kind": "path", "displayName": "Name", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A unique name to identify this endpoint. Allows multiple Citrus endpoints with different validation expectations in the same route." }, + "name": { "index": 1, "kind": "path", "displayName": "Name", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Name of mock endpoint" }, "assertPeriod": { "index": 2, "kind": "parameter", "displayName": "Assert Period", "group": "producer", "label": "producer", "required": false, "type": "duration", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "description": "Sets a grace period after which the mock will re-assert to ensure the preliminary assertion is still valid. This is used, for example, to assert that exactly a number of messages arrive. For example, if the expected count was set [...] "expectedCount": { "index": 3, "kind": "parameter", "displayName": "Expected Count", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": -1, "description": "Specifies the expected number of message exchanges that should be received by this mock. Beware: If you want to expect that 0 messages, then take extra care, as 0 matches when the tests starts, so you need to s [...] "messageType": { "index": 4, "kind": "parameter", "displayName": "Message Type", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The message type for validation. Determines which Citrus validation module is used. Supported values: json, xml, yaml, plaintext." }, diff --git a/components/camel-test/camel-test-citrus/src/generated/java/org/apache/camel/component/citrus/CitrusEndpointUriFactory.java b/components/camel-test/camel-test-citrus/src/generated/java/org/apache/camel/component/citrus/CitrusEndpointUriFactory.java index 54ed2323f209..64ff55b2ec76 100644 --- a/components/camel-test/camel-test-citrus/src/generated/java/org/apache/camel/component/citrus/CitrusEndpointUriFactory.java +++ b/components/camel-test/camel-test-citrus/src/generated/java/org/apache/camel/component/citrus/CitrusEndpointUriFactory.java @@ -60,7 +60,7 @@ public class CitrusEndpointUriFactory extends org.apache.camel.support.component Map<String, Object> copy = copyParameters(properties); uri = buildPathParameter(syntax, uri, "operation", null, true, copy); - uri = buildPathParameter(syntax, uri, "name", null, false, copy); + uri = buildPathParameter(syntax, uri, "name", null, true, copy); uri = buildQueryParameters(uri, copy, encode); return uri; } diff --git a/components/camel-test/camel-test-citrus/src/generated/resources/META-INF/org/apache/camel/component/citrus/citrus.json b/components/camel-test/camel-test-citrus/src/generated/resources/META-INF/org/apache/camel/component/citrus/citrus.json index 058471240c86..76941d15c7f3 100644 --- a/components/camel-test/camel-test-citrus/src/generated/resources/META-INF/org/apache/camel/component/citrus/citrus.json +++ b/components/camel-test/camel-test-citrus/src/generated/resources/META-INF/org/apache/camel/component/citrus/citrus.json @@ -31,7 +31,7 @@ }, "properties": { "operation": { "index": 0, "kind": "path", "displayName": "Operation", "group": "producer", "label": "", "required": true, "type": "enum", "javaType": "java.lang.String", "enum": [ "validate", "receive" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation to perform. 'validate' validates exchanges without modifying them. 'receive' validates exchanges and returns a simulated response." }, - "name": { "index": 1, "kind": "path", "displayName": "Name", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A unique name to identify this endpoint. Allows multiple Citrus endpoints with different validation expectations in the same route." }, + "name": { "index": 1, "kind": "path", "displayName": "Name", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Name of mock endpoint" }, "assertPeriod": { "index": 2, "kind": "parameter", "displayName": "Assert Period", "group": "producer", "label": "producer", "required": false, "type": "duration", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "description": "Sets a grace period after which the mock will re-assert to ensure the preliminary assertion is still valid. This is used, for example, to assert that exactly a number of messages arrive. For example, if the expected count was set [...] "expectedCount": { "index": 3, "kind": "parameter", "displayName": "Expected Count", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": -1, "description": "Specifies the expected number of message exchanges that should be received by this mock. Beware: If you want to expect that 0 messages, then take extra care, as 0 matches when the tests starts, so you need to s [...] "messageType": { "index": 4, "kind": "parameter", "displayName": "Message Type", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The message type for validation. Determines which Citrus validation module is used. Supported values: json, xml, yaml, plaintext." }, diff --git a/components/camel-test/camel-test-citrus/src/main/java/org/apache/camel/component/citrus/CitrusEndpoint.java b/components/camel-test/camel-test-citrus/src/main/java/org/apache/camel/component/citrus/CitrusEndpoint.java index 04f33ae3e931..614059cc7626 100644 --- a/components/camel-test/camel-test-citrus/src/main/java/org/apache/camel/component/citrus/CitrusEndpoint.java +++ b/components/camel-test/camel-test-citrus/src/main/java/org/apache/camel/component/citrus/CitrusEndpoint.java @@ -26,6 +26,7 @@ import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriPath; import org.citrusframework.CitrusContext; +import org.citrusframework.context.TestContext; import org.citrusframework.message.MessagePayloadBuilder; import org.citrusframework.validation.context.ValidationContext; @@ -39,10 +40,6 @@ public class CitrusEndpoint extends MockEndpoint { @Metadata(required = true) private String operation; - @UriPath(description = "A unique name to identify this endpoint. Allows multiple Citrus endpoints" - + " with different validation expectations in the same route.") - private String name; - @UriParam(description = "The message type for validation. Determines which Citrus validation module is used." + " Supported values: json, xml, yaml, plaintext.") private String messageType; @@ -91,14 +88,21 @@ public class CitrusEndpoint extends MockEndpoint { } private CitrusValidationProcessor createProcessor(MessageValidationSpec validationSpec) { - return new CitrusValidationProcessor(() -> citrusContext.createTestContext(), messageType, validationSpec); + return new CitrusValidationProcessor(this::createTestContext, messageType, validationSpec); } private CitrusValidationProcessor createProcessor( MessageValidationSpec validationSpec, MessageResponseSpec responseSpec) { - return new CitrusValidationProcessor( - () -> citrusContext.createTestContext(), messageType, validationSpec, responseSpec); + return new CitrusValidationProcessor(this::createTestContext, messageType, validationSpec, responseSpec); + } + + private TestContext createTestContext() { + CitrusContext ctx = citrusContext; + if (ctx == null) { + throw new IllegalStateException("CitrusEndpoint is not started"); + } + return ctx.createTestContext(); } // --- Gherkin-style API (for 'receive' operation) --- diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java index bef527f62ada..9d1bf697ccc6 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java @@ -3390,9 +3390,8 @@ public class StaticEndpointBuilders { * response. * There are 2 enums and the value can be one of: validate, receive * - * Path parameter: name - * A unique name to identify this endpoint. Allows multiple Citrus endpoints - * with different validation expectations in the same route. + * Path parameter: name (required) + * Name of mock endpoint * * @param path operation/name * @return the dsl builder @@ -3416,9 +3415,8 @@ public class StaticEndpointBuilders { * response. * There are 2 enums and the value can be one of: validate, receive * - * Path parameter: name - * A unique name to identify this endpoint. Allows multiple Citrus endpoints - * with different validation expectations in the same route. + * Path parameter: name (required) + * Name of mock endpoint * * @param componentName to use a custom component name for the endpoint * instead of the default name diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CitrusEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CitrusEndpointBuilderFactory.java index 57bbadf83f6b..5c1bcbe5036b 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CitrusEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/CitrusEndpointBuilderFactory.java @@ -592,9 +592,8 @@ public interface CitrusEndpointBuilderFactory { * response. * There are 2 enums and the value can be one of: validate, receive * - * Path parameter: name - * A unique name to identify this endpoint. Allows multiple Citrus - * endpoints with different validation expectations in the same route. + * Path parameter: name (required) + * Name of mock endpoint * * @param path operation/name * @return the dsl builder @@ -618,9 +617,8 @@ public interface CitrusEndpointBuilderFactory { * response. * There are 2 enums and the value can be one of: validate, receive * - * Path parameter: name - * A unique name to identify this endpoint. Allows multiple Citrus - * endpoints with different validation expectations in the same route. + * Path parameter: name (required) + * Name of mock endpoint * * @param componentName to use a custom component name for the endpoint * instead of the default name
