From 59bc93a36f8a50750743faa1c346313b8a0c06e2 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Wed, 13 May 2026 14:18:16 +0200 Subject: [PATCH 1/2] CAMEL-22640: Tighten @Nullable annotations where non-null is enforced Remove @Nullable from parameters that are already enforced as non-null or are never null in practice: - ResolveEndpointFailedException.uri: zero callers pass null, add requireNonNull enforcement - LifecycleStrategy.onThreadPoolAdd() id param: always computed by BaseExecutorServiceManager before callback (the original Javadoc "can be null in special cases" was accurate when added in CAMEL-3437, but the caller was later fixed to always generate an id) Co-Authored-By: Claude Opus 4.6 (1M context) --- .../camel/ResolveEndpointFailedException.java | 18 ++++++++---------- .../apache/camel/spi/LifecycleStrategy.java | 8 ++++---- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java b/core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java index a5df127cb5438..36cc705038bbc 100644 --- a/core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java +++ b/core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java @@ -18,8 +18,6 @@ import java.util.Objects; -import org.jspecify.annotations.Nullable; - import static org.apache.camel.util.URISupport.sanitizeUri; /** @@ -27,26 +25,26 @@ */ 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: " + Objects.requireNonNull(message, "message")); this.uri = sanitizeUri(uri); } - public ResolveEndpointFailedException(@Nullable String uri) { - super("Failed to resolve endpoint: " + sanitizeUri(uri)); + public ResolveEndpointFailedException(String uri) { + super("Failed to resolve endpoint: " + sanitizeUri(Objects.requireNonNull(uri, "uri"))); this.uri = sanitizeUri(uri); } - public @Nullable String getUri() { + public String getUri() { return uri; } } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/LifecycleStrategy.java b/core/camel-api/src/main/java/org/apache/camel/spi/LifecycleStrategy.java index 737de85ab25da..037e7e585c702 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/LifecycleStrategy.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/LifecycleStrategy.java @@ -194,13 +194,13 @@ default void onServiceRemove(CamelContext context, Service service, @Nullable Ro * * @param camelContext the camel context * @param threadPool the thread pool - * @param id id of the thread pool (can be null in special cases) + * @param id id of the thread pool * @param sourceId id of the source creating the thread pool (can be null in special cases) * @param routeId id of the route for the source (is null if no source) * @param threadPoolProfileId id of the thread pool profile, if used for creating this thread pool (can be null) */ void onThreadPoolAdd( - CamelContext camelContext, ThreadPoolExecutor threadPool, @Nullable String id, + CamelContext camelContext, ThreadPoolExecutor threadPool, String id, @Nullable String sourceId, @Nullable String routeId, @Nullable String threadPoolProfileId); /** @@ -217,13 +217,13 @@ void onThreadPoolAdd( * * @param camelContext the camel context * @param executorService the executor service - * @param id id of the thread pool (can be null in special cases) + * @param id id of the thread pool * @param sourceId id of the source creating the thread pool (can be null in special cases) * @param routeId id of the route for the source (is null if no source) * @param threadPoolProfileId id of the thread pool profile, if used for creating this thread pool (can be null) */ default void onThreadPoolAdd( - CamelContext camelContext, ExecutorService executorService, @Nullable String id, + CamelContext camelContext, ExecutorService executorService, String id, @Nullable String sourceId, @Nullable String routeId, @Nullable String threadPoolProfileId) { } From fd1f7e3ee66caaea77691fcd506fed4c6fd5f991 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Thu, 14 May 2026 23:51:05 +0200 Subject: [PATCH 2/2] CAMEL-22640: Add missing @Nullable import in ResolveEndpointFailedException Co-Authored-By: Claude Opus 4.6 (1M context) --- .../java/org/apache/camel/ResolveEndpointFailedException.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java b/core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java index 9dc49a5060f11..7465547a3d0e6 100644 --- a/core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java +++ b/core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java @@ -18,6 +18,8 @@ import java.util.Objects; +import org.jspecify.annotations.Nullable; + import static org.apache.camel.util.URISupport.sanitizeUri; /**