Skip to content

CAMEL-23542: Restore @Nullable annotations removed by the requireNonNull revert#23304

Open
gnodet wants to merge 2 commits into
apache:mainfrom
gnodet:CAMEL-23542-restore-nullable-annotations
Open

CAMEL-23542: Restore @Nullable annotations removed by the requireNonNull revert#23304
gnodet wants to merge 2 commits into
apache:mainfrom
gnodet:CAMEL-23542-restore-nullable-annotations

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented May 18, 2026

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 @Nullable JSpecify annotations. This PR restores them to accurately document the nullability contracts:

  • ValidationException: exchange, message, and cause parameters are nullable — callers pass null exchange in tests, e.getMessage() returns null, and callers may hold a cause in a variable that could be null
  • CamelExchangeException: message and cause parameters are nullable — consistent with createExceptionMessage() which already accepts all-@Nullable parameters, and Exception(String, Throwable) handles null cause
  • RestConfiguration.setValidationLevels: parameter is nullable — consistent with the field and getter which are already @Nullable

Claude Code on behalf of Guillaume Nodet

…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>
@github-actions
Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions
Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • core/camel-api

ℹ️ Dependent modules were not tested because the total number of affected modules exceeded the threshold (50). Use the test-dependents label to force testing all dependents.


⚙️ View full build and test results

* @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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the cause is Nullable too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants