You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "gnodet (via GitHub)" <gi...@apache.org> on 2026/05/13 12:18:44 UTC

[PR] CAMEL-22640: Tighten @Nullable annotations where non-null is enforced [camel]

gnodet opened a new pull request, #23194:
URL: https://github.com/apache/camel/pull/23194

   [CAMEL-22640](https://issues.apache.org/jira/browse/CAMEL-22640)
   
   ## Summary
   
   Follow-up to #23021 — removes `@Nullable` from fields and parameters that are already enforced as non-null or are never null in practice. The previous PR documented *current reality*; this PR tightens the contract where *intentionality* is clear.
   
   ## Changes
   
   - **`InvalidPayloadException.type`** / **`InvalidPayloadRuntimeException.type`**: Remove `@Nullable` from field and getter — all constructors enforce non-null via `requireNonNull`. The `@Nullable` was only there because the field is `transient`.
   - **`ExpectedBodyTypeException.exchange`** + **`expectedBodyType`**: Same — single constructor enforces non-null via `requireNonNull`.
   - **`ResolveEndpointFailedException.uri`**: Remove `@Nullable` from field, constructors, and getter — zero callers across the entire codebase pass null. Add `requireNonNull` enforcement.
   - **`LifecycleStrategy.onThreadPoolAdd()` `id` param**: Remove `@Nullable` — `BaseExecutorServiceManager.onThreadPoolCreated()` always computes a non-null id (with `StringHelper.notEmpty()` enforcement at line 584).
   - **`DataType(String urn)` constructor**: Remove `@Nullable` and the null-to-`ANY` fallback. Callers should use `DataType.ANY` explicitly. No callers pass null.
   
   ## Verification
   
   - `mvn install -B -pl core/camel-api -DskipTests -am` — BUILD SUCCESS
   - `mvn install -B -pl core/camel-core -DskipTests` — BUILD SUCCESS (downstream compilation)
   - `mvn formatter:format impsort:sort -B -pl core/camel-api` — no formatting changes


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22640: Tighten @Nullable annotations where non-null is enforced [camel]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #23194:
URL: https://github.com/apache/camel/pull/23194#discussion_r3235199096


##########
core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java:
##########
@@ -18,35 +18,33 @@
 
 import java.util.Objects;
 
-import org.jspecify.annotations.Nullable;
-
 import static org.apache.camel.util.URISupport.sanitizeUri;
 
 /**
  * A runtime exception thrown if an {@link Endpoint} cannot be resolved via URI
  */
 public class ResolveEndpointFailedException extends RuntimeCamelException {
 
-    private final @Nullable String uri;
+    private final String uri;
 
-    public ResolveEndpointFailedException(@Nullable String uri, Throwable cause) {
-        super("Failed to resolve endpoint: " + sanitizeUri(uri) + " due to: "
+    public ResolveEndpointFailedException(String uri, Throwable cause) {
+        super("Failed to resolve endpoint: " + sanitizeUri(Objects.requireNonNull(uri, "uri")) + " due to: "

Review Comment:
   If we could come up with a real value added message, that would be different, but here, we're just checking an argument, we don't have any information to provide.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22640: Tighten @Nullable annotations where non-null is enforced [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #23194:
URL: https://github.com/apache/camel/pull/23194#issuecomment-4440886089

   :star2: Thank you for your contribution to the Apache Camel project! :star2:
     :robot: CI automation will test this PR automatically.
   
     :camel: 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](https://camel.apache.org/community/team/#committers) have access to the summary.
     
     :warning: Be careful when sharing logs. Review their contents before sharing them publicly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22640: Tighten @Nullable annotations where non-null is enforced [camel]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #23194:
URL: https://github.com/apache/camel/pull/23194#discussion_r3235190072


##########
core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java:
##########
@@ -18,35 +18,33 @@
 
 import java.util.Objects;
 
-import org.jspecify.annotations.Nullable;
-
 import static org.apache.camel.util.URISupport.sanitizeUri;
 
 /**
  * A runtime exception thrown if an {@link Endpoint} cannot be resolved via URI
  */
 public class ResolveEndpointFailedException extends RuntimeCamelException {
 
-    private final @Nullable String uri;
+    private final String uri;
 
-    public ResolveEndpointFailedException(@Nullable String uri, Throwable cause) {
-        super("Failed to resolve endpoint: " + sanitizeUri(uri) + " due to: "
+    public ResolveEndpointFailedException(String uri, Throwable cause) {
+        super("Failed to resolve endpoint: " + sanitizeUri(Objects.requireNonNull(uri, "uri")) + " due to: "

Review Comment:
   That's how the JDK handles it, and it's consistent with the rest of the codebase (not completely, but mostly). `NullPointerException("uri must not be null")` doesn't add information over `NullPointerException("uri")` — the "must not be null" part is already conveyed by the exception type itself. The parameter name is the useful signal; the rest is noise.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22640: Tighten @Nullable annotations where non-null is enforced [camel]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet merged PR #23194:
URL: https://github.com/apache/camel/pull/23194


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22640: Tighten @Nullable annotations where non-null is enforced [camel]

Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier commented on code in PR #23194:
URL: https://github.com/apache/camel/pull/23194#discussion_r3234582869


##########
core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java:
##########
@@ -18,35 +18,33 @@
 
 import java.util.Objects;
 
-import org.jspecify.annotations.Nullable;
-
 import static org.apache.camel.util.URISupport.sanitizeUri;
 
 /**
  * A runtime exception thrown if an {@link Endpoint} cannot be resolved via URI
  */
 public class ResolveEndpointFailedException extends RuntimeCamelException {
 
-    private final @Nullable String uri;
+    private final String uri;
 
-    public ResolveEndpointFailedException(@Nullable String uri, Throwable cause) {
-        super("Failed to resolve endpoint: " + sanitizeUri(uri) + " due to: "
+    public ResolveEndpointFailedException(String uri, Throwable cause) {
+        super("Failed to resolve endpoint: " + sanitizeUri(Objects.requireNonNull(uri, "uri")) + " due to: "
               + Objects.requireNonNull(cause, "cause").getMessage(), cause);
         this.uri = sanitizeUri(uri);
     }
 
-    public ResolveEndpointFailedException(@Nullable String uri, String message) {
-        super("Failed to resolve endpoint: " + sanitizeUri(uri) + " due to: "
+    public ResolveEndpointFailedException(String uri, String message) {
+        super("Failed to resolve endpoint: " + sanitizeUri(Objects.requireNonNull(uri, "uri")) + " due to: "

Review Comment:
   the Objects.requireNonNull shoudl provide a meaningful message or it is uselles and just blur the codebase



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22640: Tighten @Nullable annotations where non-null is enforced [camel]

Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier commented on code in PR #23194:
URL: https://github.com/apache/camel/pull/23194#discussion_r3234579668


##########
core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java:
##########
@@ -18,35 +18,33 @@
 
 import java.util.Objects;
 
-import org.jspecify.annotations.Nullable;
-
 import static org.apache.camel.util.URISupport.sanitizeUri;
 
 /**
  * A runtime exception thrown if an {@link Endpoint} cannot be resolved via URI
  */
 public class ResolveEndpointFailedException extends RuntimeCamelException {
 
-    private final @Nullable String uri;
+    private final String uri;
 
-    public ResolveEndpointFailedException(@Nullable String uri, Throwable cause) {
-        super("Failed to resolve endpoint: " + sanitizeUri(uri) + " due to: "
+    public ResolveEndpointFailedException(String uri, Throwable cause) {
+        super("Failed to resolve endpoint: " + sanitizeUri(Objects.requireNonNull(uri, "uri")) + " due to: "

Review Comment:
   the Objects.requireNonNull shoudl provide a meaningful message or it is uselles and just blur the codebase



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22640: Tighten @Nullable annotations where non-null is enforced [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #23194:
URL: https://github.com/apache/camel/pull/23194#discussion_r3235614112


##########
core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java:
##########
@@ -18,35 +18,33 @@
 
 import java.util.Objects;
 
-import org.jspecify.annotations.Nullable;
-
 import static org.apache.camel.util.URISupport.sanitizeUri;
 
 /**
  * A runtime exception thrown if an {@link Endpoint} cannot be resolved via URI
  */
 public class ResolveEndpointFailedException extends RuntimeCamelException {
 
-    private final @Nullable String uri;
+    private final String uri;
 
-    public ResolveEndpointFailedException(@Nullable String uri, Throwable cause) {
-        super("Failed to resolve endpoint: " + sanitizeUri(uri) + " due to: "
+    public ResolveEndpointFailedException(String uri, Throwable cause) {
+        super("Failed to resolve endpoint: " + sanitizeUri(Objects.requireNonNull(uri, "uri")) + " due to: "

Review Comment:
   yeah this is fine and how other frameworks also would do it - also those null values are rarely happening and if so its during development.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22640: Tighten @Nullable annotations where non-null is enforced [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #23194:
URL: https://github.com/apache/camel/pull/23194#issuecomment-4442790368

   LGTM


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-22640: Tighten @Nullable annotations where non-null is enforced [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #23194:
URL: https://github.com/apache/camel/pull/23194#issuecomment-4441032187

   <!-- ci-tested-modules -->
   :test_tube: **CI tested the following changed modules:**
   
   - `core/camel-api`
   
   > :information_source: 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.
   
   ---
   :gear: [View full build and test results](https://github.com/apache/camel/actions/runs/25798617999)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org