CAMEL-23542: Restore @Nullable annotations removed by the requireNonNull revert#23304
CAMEL-23542: Restore @Nullable annotations removed by the requireNonNull revert#23304gnodet wants to merge 2 commits into
Conversation
…ull revert The revert in apache#23289 correctly removed the Objects.requireNonNull() runtime checks but also removed the @nullable annotations. Restore them to accurately document the nullability contracts: - ValidationException: exchange and message parameters are nullable (callers pass null exchange in tests, and e.getMessage() returns null) - CamelExchangeException: message parameter is nullable (consistent with createExceptionMessage() which already accepts @nullable) - RestConfiguration.setValidationLevels: parameter is nullable (consistent with the field and getter which are already @nullable) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.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:
|
| * @param cause the cause of the failure | ||
| */ | ||
| public CamelExchangeException(String message, @Nullable Exchange exchange, Throwable cause) { | ||
| public CamelExchangeException(@Nullable String message, @Nullable Exchange exchange, Throwable cause) { |
There was a problem hiding this comment.
I think that the cause is Nullable too
There was a problem hiding this comment.
Good point — added @Nullable on Throwable cause too (both CamelExchangeException and ValidationException). Java's Exception(String, Throwable) and createExceptionMessage() both handle null cause correctly, and it avoids forcing callers to branch on whether cause is null to pick the right constructor.
Claude Code on behalf of Guillaume Nodet
Allows callers to use the 3-arg constructor without branching on whether cause is null. Java's Exception(String, Throwable) and createExceptionMessage() both handle null cause correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CAMEL-23542
Follow-up to #23289.
Summary
The revert in #23289 correctly removed the
Objects.requireNonNull()runtime checks that broke 3 tests, but also removed the@NullableJSpecify annotations. This PR restores them to accurately document the nullability contracts:ValidationException:exchange,message, andcauseparameters are nullable — callers pass null exchange in tests,e.getMessage()returns null, and callers may hold a cause in a variable that could be nullCamelExchangeException:messageandcauseparameters are nullable — consistent withcreateExceptionMessage()which already accepts all-@Nullableparameters, andException(String, Throwable)handles null causeRestConfiguration.setValidationLevels: parameter is nullable — consistent with the field and getter which are already@NullableClaude Code on behalf of Guillaume Nodet