CAMEL-24460: Mark ProducerTemplate body, header and property values as @Nullable - #26032
Conversation
…@nullable The org.apache.camel package is @NullMarked, so unannotated reference parameters are treated as non-null under JSpecify. Camel supports null message bodies at runtime, and the sibling FluentProducerTemplate already annotates its withBody/withHeader/withExchangeProperty values as @nullable. Align ProducerTemplate by marking body, header value and property value parameters as @nullable. Header/property names and the headers Map stay non-null (keys cannot be null). Annotation-only change: no runtime or binary compatibility impact. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
…via ProducerTemplate Drives a null body, null header value and null property value through the ProducerTemplate API end-to-end, verifying they are accepted and routed. Closes the property-value coverage gap and anchors the @nullable contract. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 565 tested, 27 compile-only — current: 565 all testedMaveniverse Scalpel detected 592 affected modules (current approach: 565).
|
…@nullable (backport 4.22.x) (#26037) CAMEL-24460: Mark ProducerTemplate body, header and property values as @nullable The org.apache.camel package is @NullMarked, so unannotated reference parameters are treated as non-null under JSpecify. Camel supports null message bodies at runtime, and the sibling FluentProducerTemplate already annotates its withBody/withHeader/withExchangeProperty values as @nullable. ProducerTemplate was missed in that rollout. Align ProducerTemplate by marking body, header value and property value parameters as @nullable. Header/property names and the headers Map stay non-null (keys cannot be null). Annotation-only change with no runtime or binary compatibility impact. Adds a test driving a null body, header value and property value through the API end-to-end. Closes #26032 (cherry picked from commit 01b6fd5) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Description
The
org.apache.camelpackage is@NullMarked, so unannotated reference parameters are treated as non-null under JSpecify. However, Camel fully supportsnullmessage bodies at runtime, and the siblingFluentProducerTemplatealready annotates itswithBody/withHeader/withExchangePropertyvalues as@Nullable(added in CAMEL-22640).ProducerTemplatewas missed in that rollout, so callers with null-checking enabled were forced to work around a contract that does not match reality.This aligns
ProducerTemplatewithFluentProducerTemplate:@Nullableadded to allbodyparameters (sendBody*,requestBody*,asyncSendBody,asyncRequestBody*)@Nullableadded toheaderValueandpropertyValueparametersString header,String property) and theMap<String, Object> headersremain non-null — keys cannot be nullImpact
Testing
Added
DefaultProducerTemplateTest.testNullBodyAndValues, driving a null body, null header value, and null property value through the API end-to-end (the property-value case had no prior direct coverage). Null bodies and null header values are already exercised widely across the core test suite.JIRA: https://issues.apache.org/jira/browse/CAMEL-24460
Claude Code on behalf of @davsclaus