From da280a220f310af680f2cda8bf2427ea478c8fe9 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Sun, 29 Mar 2026 23:02:54 +0200 Subject: [PATCH 1/3] CAMEL-22640: Add JSpecify null safety annotations to camel-api Add @NullMarked (JSpecify 1.0.0) to all packages in camel-api, making non-null the default. Annotate ~200 API interfaces and classes with @Nullable where parameters or return values can legitimately be null, covering the core API surface including CamelContext, Exchange, Message, Component, Endpoint, TypeConverter, and all SPI interfaces. Co-Authored-By: Claude Opus 4.6 --- core/camel-api/pom.xml | 5 ++ .../org/apache/camel/AggregationStrategy.java | 9 +- .../org/apache/camel/BinaryPredicate.java | 3 + .../camel/CamelAuthorizationException.java | 6 +- .../java/org/apache/camel/CamelContext.java | 57 +++++++++---- .../java/org/apache/camel/CamelException.java | 8 +- .../apache/camel/CamelExchangeException.java | 9 +- .../org/apache/camel/CatalogCamelContext.java | 8 ++ .../main/java/org/apache/camel/Channel.java | 6 +- .../main/java/org/apache/camel/Component.java | 9 +- .../java/org/apache/camel/ComponentAware.java | 5 +- .../main/java/org/apache/camel/Consumer.java | 3 +- .../org/apache/camel/ConsumerTemplate.java | 18 +++- .../apache/camel/DynamicPollingConsumer.java | 5 ++ .../main/java/org/apache/camel/Exchange.java | 39 +++++---- .../org/apache/camel/ExchangeExtension.java | 23 ++++-- .../org/apache/camel/ExchangePropertyKey.java | 3 +- .../java/org/apache/camel/Expression.java | 4 +- .../ExpressionIllegalSyntaxException.java | 4 +- .../apache/camel/ExtendedCamelContext.java | 33 +++++--- .../camel/FailedToCreateRouteException.java | 15 ++-- .../camel/FailedToStartRouteException.java | 8 +- .../apache/camel/FluentProducerTemplate.java | 15 ++-- .../camel/InvalidPropertyException.java | 8 +- .../org/apache/camel/LineNumberAware.java | 7 +- .../main/java/org/apache/camel/Message.java | 21 +++-- .../java/org/apache/camel/MessageHistory.java | 3 + .../main/java/org/apache/camel/NamedNode.java | 11 ++- .../java/org/apache/camel/NamedRoute.java | 3 + .../main/java/org/apache/camel/Navigate.java | 3 + .../org/apache/camel/NoSuchBeanException.java | 8 +- .../apache/camel/NoSuchHeaderException.java | 10 ++- .../NoSuchHeaderOrPropertyException.java | 4 +- .../apache/camel/NoSuchPropertyException.java | 10 ++- .../apache/camel/NoSuchVariableException.java | 6 +- .../NoTypeConversionAvailableException.java | 16 ++-- .../org/apache/camel/PollingConsumer.java | 5 ++ .../org/apache/camel/ProducerTemplate.java | 38 +++++++-- .../camel/PropertiesLookupListener.java | 4 +- .../camel/PropertyBindingException.java | 26 +++--- .../src/main/java/org/apache/camel/Route.java | 19 ++++- .../java/org/apache/camel/RouteAware.java | 5 +- .../apache/camel/RouteTemplateContext.java | 8 +- .../apache/camel/RuntimeCamelException.java | 8 +- .../apache/camel/RuntimeConfiguration.java | 6 +- .../camel/RuntimeExchangeException.java | 8 +- .../camel/SSLContextParametersAware.java | 3 +- .../java/org/apache/camel/StreamCache.java | 3 + .../apache/camel/StreamCacheException.java | 4 +- .../java/org/apache/camel/TimeoutMap.java | 6 ++ .../apache/camel/TypeConversionException.java | 12 +-- .../java/org/apache/camel/TypeConverter.java | 16 ++-- .../java/org/apache/camel/VariableAware.java | 3 + .../org/apache/camel/ai/package-info.java | 20 +++++ ...nfigurationPropertiesValidationResult.java | 18 ++-- .../catalog/EndpointValidationResult.java | 24 +++--- .../camel/catalog/JSonSchemaResolver.java | 12 +++ .../catalog/LanguageValidationResult.java | 14 ++-- .../catalog/PropertiesValidationResult.java | 54 ++++++++---- .../camel/catalog/RuntimeCamelCatalog.java | 2 + .../apache/camel/catalog/package-info.java | 20 +++++ .../org/apache/camel/clock/ContextClock.java | 3 +- .../org/apache/camel/clock/EventClock.java | 3 + .../org/apache/camel/clock/package-info.java | 20 +++++ .../camel/cloudevents/package-info.java | 20 +++++ .../apache/camel/cluster/package-info.java | 20 +++++ .../extension/ComponentVerifierExtension.java | 6 +- .../extension/MetaDataExtension.java | 7 +- .../component/extension/package-info.java | 20 +++++ .../camel/console/DevConsoleRegistry.java | 4 +- .../camel/console/DevConsoleResolver.java | 2 + .../apache/camel/console/package-info.java | 20 +++++ .../camel/health/HealthCheckHelper.java | 20 +++-- .../camel/health/HealthCheckRegistry.java | 7 +- .../camel/health/HealthCheckResolver.java | 3 + .../health/HealthCheckResultBuilder.java | 21 ++--- .../org/apache/camel/health/package-info.java | 20 +++++ .../java/org/apache/camel/package-info.java | 3 + .../apache/camel/resume/Deserializable.java | 8 +- .../java/org/apache/camel/resume/Offset.java | 4 +- .../org/apache/camel/resume/Resumable.java | 3 + .../apache/camel/resume/ResumeStrategy.java | 7 +- .../resume/ResumeStrategyConfiguration.java | 9 +- .../org/apache/camel/resume/Serializable.java | 3 +- .../camel/resume/cache/ResumeCache.java | 4 +- .../camel/resume/cache/package-info.java | 20 +++++ .../org/apache/camel/resume/package-info.java | 20 +++++ .../camel/spi/AggregationRepository.java | 3 + .../camel/spi/AsyncProcessorAwaitManager.java | 3 + .../org/apache/camel/spi/BacklogDebugger.java | 3 + .../org/apache/camel/spi/BacklogTracer.java | 8 +- .../camel/spi/BacklogTracerEventMessage.java | 13 +++ .../apache/camel/spi/BeanIntrospection.java | 10 ++- .../camel/spi/BeanProcessorFactory.java | 6 +- .../org/apache/camel/spi/BeanRepository.java | 6 +- .../java/org/apache/camel/spi/Breakpoint.java | 3 +- .../apache/camel/spi/BulkTypeConverters.java | 8 +- .../camel/spi/CamelBeanPostProcessor.java | 5 +- .../spi/CamelBeanPostProcessorInjector.java | 6 +- .../java/org/apache/camel/spi/CamelEvent.java | 2 + .../spi/CamelInternalProcessorAdvice.java | 4 +- .../org/apache/camel/spi/CamelLogger.java | 13 +-- .../camel/spi/ClaimCheckRepository.java | 4 + .../org/apache/camel/spi/ClassResolver.java | 11 ++- .../camel/spi/CompilePostProcessor.java | 3 +- .../apache/camel/spi/ComponentResolver.java | 2 + .../apache/camel/spi/ConfigurerResolver.java | 2 + .../org/apache/camel/spi/ConsumerCache.java | 4 + .../apache/camel/spi/ContentTypeAware.java | 5 +- .../java/org/apache/camel/spi/Contract.java | 5 +- .../apache/camel/spi/DataFormatResolver.java | 2 + .../java/org/apache/camel/spi/DataType.java | 3 +- .../org/apache/camel/spi/DataTypeAware.java | 3 + .../camel/spi/EndpointServiceLocation.java | 6 +- .../camel/spi/EndpointServiceRegistry.java | 5 +- .../apache/camel/spi/ErrorRegistryEntry.java | 7 +- .../org/apache/camel/spi/EventFactory.java | 5 +- .../camel/spi/ExecutorServiceManager.java | 3 + .../camel/spi/ExpressionResultTypeAware.java | 3 + .../java/org/apache/camel/spi/GroupAware.java | 4 +- .../java/org/apache/camel/spi/HasGroup.java | 3 + .../camel/spi/HeaderFilterStrategy.java | 5 +- .../camel/spi/HeaderFilterStrategyAware.java | 3 + .../apache/camel/spi/HttpResponseAware.java | 5 +- .../apache/camel/spi/InflightRepository.java | 10 ++- .../camel/spi/InterceptEndpointFactory.java | 3 +- .../camel/spi/InterceptSendToEndpoint.java | 10 ++- .../apache/camel/spi/InterceptStrategy.java | 3 +- .../apache/camel/spi/InternalProcessor.java | 3 +- .../camel/spi/InternalProcessorFactory.java | 4 +- .../camel/spi/InvokeOnHeaderStrategy.java | 2 + .../apache/camel/spi/LanguageCustomizer.java | 3 +- .../apache/camel/spi/LifecycleStrategy.java | 15 ++-- .../camel/spi/LocalBeanRepositoryAware.java | 5 +- .../org/apache/camel/spi/ManagementAgent.java | 4 +- .../spi/ManagementInterceptStrategy.java | 6 +- .../camel/spi/ManagementMBeanAssembler.java | 2 + .../camel/spi/ManagementNameStrategy.java | 3 + .../spi/ManagementObjectNameStrategy.java | 4 +- .../camel/spi/ManagementObjectStrategy.java | 3 +- .../camel/spi/ManagementStrategyFactory.java | 3 +- .../camel/spi/MessageHistoryFactory.java | 4 +- .../MockSendToEndpointStrategyFactory.java | 4 +- .../org/apache/camel/spi/ModelDumpLine.java | 4 +- .../apache/camel/spi/OAuthClientConfig.java | 20 +++-- ...ptimisticLockingAggregationRepository.java | 4 +- .../apache/camel/spi/PeriodTaskScheduler.java | 4 +- .../org/apache/camel/spi/PluginManager.java | 4 +- .../apache/camel/spi/PollDynamicAware.java | 2 + .../apache/camel/spi/PooledObjectFactory.java | 3 + .../camel/spi/PredicateExceptionFactory.java | 4 +- .../apache/camel/spi/ProcessorFactory.java | 4 + .../org/apache/camel/spi/ProducerCache.java | 6 +- .../apache/camel/spi/PropertiesComponent.java | 10 ++- .../camel/spi/PropertiesResolvedValue.java | 5 +- .../apache/camel/spi/PropertiesSource.java | 4 +- .../camel/spi/PropertyConfigurerAware.java | 3 + .../camel/spi/PropertyConfigurerGetter.java | 8 +- .../spi/RecoverableAggregationRepository.java | 5 +- .../java/org/apache/camel/spi/Registry.java | 11 ++- .../org/apache/camel/spi/ReloadStrategy.java | 2 + .../java/org/apache/camel/spi/Resource.java | 4 +- .../org/apache/camel/spi/ResourceAware.java | 3 + .../apache/camel/spi/ResourceResolver.java | 2 + ...estBindingJacksonXmlDataFormatFactory.java | 4 +- .../spi/RestBindingJaxbDataFormatFactory.java | 4 +- .../camel/spi/RestClientRequestValidator.java | 2 + .../spi/RestClientResponseValidator.java | 2 + .../apache/camel/spi/RestConfiguration.java | 82 ++++++++++--------- .../apache/camel/spi/RestConsumerFactory.java | 7 +- .../apache/camel/spi/RestProducerFactory.java | 6 +- .../org/apache/camel/spi/RestRegistry.java | 17 +++- .../org/apache/camel/spi/RouteFactory.java | 5 +- .../org/apache/camel/spi/RouteIdAware.java | 3 + .../apache/camel/spi/RoutePolicyFactory.java | 2 + .../apache/camel/spi/ScriptingLanguage.java | 4 +- .../apache/camel/spi/SendDynamicAware.java | 4 + .../org/apache/camel/spi/SimpleFunction.java | 4 +- .../camel/spi/SimpleFunctionRegistry.java | 2 + .../spi/SimpleLanguageFunctionFactory.java | 3 + .../apache/camel/spi/StartupCondition.java | 5 +- .../apache/camel/spi/StartupStepRecorder.java | 3 + .../org/apache/camel/spi/StateRepository.java | 2 + .../camel/spi/StreamCachingStrategy.java | 5 ++ .../camel/spi/SupervisingRouteController.java | 10 ++- .../org/apache/camel/spi/Synchronization.java | 3 +- .../apache/camel/spi/ThreadPoolProfile.java | 57 ++++++------- .../java/org/apache/camel/spi/Tracer.java | 4 +- .../org/apache/camel/spi/Transformer.java | 17 ++-- .../apache/camel/spi/TransformerRegistry.java | 2 + .../apache/camel/spi/TransformerResolver.java | 2 + .../camel/spi/TypeConverterRegistry.java | 2 + .../java/org/apache/camel/spi/UnitOfWork.java | 5 +- .../apache/camel/spi/UriFactoryResolver.java | 2 + .../java/org/apache/camel/spi/Validator.java | 9 +- .../apache/camel/spi/ValidatorRegistry.java | 2 + .../apache/camel/spi/VariableRepository.java | 2 + .../camel/spi/VariableRepositoryFactory.java | 3 + .../org/apache/camel/spi/package-info.java | 20 +++++ .../jsse/AliasedX509ExtendedKeyManager.java | 20 +++-- .../jsse/BaseSSLContextParameters.java | 57 ++++++------- .../support/jsse/CipherSuitesParameters.java | 6 +- .../camel/support/jsse/FilterParameters.java | 6 +- .../camel/support/jsse/JsseParameters.java | 5 +- .../support/jsse/KeyManagersParameters.java | 25 +++--- .../support/jsse/KeyStoreParameters.java | 29 +++---- .../support/jsse/NamedGroupsParameters.java | 4 +- .../support/jsse/SSLContextParameters.java | 47 +++++------ .../jsse/SSLContextServerParameters.java | 7 +- .../support/jsse/SecureRandomParameters.java | 13 +-- .../jsse/SecureSocketProtocolsParameters.java | 6 +- .../jsse/SignatureSchemesParameters.java | 4 +- .../support/jsse/TrustManagersParameters.java | 25 +++--- .../camel/support/jsse/package-info.java | 20 +++++ .../camel/support/service/BaseService.java | 3 +- .../camel/support/service/ServiceHelper.java | 55 +++++++------ .../camel/support/service/package-info.java | 20 +++++ .../camel/trait/message/package-info.java | 20 +++++ .../camel/vault/AwsVaultConfiguration.java | 43 +++++----- .../camel/vault/AzureVaultConfiguration.java | 55 +++++++------ .../vault/CyberArkVaultConfiguration.java | 49 +++++------ .../camel/vault/GcpVaultConfiguration.java | 25 +++--- .../vault/HashicorpVaultConfiguration.java | 37 +++++---- .../IBMSecretsManagerVaultConfiguration.java | 49 +++++------ ...KubernetesConfigMapVaultConfiguration.java | 7 +- .../vault/KubernetesVaultConfiguration.java | 7 +- .../vault/SpringCloudConfigConfiguration.java | 25 +++--- .../camel/vault/VaultConfiguration.java | 56 +++++++------ .../org/apache/camel/vault/package-info.java | 20 +++++ parent/pom.xml | 8 ++ 230 files changed, 1700 insertions(+), 768 deletions(-) create mode 100644 core/camel-api/src/main/java/org/apache/camel/ai/package-info.java create mode 100644 core/camel-api/src/main/java/org/apache/camel/catalog/package-info.java create mode 100644 core/camel-api/src/main/java/org/apache/camel/clock/package-info.java create mode 100644 core/camel-api/src/main/java/org/apache/camel/cloudevents/package-info.java create mode 100644 core/camel-api/src/main/java/org/apache/camel/cluster/package-info.java create mode 100644 core/camel-api/src/main/java/org/apache/camel/component/extension/package-info.java create mode 100644 core/camel-api/src/main/java/org/apache/camel/console/package-info.java create mode 100644 core/camel-api/src/main/java/org/apache/camel/health/package-info.java create mode 100644 core/camel-api/src/main/java/org/apache/camel/resume/cache/package-info.java create mode 100644 core/camel-api/src/main/java/org/apache/camel/resume/package-info.java create mode 100644 core/camel-api/src/main/java/org/apache/camel/spi/package-info.java create mode 100644 core/camel-api/src/main/java/org/apache/camel/support/jsse/package-info.java create mode 100644 core/camel-api/src/main/java/org/apache/camel/support/service/package-info.java create mode 100644 core/camel-api/src/main/java/org/apache/camel/trait/message/package-info.java create mode 100644 core/camel-api/src/main/java/org/apache/camel/vault/package-info.java diff --git a/core/camel-api/pom.xml b/core/camel-api/pom.xml index fac4acf912a07..c0d953d18c87c 100644 --- a/core/camel-api/pom.xml +++ b/core/camel-api/pom.xml @@ -39,6 +39,11 @@ + + org.jspecify + jspecify + + org.apache.camel camel-util diff --git a/core/camel-api/src/main/java/org/apache/camel/AggregationStrategy.java b/core/camel-api/src/main/java/org/apache/camel/AggregationStrategy.java index 2109aa7df7bb4..fd040410bb001 100644 --- a/core/camel-api/src/main/java/org/apache/camel/AggregationStrategy.java +++ b/core/camel-api/src/main/java/org/apache/camel/AggregationStrategy.java @@ -16,6 +16,7 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; import org.slf4j.LoggerFactory; /** @@ -64,7 +65,8 @@ public interface AggregationStrategy { * @return a combined composite of the two exchanges, return either the old or new exchange from the * input parameters; favor returning the old exchange whenever possible) */ - Exchange aggregate(Exchange oldExchange, Exchange newExchange); + @Nullable + Exchange aggregate(@Nullable Exchange oldExchange, @Nullable Exchange newExchange); /** * Aggregates an old and new exchange together to create a single combined exchange. @@ -82,7 +84,8 @@ public interface AggregationStrategy { * @return a combined composite of the two exchanges, return either the old or new exchange from the * input parameters; favor returning the old exchange whenever possible) */ - default Exchange aggregate(Exchange oldExchange, Exchange newExchange, Exchange inputExchange) { + default @Nullable Exchange aggregate( + @Nullable Exchange oldExchange, @Nullable Exchange newExchange, Exchange inputExchange) { return aggregate(oldExchange, newExchange); } @@ -105,7 +108,7 @@ default boolean canPreComplete() { * @return true to complete current group and start a new group, or false to keep * using current */ - default boolean preComplete(Exchange oldExchange, Exchange newExchange) { + default boolean preComplete(@Nullable Exchange oldExchange, @Nullable Exchange newExchange) { return false; } diff --git a/core/camel-api/src/main/java/org/apache/camel/BinaryPredicate.java b/core/camel-api/src/main/java/org/apache/camel/BinaryPredicate.java index 2626fbb25423c..604904d01bc83 100644 --- a/core/camel-api/src/main/java/org/apache/camel/BinaryPredicate.java +++ b/core/camel-api/src/main/java/org/apache/camel/BinaryPredicate.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * A predicate which evaluates a binary expression. *

@@ -55,6 +57,7 @@ public interface BinaryPredicate extends Predicate { * @param exchange the message exchange * @return null if the predicate matches. */ + @Nullable String matchesReturningFailureMessage(Exchange exchange); } diff --git a/core/camel-api/src/main/java/org/apache/camel/CamelAuthorizationException.java b/core/camel-api/src/main/java/org/apache/camel/CamelAuthorizationException.java index 4afeac7acc24c..2550165980540 100644 --- a/core/camel-api/src/main/java/org/apache/camel/CamelAuthorizationException.java +++ b/core/camel-api/src/main/java/org/apache/camel/CamelAuthorizationException.java @@ -16,13 +16,15 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * An exception thrown for either authentication or authorization errors occurring in a Camel exchange. Intended to be * used when a user is denied an action and Camel should not process the message as a result. */ public class CamelAuthorizationException extends CamelExchangeException { - private final String policyId; + private final @Nullable String policyId; public CamelAuthorizationException(String message, Exchange exchange) { super(message, exchange); @@ -34,7 +36,7 @@ public CamelAuthorizationException(String message, Exchange exchange, Throwable policyId = exchange.getIn().getHeader(Exchange.AUTHENTICATION_FAILURE_POLICY_ID, String.class); } - public String getPolicyId() { + public @Nullable String getPolicyId() { return policyId; } diff --git a/core/camel-api/src/main/java/org/apache/camel/CamelContext.java b/core/camel-api/src/main/java/org/apache/camel/CamelContext.java index fcf36be190b1f..203b7480e9f37 100644 --- a/core/camel-api/src/main/java/org/apache/camel/CamelContext.java +++ b/core/camel-api/src/main/java/org/apache/camel/CamelContext.java @@ -57,6 +57,7 @@ import org.apache.camel.spi.ValidatorRegistry; import org.apache.camel.support.jsse.SSLContextParameters; import org.apache.camel.vault.VaultConfiguration; +import org.jspecify.annotations.Nullable; /** * Interface used to represent the CamelContext used to configure routes and the policies to use during message @@ -110,6 +111,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio * * @return the description, or null if no description has been set. */ + @Nullable String getDescription(); /** @@ -149,12 +151,13 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio * * @return the management name */ + @Nullable String getManagementName(); /** * Sets the name this {@link CamelContext} will be registered in JMX. */ - void setManagementName(String name); + void setManagementName(@Nullable String name); /** * Gets the version of this CamelContext. @@ -275,6 +278,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio * @param filter the filter * @return the service if found or null if none found */ + @Nullable Service hasService(java.util.function.Predicate filter); /** @@ -283,7 +287,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio * @param type the class type * @return the service instance or null if not already added. */ - T hasService(Class type); + @Nullable T hasService(Class type); /** * Has the given service type already been added to this CamelContext? @@ -343,6 +347,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio * @param componentName the name of the component * @return the registered Component or null if not registered */ + @Nullable Component hasComponent(String componentName); /** @@ -402,6 +407,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio * @param componentName the component name to remove * @return the previously added component or null if it had not been previously added. */ + @Nullable Component removeComponent(String componentName); // Endpoint Management Methods @@ -458,6 +464,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio * @param uri the URI of the endpoint * @return the registered endpoint or null if not registered */ + @Nullable Endpoint hasEndpoint(String uri); /** @@ -468,6 +475,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio * @return the old endpoint that was previously registered or null if none was registered * @throws Exception if the new endpoint could not be started or the old endpoint could not be stopped */ + @Nullable Endpoint addEndpoint(String uri, Endpoint endpoint) throws Exception; /** @@ -563,6 +571,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio * @param id id of the route * @return the route or null if not found */ + @Nullable Route getRoute(String id); /** @@ -571,6 +580,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio * @param id id of the processor * @return the processor or null if not found */ + @Nullable Processor getProcessor(String id); /** @@ -581,7 +591,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio * @return the processor or null if not found * @throws java.lang.ClassCastException is thrown if the type is not correct type */ - T getProcessor(String id, Class type); + @Nullable T getProcessor(String id, Class type); /** * Adds a collection of routes to this CamelContext using the given builder to build them. @@ -654,7 +664,8 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio * @return the id of the route added (for example when an id was auto assigned) * @throws Exception is thrown if error creating and adding the new route */ - String addRouteFromTemplate(String routeId, String routeTemplateId, Map parameters) throws Exception; + String addRouteFromTemplate(@Nullable String routeId, String routeTemplateId, Map parameters) + throws Exception; /** * Adds a new route from a given route template. @@ -671,7 +682,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio */ @Deprecated(since = "4.14.0") String addRouteFromTemplate( - String routeId, String routeTemplateId, String prefixId, + @Nullable String routeId, String routeTemplateId, @Nullable String prefixId, Map parameters) throws Exception; @@ -690,7 +701,7 @@ String addRouteFromTemplate( * @throws Exception is thrown if error creating and adding the new route */ String addRouteFromTemplate( - String routeId, String routeTemplateId, String prefixId, String group, + @Nullable String routeId, String routeTemplateId, @Nullable String prefixId, @Nullable String group, Map parameters) throws Exception; @@ -709,7 +720,8 @@ String addRouteFromTemplate( */ @Deprecated(since = "4.14.0") String addRouteFromTemplate( - String routeId, String routeTemplateId, String prefixId, RouteTemplateContext routeTemplateContext) + @Nullable String routeId, String routeTemplateId, @Nullable String prefixId, + RouteTemplateContext routeTemplateContext) throws Exception; /** @@ -727,7 +739,8 @@ String addRouteFromTemplate( * @throws Exception is thrown if error creating and adding the new route */ String addRouteFromTemplate( - String routeId, String routeTemplateId, String prefixId, String group, RouteTemplateContext routeTemplateContext) + @Nullable String routeId, String routeTemplateId, @Nullable String prefixId, @Nullable String group, + RouteTemplateContext routeTemplateContext) throws Exception; /** @@ -744,7 +757,7 @@ String addRouteFromTemplate( */ @Deprecated(since = "4.14.0") String addRouteFromKamelet( - String routeId, String routeTemplateId, String prefixId, + @Nullable String routeId, String routeTemplateId, @Nullable String prefixId, String parentRouteId, String parentProcessorId, Map parameters) throws Exception; @@ -763,7 +776,7 @@ String addRouteFromKamelet( * @throws Exception is thrown if error creating and adding the new route */ String addRouteFromKamelet( - String routeId, String routeTemplateId, String prefixId, String group, + @Nullable String routeId, String routeTemplateId, @Nullable String prefixId, @Nullable String group, String parentRouteId, String parentProcessorId, Map parameters) throws Exception; @@ -805,6 +818,7 @@ String addRouteFromKamelet( * * @return the configuration, or null if none has been configured. */ + @Nullable RestConfiguration getRestConfiguration(); /** @@ -819,6 +833,7 @@ String addRouteFromKamelet( * * @return the configuration, or null if none has been configured. */ + @Nullable VaultConfiguration getVaultConfiguration(); /** @@ -875,7 +890,7 @@ String addRouteFromKamelet( * @param type the registry type such as org.apache.camel.impl.JndiRegistry * @return the registry, or null if the given type was not found as a registry implementation */ - T getRegistry(Class type); + @Nullable T getRegistry(Class type); /** * Returns the injector used to instantiate objects by type @@ -932,6 +947,7 @@ String addRouteFromKamelet( * repository. If no repo-id is provided, then global repository will be used. * @return the variable, or null if not found. */ + @Nullable Object getVariable(String name); /** @@ -942,7 +958,7 @@ String addRouteFromKamelet( * @param type the type to convert the variable to * @return the variable, or null if not found. */ - T getVariable(String name, Class type); + @Nullable T getVariable(String name, Class type); /** * Sets a variable @@ -1086,6 +1102,7 @@ String addRouteFromKamelet( * @param name the data format name or a reference to it in the {@link Registry} * @return the resolved data format, or null if not found */ + @Nullable DataFormat resolveDataFormat(String name); /** @@ -1094,6 +1111,7 @@ String addRouteFromKamelet( * @param name the data format name or a reference to a data format factory in the {@link Registry} * @return the created data format, or null if not found */ + @Nullable DataFormat createDataFormat(String name); /** @@ -1109,6 +1127,7 @@ String addRouteFromKamelet( * @param name the transformer name, usually a combination of some scheme and name. * @return the resolved transformer, or null if not found */ + @Nullable Transformer resolveTransformer(String name); /** @@ -1118,6 +1137,7 @@ String addRouteFromKamelet( * @param to to data type * @return the resolved transformer, or null if not found */ + @Nullable Transformer resolveTransformer(DataType from, DataType to); /** @@ -1133,6 +1153,7 @@ String addRouteFromKamelet( * @param type the data type * @return the resolved validator, or null if not found */ + @Nullable Validator resolveValidator(DataType type); /** @@ -1176,6 +1197,7 @@ String addRouteFromKamelet( * * @return the string value of the global option */ + @Nullable String getGlobalOption(String key); /** @@ -1435,7 +1457,7 @@ String addRouteFromKamelet( * Multiple patterns can be specified separated by comma, as example, to exclude all the routes starting from kafka * or jms use: kafka,jms. */ - void setAutoStartupExcludePattern(String autoStartupExcludePattern); + void setAutoStartupExcludePattern(@Nullable String autoStartupExcludePattern); /** * Used for exclusive filtering of routes to not automatically start with Camel starts. @@ -1445,6 +1467,7 @@ String addRouteFromKamelet( * Multiple patterns can be specified separated by comma, as example, to exclude all the routes starting from kafka * or jms use: kafka,jms. */ + @Nullable String getAutoStartupExcludePattern(); /** @@ -1545,6 +1568,7 @@ String addRouteFromKamelet( * */ @Deprecated(since = "4.19.0") + @Nullable String getMDCLoggingKeysPattern(); /** @@ -1565,7 +1589,7 @@ String addRouteFromKamelet( * @param pattern the pattern */ @Deprecated(since = "4.19.0") - void setMDCLoggingKeysPattern(String pattern); + void setMDCLoggingKeysPattern(@Nullable String pattern); /** * To use a custom tracing logging format. @@ -1616,6 +1640,7 @@ String addRouteFromKamelet( * * @return xml, or yaml if dumping is enabled */ + @Nullable String getDumpRoutes(); /** @@ -1630,7 +1655,7 @@ String addRouteFromKamelet( * @param format xml or yaml (additional configuration can be specified using query parameters, eg * ?include=all&uriAsParameters=true) */ - void setDumpRoutes(String format); + void setDumpRoutes(@Nullable String format); /** * Whether to enable using data type on Camel messages. @@ -1679,6 +1704,7 @@ String addRouteFromKamelet( /** * Gets the {@link org.apache.camel.spi.RuntimeEndpointRegistry} to use, or null if none is in use. */ + @Nullable RuntimeEndpointRegistry getRuntimeEndpointRegistry(); /** @@ -1694,6 +1720,7 @@ String addRouteFromKamelet( /** * Gets the global SSL context parameters if configured. */ + @Nullable SSLContextParameters getSSLContextParameters(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/CamelException.java b/core/camel-api/src/main/java/org/apache/camel/CamelException.java index d4031cc992948..b4a608801f112 100644 --- a/core/camel-api/src/main/java/org/apache/camel/CamelException.java +++ b/core/camel-api/src/main/java/org/apache/camel/CamelException.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * Base class for all Camel checked exceptions typically thrown by a {@link Processor} */ @@ -24,15 +26,15 @@ public class CamelException extends Exception { public CamelException() { } - public CamelException(String message) { + public CamelException(@Nullable String message) { super(message); } - public CamelException(String message, Throwable cause) { + public CamelException(@Nullable String message, @Nullable Throwable cause) { super(message, cause); } - public CamelException(Throwable cause) { + public CamelException(@Nullable Throwable cause) { super(cause); } } diff --git a/core/camel-api/src/main/java/org/apache/camel/CamelExchangeException.java b/core/camel-api/src/main/java/org/apache/camel/CamelExchangeException.java index 57e150da03aa4..3801e0a70625c 100644 --- a/core/camel-api/src/main/java/org/apache/camel/CamelExchangeException.java +++ b/core/camel-api/src/main/java/org/apache/camel/CamelExchangeException.java @@ -18,13 +18,15 @@ import java.io.Serial; +import org.jspecify.annotations.Nullable; + /** * An exception caused by a specific message {@link Exchange} */ public class CamelExchangeException extends CamelException { private static final @Serial long serialVersionUID = -8721487431101572630L; // exchange is not guaranteed to be serializable so we set it as transient - private final transient Exchange exchange; + private final transient @Nullable Exchange exchange; public CamelExchangeException(String message, Exchange exchange) { super(CamelExchangeException.createExceptionMessage(message, exchange, null)); @@ -39,7 +41,7 @@ public CamelExchangeException(String message, Exchange exchange, Throwable cause /** * Returns the exchange which caused the exception */ - public Exchange getExchange() { + public @Nullable Exchange getExchange() { return exchange; } @@ -53,7 +55,8 @@ public Exchange getExchange() { * @param cause the caused exception * @return an error message (without stacktrace from exception) */ - public static String createExceptionMessage(String message, Exchange exchange, Throwable cause) { + public static String createExceptionMessage( + @Nullable String message, @Nullable Exchange exchange, @Nullable Throwable cause) { StringBuilder sb = new StringBuilder(1024); if (message != null) { sb.append(message); diff --git a/core/camel-api/src/main/java/org/apache/camel/CatalogCamelContext.java b/core/camel-api/src/main/java/org/apache/camel/CatalogCamelContext.java index 84063e4c6afac..2a71e3fd9b713 100644 --- a/core/camel-api/src/main/java/org/apache/camel/CatalogCamelContext.java +++ b/core/camel-api/src/main/java/org/apache/camel/CatalogCamelContext.java @@ -20,6 +20,7 @@ import org.apache.camel.spi.DataFormat; import org.apache.camel.spi.Language; +import org.jspecify.annotations.Nullable; /** * Catalog level interface for the {@link CamelContext} @@ -31,6 +32,7 @@ public interface CatalogCamelContext extends CamelContext { * * @return the json or null if the component is not built with JSON schema support */ + @Nullable String getComponentParameterJsonSchema(String componentName) throws IOException; /** @@ -38,6 +40,7 @@ public interface CatalogCamelContext extends CamelContext { * * @return the json or null if the data format does not exist */ + @Nullable String getDataFormatParameterJsonSchema(String dataFormatName) throws IOException; /** @@ -45,6 +48,7 @@ public interface CatalogCamelContext extends CamelContext { * * @return the json or null if the language does not exist */ + @Nullable String getLanguageParameterJsonSchema(String languageName) throws IOException; /** @@ -53,6 +57,7 @@ public interface CatalogCamelContext extends CamelContext { * * @return the json or null if the transformer does not exist */ + @Nullable String getTransformerParameterJsonSchema(String transformerName) throws IOException; /** @@ -61,6 +66,7 @@ public interface CatalogCamelContext extends CamelContext { * * @return the json or null if the dev-console does not exist */ + @Nullable String getDevConsoleParameterJsonSchema(String devConsoleName) throws IOException; /** @@ -68,6 +74,7 @@ public interface CatalogCamelContext extends CamelContext { * * @return the json or null if the EIP does not exist */ + @Nullable String getEipParameterJsonSchema(String eipName) throws IOException; /** @@ -75,6 +82,7 @@ public interface CatalogCamelContext extends CamelContext { * * @return the json or null if the pojo bean does not exist */ + @Nullable String getPojoBeanParameterJsonSchema(String name) throws IOException; } diff --git a/core/camel-api/src/main/java/org/apache/camel/Channel.java b/core/camel-api/src/main/java/org/apache/camel/Channel.java index 9778df21139ce..19018fb37161e 100644 --- a/core/camel-api/src/main/java/org/apache/camel/Channel.java +++ b/core/camel-api/src/main/java/org/apache/camel/Channel.java @@ -20,6 +20,7 @@ import org.apache.camel.spi.ErrorHandler; import org.apache.camel.spi.InterceptStrategy; +import org.jspecify.annotations.Nullable; /** * Channel acts as a channel between {@link Processor}s in the route graph. @@ -35,10 +36,10 @@ public interface Channel extends AsyncProcessor, Navigate { void initChannel( Route route, NamedNode definition, - NamedNode childDefinition, + @Nullable NamedNode childDefinition, List interceptors, Processor nextProcessor, - NamedRoute routeDefinition, + @Nullable NamedRoute routeDefinition, boolean first) throws Exception; @@ -54,6 +55,7 @@ void initChannel( * * @return the error handler, or null if no error handler is used. */ + @Nullable Processor getErrorHandler(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/Component.java b/core/camel-api/src/main/java/org/apache/camel/Component.java index e4a01005e944e..84313832e6169 100644 --- a/core/camel-api/src/main/java/org/apache/camel/Component.java +++ b/core/camel-api/src/main/java/org/apache/camel/Component.java @@ -23,6 +23,7 @@ import org.apache.camel.component.extension.ComponentExtension; import org.apache.camel.spi.PropertyConfigurer; +import org.jspecify.annotations.Nullable; /** * A component is a factory of {@link Endpoint} objects. @@ -40,6 +41,7 @@ public interface Component extends CamelContextAware, Service { * @throws Exception is thrown if error creating the endpoint * @see #useRawUri() */ + @Nullable Endpoint createEndpoint(String uri) throws Exception; /** @@ -54,6 +56,7 @@ public interface Component extends CamelContextAware, Service { * @throws Exception is thrown if error creating the endpoint * @see #useRawUri() */ + @Nullable Endpoint createEndpoint(String uri, Map parameters) throws Exception; /** @@ -70,7 +73,7 @@ public interface Component extends CamelContextAware, Service { * * @return the configurer, or null if the component does not support using property configurer. */ - default PropertyConfigurer getComponentPropertyConfigurer() { + default @Nullable PropertyConfigurer getComponentPropertyConfigurer() { return null; } @@ -79,7 +82,7 @@ default PropertyConfigurer getComponentPropertyConfigurer() { * * @return the configurer, or null if the endpoint does not support using property configurer. */ - default PropertyConfigurer getEndpointPropertyConfigurer() { + default @Nullable PropertyConfigurer getEndpointPropertyConfigurer() { return null; } @@ -116,7 +119,7 @@ static T trySetComponent(T object, Component component) { /** * Gets the default name of the component. */ - default String getDefaultName() { + default @Nullable String getDefaultName() { return null; } diff --git a/core/camel-api/src/main/java/org/apache/camel/ComponentAware.java b/core/camel-api/src/main/java/org/apache/camel/ComponentAware.java index 1fbe8a7c220ef..b26952df5cee2 100644 --- a/core/camel-api/src/main/java/org/apache/camel/ComponentAware.java +++ b/core/camel-api/src/main/java/org/apache/camel/ComponentAware.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * An interface to represent an object which wishes to be injected with a {@link Component}. */ @@ -33,6 +35,7 @@ public interface ComponentAware { * * @return the component */ + @Nullable Component getComponent(); /** @@ -42,7 +45,7 @@ public interface ComponentAware { * @return an instance of the underlying concrete Component as the required type. * @throws IllegalArgumentException if the component class can't be cast to required type, */ - default T getComponent(Class type) { + default @Nullable T getComponent(Class type) { final Component component = getComponent(); if (component == null) { diff --git a/core/camel-api/src/main/java/org/apache/camel/Consumer.java b/core/camel-api/src/main/java/org/apache/camel/Consumer.java index b1a6ba611a719..b6b29a1642193 100644 --- a/core/camel-api/src/main/java/org/apache/camel/Consumer.java +++ b/core/camel-api/src/main/java/org/apache/camel/Consumer.java @@ -17,6 +17,7 @@ package org.apache.camel; import org.apache.camel.spi.UnitOfWork; +import org.jspecify.annotations.Nullable; /** * A consumer of message exchanges from an {@link Endpoint}. @@ -62,7 +63,7 @@ public interface Consumer extends Service, EndpointAware { * @param autoRelease whether the exchange was created with auto release * @return the default callback */ - default AsyncCallback defaultConsumerCallback(Exchange exchange, boolean autoRelease) { + default @Nullable AsyncCallback defaultConsumerCallback(Exchange exchange, boolean autoRelease) { return null; } diff --git a/core/camel-api/src/main/java/org/apache/camel/ConsumerTemplate.java b/core/camel-api/src/main/java/org/apache/camel/ConsumerTemplate.java index 08e29fb4f6e91..1900c8610fcb2 100644 --- a/core/camel-api/src/main/java/org/apache/camel/ConsumerTemplate.java +++ b/core/camel-api/src/main/java/org/apache/camel/ConsumerTemplate.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * Template for working with Camel and consuming {@link Message} instances in an {@link Exchange} from an * {@link Endpoint}.
@@ -112,6 +114,7 @@ public interface ConsumerTemplate extends Service { * @return the returned exchange, or null if no response * @see #doneUoW(Exchange) */ + @Nullable Exchange receive(String endpointUri, long timeout); /** @@ -124,6 +127,7 @@ public interface ConsumerTemplate extends Service { * @return the returned exchange, or null if no response * @see #doneUoW(Exchange) */ + @Nullable Exchange receive(Endpoint endpoint, long timeout); /** @@ -134,6 +138,7 @@ public interface ConsumerTemplate extends Service { * @param endpointUri the endpoint to receive from * @return the returned exchange, or null if no response */ + @Nullable Exchange receiveNoWait(String endpointUri); /** @@ -144,6 +149,7 @@ public interface ConsumerTemplate extends Service { * @param endpoint the endpoint to receive from * @return the returned exchange, or null if no response */ + @Nullable Exchange receiveNoWait(Endpoint endpoint); /** @@ -169,6 +175,7 @@ public interface ConsumerTemplate extends Service { * @param timeout timeout in millis to wait for a response * @return the returned response body, or null if no response */ + @Nullable Object receiveBody(String endpointUri, long timeout); /** @@ -178,6 +185,7 @@ public interface ConsumerTemplate extends Service { * @param timeout timeout in millis to wait for a response * @return the returned response body, or null if no response */ + @Nullable Object receiveBody(Endpoint endpoint, long timeout); /** @@ -186,6 +194,7 @@ public interface ConsumerTemplate extends Service { * @param endpointUri the endpoint to receive from * @return the returned response body, or null if no response */ + @Nullable Object receiveBodyNoWait(String endpointUri); /** @@ -194,6 +203,7 @@ public interface ConsumerTemplate extends Service { * @param endpoint the endpoint to receive from * @return the returned response body, or null if no response */ + @Nullable Object receiveBodyNoWait(Endpoint endpoint); /** @@ -222,7 +232,7 @@ public interface ConsumerTemplate extends Service { * @param type the expected response type * @return the returned response body, or null if no response */ - T receiveBody(String endpointUri, long timeout, Class type); + @Nullable T receiveBody(String endpointUri, long timeout, Class type); /** * Receives from the endpoint, waiting until there is a response or the timeout occurs @@ -232,7 +242,7 @@ public interface ConsumerTemplate extends Service { * @param type the expected response type * @return the returned response body, or null if no response */ - T receiveBody(Endpoint endpoint, long timeout, Class type); + @Nullable T receiveBody(Endpoint endpoint, long timeout, Class type); /** * Receives from the endpoint, not waiting for a response if non exists. @@ -241,7 +251,7 @@ public interface ConsumerTemplate extends Service { * @param type the expected response type * @return the returned response body, or null if no response */ - T receiveBodyNoWait(String endpointUri, Class type); + @Nullable T receiveBodyNoWait(String endpointUri, Class type); /** * Receives from the endpoint, not waiting for a response if non exists. @@ -250,7 +260,7 @@ public interface ConsumerTemplate extends Service { * @param type the expected response type * @return the returned response body, or null if no response */ - T receiveBodyNoWait(Endpoint endpoint, Class type); + @Nullable T receiveBodyNoWait(Endpoint endpoint, Class type); /** * If you have used any of the receive methods which returns a {@link Exchange} type then you need to diff --git a/core/camel-api/src/main/java/org/apache/camel/DynamicPollingConsumer.java b/core/camel-api/src/main/java/org/apache/camel/DynamicPollingConsumer.java index c939c60737566..bc661cbc8bdee 100644 --- a/core/camel-api/src/main/java/org/apache/camel/DynamicPollingConsumer.java +++ b/core/camel-api/src/main/java/org/apache/camel/DynamicPollingConsumer.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * A {@link PollingConsumer} that are used by dynamic Poll and PollEnrich EIPs to facilitate components that can use * information from the current {@link Exchange} during the poll. @@ -35,6 +37,7 @@ public interface DynamicPollingConsumer extends PollingConsumer { * * @return the message exchange received. */ + @Nullable Exchange receive(Exchange exchange); /** @@ -46,6 +49,7 @@ public interface DynamicPollingConsumer extends PollingConsumer { * * @return the message exchange if one is immediately available otherwise null */ + @Nullable Exchange receiveNoWait(Exchange exchange); /** @@ -61,5 +65,6 @@ public interface DynamicPollingConsumer extends PollingConsumer { * @return the message exchange if one was available within the timeout period, or null if the * timeout expired */ + @Nullable Exchange receive(Exchange exchange, long timeout); } diff --git a/core/camel-api/src/main/java/org/apache/camel/Exchange.java b/core/camel-api/src/main/java/org/apache/camel/Exchange.java index 55ec9532b5823..43f47bcc57318 100644 --- a/core/camel-api/src/main/java/org/apache/camel/Exchange.java +++ b/core/camel-api/src/main/java/org/apache/camel/Exchange.java @@ -22,6 +22,7 @@ import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UnitOfWork; import org.apache.camel.spi.annotations.ConstantProvider; +import org.jspecify.annotations.Nullable; /** * An Exchange is the message container holding the information during the entire routing of a {@link Message} received @@ -343,6 +344,7 @@ public interface Exchange extends VariableAware { * @param key the exchange key * @return the value of the given property or null if there is no property for the given key */ + @Nullable Object getProperty(ExchangePropertyKey key); /** @@ -353,7 +355,7 @@ public interface Exchange extends VariableAware { * @return the value of the given property or null if there is no property for the given name or * null if it cannot be converted to the given type */ - T getProperty(ExchangePropertyKey key, Class type); + @Nullable T getProperty(ExchangePropertyKey key, Class type); /** * Returns a property associated with this exchange by name and specifying the type required @@ -364,7 +366,7 @@ public interface Exchange extends VariableAware { * @return the value of the given property or defaultValue if there is no property for the * given name or null if it cannot be converted to the given type */ - T getProperty(ExchangePropertyKey key, Object defaultValue, Class type); + @Nullable T getProperty(ExchangePropertyKey key, Object defaultValue, Class type); /** * Sets a property on the exchange @@ -372,7 +374,7 @@ public interface Exchange extends VariableAware { * @param key the exchange key * @param value to associate with the name */ - void setProperty(ExchangePropertyKey key, Object value); + void setProperty(ExchangePropertyKey key, @Nullable Object value); /** * Removes the given property on the exchange @@ -380,6 +382,7 @@ public interface Exchange extends VariableAware { * @param key the exchange key * @return the old value of the property */ + @Nullable Object removeProperty(ExchangePropertyKey key); /** @@ -388,6 +391,7 @@ public interface Exchange extends VariableAware { * @param name the name of the property * @return the value of the given property or null if there is no property for the given name */ + @Nullable Object getProperty(String name); /** @@ -398,7 +402,7 @@ public interface Exchange extends VariableAware { * @return the value of the given property or null if there is no property for the given name or * null if it cannot be converted to the given type */ - T getProperty(String name, Class type); + @Nullable T getProperty(String name, Class type); /** * Returns a property associated with this exchange by name and specifying the type required @@ -409,7 +413,7 @@ public interface Exchange extends VariableAware { * @return the value of the given property or defaultValue if there is no property for the * given name or null if it cannot be converted to the given type */ - T getProperty(String name, Object defaultValue, Class type); + @Nullable T getProperty(String name, Object defaultValue, Class type); /** * Sets a property on the exchange @@ -417,7 +421,7 @@ public interface Exchange extends VariableAware { * @param name of the property * @param value to associate with the name */ - void setProperty(String name, Object value); + void setProperty(String name, @Nullable Object value); /** * Removes the given property on the exchange @@ -425,6 +429,7 @@ public interface Exchange extends VariableAware { * @param name of the property * @return the old value of the property */ + @Nullable Object removeProperty(String name); /** @@ -475,6 +480,7 @@ public interface Exchange extends VariableAware { * repository. If no repo-id is provided, then variables will be from the current exchange. * @return the value of the given variable or null if there is no variable for the given name */ + @Nullable Object getVariable(String name); /** @@ -486,7 +492,7 @@ public interface Exchange extends VariableAware { * @return the value of the given variable or null if there is no variable for the given name or * null if it cannot be converted to the given type */ - T getVariable(String name, Class type); + @Nullable T getVariable(String name, Class type); /** * Returns a variable by name and specifying the type required @@ -498,7 +504,7 @@ public interface Exchange extends VariableAware { * @return the value of the given variable or defaultValue if there is no variable for the * given name or null if it cannot be converted to the given type */ - T getVariable(String name, Object defaultValue, Class type); + @Nullable T getVariable(String name, Object defaultValue, Class type); /** * Sets a variable on the exchange @@ -507,7 +513,7 @@ public interface Exchange extends VariableAware { * If no repo-id is provided, then variables will be stored in the current exchange. * @param value the value of the variable */ - void setVariable(String name, Object value); + void setVariable(String name, @Nullable Object value); /** * Removes the given variable @@ -518,6 +524,7 @@ public interface Exchange extends VariableAware { * repository. If no repo-id is provided, then the variable from the current exchange will be removed * @return the old value of the variable, or null if there was no variable for the given name */ + @Nullable Object removeVariable(String name); /** @@ -554,7 +561,7 @@ public interface Exchange extends VariableAware { * @param type the given type * @return the message as the given type or null if not possible to covert to given type */ - T getMessage(Class type); + @Nullable T getMessage(Class type); /** * Replace the current message instance. @@ -569,7 +576,7 @@ public interface Exchange extends VariableAware { * @param type the given type * @return the message as the given type or null if not possible to covert to given type */ - T getIn(Class type); + @Nullable T getIn(Class type); /** * Sets the inbound message instance @@ -611,7 +618,7 @@ public interface Exchange extends VariableAware { * @deprecated use {@link #getMessage(Class)} */ @Deprecated(since = "3.0.0") - T getOut(Class type); + @Nullable T getOut(Class type); /** * Returns whether an OUT message has been set or not. @@ -636,6 +643,7 @@ public interface Exchange extends VariableAware { * * @return the exception (or null if no faults) */ + @Nullable Exception getException(); /** @@ -649,7 +657,7 @@ public interface Exchange extends VariableAware { * @param type the exception type * @return the exception (or null if no caused exception matched) */ - T getException(Class type); + @Nullable T getException(Class type); /** * Sets the exception associated with this exchange @@ -659,7 +667,7 @@ public interface Exchange extends VariableAware { * * @param t the caused exception */ - void setException(Throwable t); + void setException(@Nullable Throwable t); /** * Returns true if this exchange failed due to an exception @@ -741,6 +749,7 @@ public interface Exchange extends VariableAware { * getContext().getRoute(getFromRouteId()).getEndpoint() * */ + @Nullable Endpoint getFromEndpoint(); /** @@ -750,11 +759,13 @@ public interface Exchange extends VariableAware { * Note: In case this message exchange has been cloned through another parent message exchange then this method * would return the fromRouteId property of that exchange. */ + @Nullable String getFromRouteId(); /** * Returns the unit of work that this exchange belongs to; which may map to zero, one or more physical transactions */ + @Nullable UnitOfWork getUnitOfWork(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/ExchangeExtension.java b/core/camel-api/src/main/java/org/apache/camel/ExchangeExtension.java index 7f65b63e4a875..e4f79f3c9651e 100644 --- a/core/camel-api/src/main/java/org/apache/camel/ExchangeExtension.java +++ b/core/camel-api/src/main/java/org/apache/camel/ExchangeExtension.java @@ -22,6 +22,7 @@ import org.apache.camel.spi.Synchronization; import org.apache.camel.spi.UnitOfWork; +import org.jspecify.annotations.Nullable; /* * {@link Exchange} extensions which contains the methods and APIs that are not intended for Camel end users but @@ -36,7 +37,7 @@ public interface ExchangeExtension { * @param type the given type * @return the message if exists with the given type, otherwise null. */ - T getInOrNull(Class type); + @Nullable T getInOrNull(Class type); /** * Sets the endpoint which originated this message exchange. This method should typically only be called by @@ -47,6 +48,7 @@ public interface ExchangeExtension { /** * Returns the endpoint which originated this message exchange. See {@link Exchange#getFromEndpoint()} for details. */ + @Nullable Endpoint getFromEndpoint(); /** @@ -58,7 +60,7 @@ public interface ExchangeExtension { /** * Sets the unit of work that this exchange belongs to; which may map to zero, one or more physical transactions */ - void setUnitOfWork(UnitOfWork unitOfWork); + void setUnitOfWork(@Nullable UnitOfWork unitOfWork); /** * Is stream caching disabled on the given exchange @@ -94,12 +96,13 @@ public interface ExchangeExtension { /** * Whether the exchange has been handled by the error handler. This is used internally by Camel. */ + @Nullable Boolean getErrorHandlerHandled(); /** * Used to signal that this exchange has been handled by the error handler. This is used internally by Camel. */ - void setErrorHandlerHandled(Boolean errorHandlerHandled); + void setErrorHandlerHandled(@Nullable Boolean errorHandlerHandled); /** * To control whether the exchange can accept being interrupted currently. @@ -155,34 +158,37 @@ public interface ExchangeExtension { /** * Sets the history node id (the current processor that will process the exchange) */ - void setHistoryNodeId(String historyNodeId); + void setHistoryNodeId(@Nullable String historyNodeId); /** * Gets the history node id (the current processor that will process the exchange) */ + @Nullable String getHistoryNodeId(); /** * Gets the history node source:line-number where the node is located in the source code (the current processor that * will process the exchange). */ + @Nullable String getHistoryNodeSource(); /** * Sets the history node source:line-number where the node is located in the source code (the current processor that * will process the exchange). */ - void setHistoryNodeSource(String historyNodeSource); + void setHistoryNodeSource(@Nullable String historyNodeSource); /** * Gets the history node label (the current processor that will process the exchange) */ + @Nullable String getHistoryNodeLabel(); /** * Sets the history node label (the current processor that will process the exchange) */ - void setHistoryNodeLabel(String historyNodeLabel); + void setHistoryNodeLabel(@Nullable String historyNodeLabel); /** * Whether the exchange is currently used as event notification. @@ -241,7 +247,7 @@ public interface ExchangeExtension { * * @see SafeCopyProperty */ - T getSafeCopyProperty(String key, Class type); + @Nullable T getSafeCopyProperty(String key, Class type); /** * To set a property that must be copied specially (thread safe with deep cloning). @@ -275,6 +281,7 @@ public interface ExchangeExtension { *

* This is only used when pooled exchange is enabled for optimization and reducing object allocations. */ + @Nullable AsyncCallback getDefaultConsumerCallback(); /** @@ -282,7 +289,7 @@ public interface ExchangeExtension { *

* This is only used when pooled exchange is enabled for optimization and reducing object allocations. */ - void setDefaultConsumerCallback(AsyncCallback callback); + void setDefaultConsumerCallback(@Nullable AsyncCallback callback); /** * Returns whether the exchange has been failure handed diff --git a/core/camel-api/src/main/java/org/apache/camel/ExchangePropertyKey.java b/core/camel-api/src/main/java/org/apache/camel/ExchangePropertyKey.java index 491a48f3a2d06..3710e67f57140 100644 --- a/core/camel-api/src/main/java/org/apache/camel/ExchangePropertyKey.java +++ b/core/camel-api/src/main/java/org/apache/camel/ExchangePropertyKey.java @@ -17,6 +17,7 @@ package org.apache.camel; import org.apache.camel.spi.CircuitBreakerConstants; +import org.jspecify.annotations.Nullable; /** * An enum of common and known keys for exchange properties used by camel-core. @@ -100,7 +101,7 @@ public String getName() { return name; } - public static ExchangePropertyKey asExchangePropertyKey(String name) { + public static @Nullable ExchangePropertyKey asExchangePropertyKey(String name) { switch (name) { case Exchange.AGGREGATED_COMPLETED_BY: return AGGREGATED_COMPLETED_BY; diff --git a/core/camel-api/src/main/java/org/apache/camel/Expression.java b/core/camel-api/src/main/java/org/apache/camel/Expression.java index 3a34cfeef0199..0724391603385 100644 --- a/core/camel-api/src/main/java/org/apache/camel/Expression.java +++ b/core/camel-api/src/main/java/org/apache/camel/Expression.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * An expression provides a plugin strategy for evaluating * expressions on a message exchange. @@ -37,7 +39,7 @@ public interface Expression { * @param type the expected type of the evaluation result * @return the value of the expression */ - T evaluate(Exchange exchange, Class type); + @Nullable T evaluate(Exchange exchange, Class type); /** * Initialize the expression with the given camel context diff --git a/core/camel-api/src/main/java/org/apache/camel/ExpressionIllegalSyntaxException.java b/core/camel-api/src/main/java/org/apache/camel/ExpressionIllegalSyntaxException.java index 6102eda6c8de7..9a8ad03068c2c 100644 --- a/core/camel-api/src/main/java/org/apache/camel/ExpressionIllegalSyntaxException.java +++ b/core/camel-api/src/main/java/org/apache/camel/ExpressionIllegalSyntaxException.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * An exception thrown if the expression contains illegal syntax. */ @@ -27,7 +29,7 @@ public ExpressionIllegalSyntaxException(String expression) { this(expression, null); } - public ExpressionIllegalSyntaxException(String expression, Throwable cause) { + public ExpressionIllegalSyntaxException(String expression, @Nullable Throwable cause) { super("Illegal syntax: " + expression, cause); this.expression = expression; } diff --git a/core/camel-api/src/main/java/org/apache/camel/ExtendedCamelContext.java b/core/camel-api/src/main/java/org/apache/camel/ExtendedCamelContext.java index 6d288d3f881a9..7c5ea9f55671b 100644 --- a/core/camel-api/src/main/java/org/apache/camel/ExtendedCamelContext.java +++ b/core/camel-api/src/main/java/org/apache/camel/ExtendedCamelContext.java @@ -43,6 +43,7 @@ import org.apache.camel.spi.RouteController; import org.apache.camel.spi.RouteStartupOrder; import org.apache.camel.spi.StartupStepRecorder; +import org.jspecify.annotations.Nullable; /** * Extended {@link CamelContext} which contains the methods and APIs that are not primary intended for Camel end users @@ -60,28 +61,28 @@ public interface ExtendedCamelContext { */ void setName(String name); - default String getName() { + default @Nullable String getName() { return null; } /** * Sets the description of this Camel application. */ - void setDescription(String description); + void setDescription(@Nullable String description); - default String getDescription() { + default @Nullable String getDescription() { return null; } /** * Sets the profile Camel should run as (dev,test,prod). */ - void setProfile(String profile); + void setProfile(@Nullable String profile); /** * The profile Camel should run as (dev,test,prod). Returns null if no profile has been set. */ - default String getProfile() { + default @Nullable String getProfile() { return null; } @@ -102,7 +103,7 @@ default String getProfile() { */ void setManagementMBeanAssembler(ManagementMBeanAssembler managementMBeanAssembler); - default Registry getRegistry() { + default @Nullable Registry getRegistry() { return null; } @@ -175,7 +176,7 @@ default T setupRoutes(Callable callable) throws Exception { * ScopedValue compatibility */ @Deprecated(since = "4.19.0") - void createRoute(String routeId); + void createRoute(@Nullable String routeId); /** * Indicates whether current thread is creating a route as part of starting Camel. @@ -185,6 +186,7 @@ default T setupRoutes(Callable callable) throws Exception { * @return the route id currently being created/started, or null if not. * @see #createRoute(String) */ + @Nullable String getCreateRoute(); /** @@ -233,7 +235,7 @@ default T createRoute(String routeId, Callable callable) throws Exception * {@link #createProcessor(String, Callable)} for ScopedValue compatibility */ @Deprecated(since = "4.19.0") - void createProcessor(String processorId); + void createProcessor(@Nullable String processorId); /** * Indicates whether current thread is creating a processor as part of starting Camel. @@ -243,6 +245,7 @@ default T createRoute(String routeId, Callable callable) throws Exception * @return the current id of the processor being created * @see #createProcessor(String) */ + @Nullable String getCreateProcessor(); /** @@ -336,6 +339,7 @@ default T createProcessor(String processorId, Callable callable) throws E * @param uri the URI of the endpoint * @return the registered endpoint or null if not registered */ + @Nullable Endpoint hasEndpoint(NormalizedEndpointUri uri); /** @@ -509,11 +513,12 @@ default T createProcessor(String processorId, Callable callable) throws E * * @param options optional parameters to configure {@link org.apache.camel.spi.ManagementAgent}. */ - void setupManagement(Map options); + void setupManagement(@Nullable Map options); /** * Gets a list of {@link LogListener} (can be null if empty). */ + @Nullable Set getLogListeners(); /** @@ -577,6 +582,7 @@ default T createProcessor(String processorId, Callable callable) throws E /** * Gets the {@link EndpointUriFactory} for the given component name. */ + @Nullable EndpointUriFactory getEndpointUriFactory(String scheme); /** @@ -615,6 +621,7 @@ default RuntimeCamelCatalog getRuntimeCamelCatalog() { /** * Used during unit-testing where it is possible to specify a set of routes to exclude from discovery */ + @Nullable String getTestExcludeRoutes(); /** @@ -638,6 +645,7 @@ default RuntimeCamelCatalog getRuntimeCamelCatalog() { * * @return the base package name (can be null if not configured) */ + @Nullable String getBasePackageScan(); /** @@ -647,7 +655,7 @@ default RuntimeCamelCatalog getRuntimeCamelCatalog() { * * @param basePackageScan the base package name */ - void setBasePackageScan(String basePackageScan); + void setBasePackageScan(@Nullable String basePackageScan); /** * Camel comes with a default set of sensitive keywords which are automatically masked. This option allows to add @@ -655,6 +663,7 @@ default RuntimeCamelCatalog getRuntimeCamelCatalog() { * * @see org.apache.camel.util.SensitiveUtils */ + @Nullable String getAdditionalSensitiveKeywords(); /** @@ -663,7 +672,7 @@ default RuntimeCamelCatalog getRuntimeCamelCatalog() { * * @see org.apache.camel.util.SensitiveUtils */ - void setAdditionalSensitiveKeywords(String additionalSensitiveKeywords); + void setAdditionalSensitiveKeywords(@Nullable String additionalSensitiveKeywords); /** * Gets the {@link AutoMockInterceptStrategy} strategies. @@ -682,7 +691,7 @@ default RuntimeCamelCatalog getRuntimeCamelCatalog() { * @param type the type of the extension * @return the extension, or null if no extension has been installed. */ - T getContextPlugin(Class type); + @Nullable T getContextPlugin(Class type); /** * Whether a plugin of the given type is already in use diff --git a/core/camel-api/src/main/java/org/apache/camel/FailedToCreateRouteException.java b/core/camel-api/src/main/java/org/apache/camel/FailedToCreateRouteException.java index 8c02ef9dcc095..398df53ebb73e 100644 --- a/core/camel-api/src/main/java/org/apache/camel/FailedToCreateRouteException.java +++ b/core/camel-api/src/main/java/org/apache/camel/FailedToCreateRouteException.java @@ -17,14 +17,15 @@ package org.apache.camel; import org.apache.camel.util.URISupport; +import org.jspecify.annotations.Nullable; /** * Exception when failing to create a {@link org.apache.camel.Route}. */ public class FailedToCreateRouteException extends RuntimeCamelException { - private final String routeId; - private final String location; + private final @Nullable String routeId; + private final @Nullable String location; public FailedToCreateRouteException(String cause) { super("Failed to create route because: " + cause); @@ -32,14 +33,14 @@ public FailedToCreateRouteException(String cause) { this.location = null; } - public FailedToCreateRouteException(String routeId, String location, String route, String cause) { + public FailedToCreateRouteException(String routeId, @Nullable String location, String route, String cause) { super("Failed to create route: " + routeId + (location != null ? " (source: " + location + ")" : "") + ": " + getRouteMessage(route) + " because: " + cause); this.routeId = routeId; this.location = location; } - public FailedToCreateRouteException(String routeId, String location, String route, Throwable cause) { + public FailedToCreateRouteException(String routeId, @Nullable String location, String route, Throwable cause) { super("Failed to create route: " + routeId + (location != null ? " (source: " + location + ")" : "") + ": " + getRouteMessage(route) + " because: " + getExceptionMessage(cause), cause); @@ -47,7 +48,7 @@ public FailedToCreateRouteException(String routeId, String location, String rout this.location = location; } - public FailedToCreateRouteException(String routeId, String location, String route, String at, Throwable cause) { + public FailedToCreateRouteException(String routeId, @Nullable String location, String route, String at, Throwable cause) { super("Failed to create route: " + routeId + (location != null ? " (source: " + location + ")" : "") + " at: >>> " + at + " <<< in route: " + getRouteMessage(route) + " because: " + getExceptionMessage(cause), cause); @@ -55,11 +56,11 @@ public FailedToCreateRouteException(String routeId, String location, String rout this.location = location; } - public String getRouteId() { + public @Nullable String getRouteId() { return routeId; } - public String getLocation() { + public @Nullable String getLocation() { return location; } diff --git a/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java b/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java index cf6a1976dedfc..7aa438af701ff 100644 --- a/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java +++ b/core/camel-api/src/main/java/org/apache/camel/FailedToStartRouteException.java @@ -16,13 +16,15 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * Exception when failing to start a {@link Route}. */ public class FailedToStartRouteException extends RuntimeCamelException { private final String routeId; - private final String location; + private final @Nullable String location; public FailedToStartRouteException(String routeId, String message) { super("Failed to start route: " + routeId + " because: " + message); @@ -36,7 +38,7 @@ public FailedToStartRouteException(String routeId, String message, Throwable cau this.location = null; } - public FailedToStartRouteException(String routeId, String location, String message, Throwable cause) { + public FailedToStartRouteException(String routeId, @Nullable String location, String message, Throwable cause) { super("Failed to start route: " + routeId + (location != null ? " (source: " + location + ")" : "") + " because: " + message, cause); @@ -48,7 +50,7 @@ public String getRouteId() { return routeId; } - public String getLocation() { + public @Nullable String getLocation() { return location; } } diff --git a/core/camel-api/src/main/java/org/apache/camel/FluentProducerTemplate.java b/core/camel-api/src/main/java/org/apache/camel/FluentProducerTemplate.java index adf0a3b3f389e..faebfc69bfc3f 100644 --- a/core/camel-api/src/main/java/org/apache/camel/FluentProducerTemplate.java +++ b/core/camel-api/src/main/java/org/apache/camel/FluentProducerTemplate.java @@ -21,6 +21,7 @@ import java.util.function.Supplier; import org.apache.camel.util.ObjectHelper; +import org.jspecify.annotations.Nullable; /** * Template for working with Camel and sending {@link Message} instances in an {@link Exchange} to an {@link Endpoint} @@ -128,6 +129,7 @@ public interface FluentProducerTemplate extends Service { * * @return the default endpoint instance */ + @Nullable Endpoint getDefaultEndpoint(); /** @@ -189,7 +191,7 @@ public interface FluentProducerTemplate extends Service { * @param key the key of the header * @param value the value of the header */ - FluentProducerTemplate withHeader(String key, Object value); + FluentProducerTemplate withHeader(String key, @Nullable Object value); /** * Set the exchange properties @@ -210,7 +212,7 @@ public interface FluentProducerTemplate extends Service { * @param key the key of the exchange property * @param value the value of the exchange property */ - FluentProducerTemplate withExchangeProperty(String key, Object value); + FluentProducerTemplate withExchangeProperty(String key, @Nullable Object value); /** * Set the variables @@ -231,7 +233,7 @@ public interface FluentProducerTemplate extends Service { * @param key the key of the variable * @param value the value of the variable */ - FluentProducerTemplate withVariable(String key, Object value); + FluentProducerTemplate withVariable(String key, @Nullable Object value); /** * Set the message body @@ -241,7 +243,7 @@ public interface FluentProducerTemplate extends Service { * * @param body the body */ - FluentProducerTemplate withBody(Object body); + FluentProducerTemplate withBody(@Nullable Object body); /** * Set the message body after converting it to the given type @@ -252,7 +254,7 @@ public interface FluentProducerTemplate extends Service { * @param body the body * @param type the type which the body should be converted to */ - FluentProducerTemplate withBodyAs(Object body, Class type); + FluentProducerTemplate withBodyAs(@Nullable Object body, Class type); /** * To customize the producer template for advanced usage like to set the executor service to use. @@ -402,6 +404,7 @@ default FluentProducerTemplate to(EndpointProducerResolver resolver) { * @return the result * @throws CamelExecutionException is thrown if error occurred */ + @Nullable Object request() throws CamelExecutionException; /** @@ -411,7 +414,7 @@ default FluentProducerTemplate to(EndpointProducerResolver resolver) { * @return the result * @throws CamelExecutionException is thrown if error occurred */ - T request(Class type) throws CamelExecutionException; + @Nullable T request(Class type) throws CamelExecutionException; /** * Sends asynchronously to the given endpoint (InOut). diff --git a/core/camel-api/src/main/java/org/apache/camel/InvalidPropertyException.java b/core/camel-api/src/main/java/org/apache/camel/InvalidPropertyException.java index 490f81618b2a0..35e159f98bacf 100644 --- a/core/camel-api/src/main/java/org/apache/camel/InvalidPropertyException.java +++ b/core/camel-api/src/main/java/org/apache/camel/InvalidPropertyException.java @@ -16,15 +16,17 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * An exception caused when an invalid property name is used on an object */ public class InvalidPropertyException extends RuntimeCamelException { - private final transient Object owner; + private final transient @Nullable Object owner; private final String propertyName; - public InvalidPropertyException(Object owner, String propertyName) { + public InvalidPropertyException(@Nullable Object owner, String propertyName) { this(owner, propertyName, owner != null ? owner.getClass() : Object.class); } @@ -38,7 +40,7 @@ public String getPropertyName() { return propertyName; } - public Object getOwner() { + public @Nullable Object getOwner() { return owner; } } diff --git a/core/camel-api/src/main/java/org/apache/camel/LineNumberAware.java b/core/camel-api/src/main/java/org/apache/camel/LineNumberAware.java index e917848ea09f2..b227b7b2d894a 100644 --- a/core/camel-api/src/main/java/org/apache/camel/LineNumberAware.java +++ b/core/camel-api/src/main/java/org/apache/camel/LineNumberAware.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * An entity that can point to a given line number from a source {@link org.apache.camel.spi.Resource} such as YAML and * XML DSL parsers. @@ -39,17 +41,18 @@ public interface LineNumberAware { /** * The location of the entity. */ + @Nullable String getLocation(); /** * Sets the location of the entity (source file name, i.e. foo.java, bar.xml, etc.) */ - void setLocation(String location); + void setLocation(@Nullable String location); /** * Set the {@link LineNumberAware} if the object is an instance of {@link LineNumberAware}. */ - static T trySetLineNumberAware(T object, LineNumberAware source) { + static T trySetLineNumberAware(T object, @Nullable LineNumberAware source) { if (source != null && object instanceof LineNumberAware lineNumberAware) { lineNumberAware.setLineNumber(source.getLineNumber()); lineNumberAware.setLocation(source.getLocation()); diff --git a/core/camel-api/src/main/java/org/apache/camel/Message.java b/core/camel-api/src/main/java/org/apache/camel/Message.java index 9bdd1bb1e7537..687e2fc4923bb 100644 --- a/core/camel-api/src/main/java/org/apache/camel/Message.java +++ b/core/camel-api/src/main/java/org/apache/camel/Message.java @@ -21,6 +21,7 @@ import org.apache.camel.spi.HeadersMapFactory; import org.apache.camel.trait.message.MessageTrait; +import org.jspecify.annotations.Nullable; /** * Implements the Message pattern and represents an inbound or @@ -98,6 +99,7 @@ public interface Message { * @param name name of header * @return the value of the given header or null if there is no header for the given name */ + @Nullable Object getHeader(String name); /** @@ -129,7 +131,7 @@ public interface Message { * given name * @throws TypeConversionException is thrown if error during type conversion */ - T getHeader(String name, Class type); + @Nullable T getHeader(String name, Class type); /** * Returns a header associated with this message by name and specifying the type required @@ -140,7 +142,7 @@ public interface Message { * @return the value of the given header or defaultValue if there is no header for the given * name or null if it cannot be converted to the given type */ - T getHeader(String name, Object defaultValue, Class type); + @Nullable T getHeader(String name, Object defaultValue, Class type); /** * Returns a header associated with this message by name and specifying the type required @@ -152,7 +154,7 @@ public interface Message { * defaultValueSupplier if there is no header for the given name or * null if it cannot be converted to the given type */ - T getHeader(String name, Supplier defaultValueSupplier, Class type); + @Nullable T getHeader(String name, Supplier defaultValueSupplier, Class type); /** * Sets a header on the message @@ -160,7 +162,7 @@ public interface Message { * @param name of the header * @param value to associate with the name */ - void setHeader(String name, Object value); + void setHeader(String name, @Nullable Object value); /** * Removes the named header from this message @@ -168,6 +170,7 @@ public interface Message { * @param name name of the header * @return the old value of the header */ + @Nullable Object removeHeader(String name); /** @@ -232,6 +235,7 @@ public interface Message { * * @return the body, can be null */ + @Nullable Object getBody(); /** @@ -264,7 +268,7 @@ public interface Message { * @see org.apache.camel.support.ExchangeHelper#getBodyAndResetStreamCache(Exchange, * Class) */ - T getBody(Class type); + @Nullable T getBody(Class type); /** * Returns the mandatory body as the specified type @@ -290,7 +294,7 @@ public interface Message { * * @param body the body */ - void setBody(Object body); + void setBody(@Nullable Object body); /** * Sets the body of the message as a specific type @@ -298,7 +302,7 @@ public interface Message { * @param body the body * @param type the type of the body */ - void setBody(Object body, Class type); + void setBody(@Nullable Object body, Class type); /** * Creates a copy of this message so that it can be used and possibly modified further in another exchange. @@ -334,7 +338,7 @@ public interface Message { * @param message the other message * @param newBody the new body to use */ - void copyFromWithNewBody(Message message, Object newBody); + void copyFromWithNewBody(Message message, @Nullable Object newBody); /** * Checks whether the message has a given {@link MessageTrait} @@ -350,6 +354,7 @@ public interface Message { * @param trait the {@link MessageTrait} to obtain the payload * @return The trait payload or null if not available */ + @Nullable Object getPayloadForTrait(MessageTrait trait); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/MessageHistory.java b/core/camel-api/src/main/java/org/apache/camel/MessageHistory.java index b576d59d30dd1..46a4fd60a4319 100644 --- a/core/camel-api/src/main/java/org/apache/camel/MessageHistory.java +++ b/core/camel-api/src/main/java/org/apache/camel/MessageHistory.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * Represents the history of a Camel {@link Message} how it was routed by the Camel routing engine. */ @@ -63,6 +65,7 @@ default long getElapsedSinceCreated() { /** * A read-only copy of the message at the point of this history (if this has been enabled). */ + @Nullable Message getMessage(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/NamedNode.java b/core/camel-api/src/main/java/org/apache/camel/NamedNode.java index e34600e8f7837..593ddc7793284 100644 --- a/core/camel-api/src/main/java/org/apache/camel/NamedNode.java +++ b/core/camel-api/src/main/java/org/apache/camel/NamedNode.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * Represents a node in the {@link org.apache.camel.model routes} which is identified by an id. */ @@ -29,6 +31,7 @@ public interface NamedNode extends LineNumberAware { /** * Gets the node prefix id. */ + @Nullable String getNodePrefixId(); /** @@ -47,11 +50,13 @@ public interface NamedNode extends LineNumberAware { /** * Returns the description text or null if there is no description text associated with this node */ + @Nullable String getDescriptionText(); /** * Returns the parent */ + @Nullable NamedNode getParent(); /** @@ -81,7 +86,7 @@ default int getLevel() { return level; } - default String getParentId() { + default @Nullable String getParentId() { NamedNode node = this; while (node != null && node.getParent() != null) { boolean shallow = "when".equals(node.getShortName()) || "otherwise".equals(node.getShortName()); @@ -96,14 +101,14 @@ default String getParentId() { /** * Special methods for Choice EIP */ - default NamedNode findMatchingWhen(String id) { + default @Nullable NamedNode findMatchingWhen(String id) { return null; } /** * Special methods for Choice EIP */ - default NamedNode findMatchingOtherwise(String id) { + default @Nullable NamedNode findMatchingOtherwise(String id) { return null; } diff --git a/core/camel-api/src/main/java/org/apache/camel/NamedRoute.java b/core/camel-api/src/main/java/org/apache/camel/NamedRoute.java index 047cd99be2db0..3e5e7e12777b2 100644 --- a/core/camel-api/src/main/java/org/apache/camel/NamedRoute.java +++ b/core/camel-api/src/main/java/org/apache/camel/NamedRoute.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * Represents a node in the {@link org.apache.camel.model routes} which is identified as a route. */ @@ -29,6 +31,7 @@ public interface NamedRoute { /** * Gets the node prefix id. */ + @Nullable String getNodePrefixId(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/Navigate.java b/core/camel-api/src/main/java/org/apache/camel/Navigate.java index 8d77f020704de..1ca04654ac1cc 100644 --- a/core/camel-api/src/main/java/org/apache/camel/Navigate.java +++ b/core/camel-api/src/main/java/org/apache/camel/Navigate.java @@ -18,6 +18,8 @@ import java.util.List; +import org.jspecify.annotations.Nullable; + /** * Implementations support navigating a graph where you can traverse forward and each next returns a {@link List} of * outputs of type T that can contain 0..n nodes. @@ -32,6 +34,7 @@ public interface Navigate { * * @return next group or null if no more outputs */ + @Nullable List next(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/NoSuchBeanException.java b/core/camel-api/src/main/java/org/apache/camel/NoSuchBeanException.java index 42bc3053d8df7..9ea827dffba88 100644 --- a/core/camel-api/src/main/java/org/apache/camel/NoSuchBeanException.java +++ b/core/camel-api/src/main/java/org/apache/camel/NoSuchBeanException.java @@ -16,12 +16,14 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * A runtime exception if a given bean could not be found in the {@link org.apache.camel.spi.Registry} */ public class NoSuchBeanException extends RuntimeCamelException { - private final String name; + private final @Nullable String name; public NoSuchBeanException(String name) { super("No bean could be found in the registry for: " + name); @@ -35,7 +37,7 @@ public NoSuchBeanException(String name, int size) { this.name = name; } - public NoSuchBeanException(String name, String type) { + public NoSuchBeanException(@Nullable String name, String type) { super("No bean could be found in the registry" + (name != null ? " for: " + name : "") + " of type: " + type); this.name = name; } @@ -50,7 +52,7 @@ public NoSuchBeanException(String name, String message, Throwable cause) { this.name = name; } - public String getName() { + public @Nullable String getName() { return name; } } diff --git a/core/camel-api/src/main/java/org/apache/camel/NoSuchHeaderException.java b/core/camel-api/src/main/java/org/apache/camel/NoSuchHeaderException.java index b3bdfd5d8a052..388ec007890e1 100644 --- a/core/camel-api/src/main/java/org/apache/camel/NoSuchHeaderException.java +++ b/core/camel-api/src/main/java/org/apache/camel/NoSuchHeaderException.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * An exception caused when a mandatory header is not available on a message {@link Exchange} * @@ -24,7 +26,7 @@ public class NoSuchHeaderException extends CamelExchangeException { private final String headerName; - private final transient Class type; + private final transient @Nullable Class type; public NoSuchHeaderException(String message, Exchange exchange, String headerName) { super(message, exchange); @@ -32,7 +34,7 @@ public NoSuchHeaderException(String message, Exchange exchange, String headerNam this.type = null; } - public NoSuchHeaderException(Exchange exchange, String headerName, Class type) { + public NoSuchHeaderException(Exchange exchange, String headerName, @Nullable Class type) { super("No '" + headerName + "' header available" + (type != null ? " of type: " + type.getName() : "") + reason(exchange, headerName), exchange); this.headerName = headerName; @@ -43,7 +45,7 @@ public String getHeaderName() { return headerName; } - public Class getType() { + public @Nullable Class getType() { return type; } @@ -52,7 +54,7 @@ protected static String reason(Exchange exchange, String headerName) { return valueDescription(value); } - static String valueDescription(Object value) { + static String valueDescription(@Nullable Object value) { if (value == null) { return ""; } diff --git a/core/camel-api/src/main/java/org/apache/camel/NoSuchHeaderOrPropertyException.java b/core/camel-api/src/main/java/org/apache/camel/NoSuchHeaderOrPropertyException.java index 54798a82dd905..fdee451030222 100644 --- a/core/camel-api/src/main/java/org/apache/camel/NoSuchHeaderOrPropertyException.java +++ b/core/camel-api/src/main/java/org/apache/camel/NoSuchHeaderOrPropertyException.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + public class NoSuchHeaderOrPropertyException extends CamelExchangeException { private final String headerName; @@ -59,7 +61,7 @@ protected static String property(Exchange exchange, String propertyName) { return valueDescription(value); } - static String valueDescription(Object value) { + static String valueDescription(@Nullable Object value) { if (value == null) { return "null"; } diff --git a/core/camel-api/src/main/java/org/apache/camel/NoSuchPropertyException.java b/core/camel-api/src/main/java/org/apache/camel/NoSuchPropertyException.java index 30a242ed51b5c..ffce95054c6da 100644 --- a/core/camel-api/src/main/java/org/apache/camel/NoSuchPropertyException.java +++ b/core/camel-api/src/main/java/org/apache/camel/NoSuchPropertyException.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * An exception caused when a mandatory property is not available on a message {@link Exchange} * @@ -24,13 +26,13 @@ public class NoSuchPropertyException extends CamelExchangeException { private final String propertyName; - private final transient Class type; + private final transient @Nullable Class type; public NoSuchPropertyException(Exchange exchange, String propertyName) { this(exchange, propertyName, null); } - public NoSuchPropertyException(Exchange exchange, String propertyName, Class type) { + public NoSuchPropertyException(Exchange exchange, String propertyName, @Nullable Class type) { super("No '" + propertyName + "' exchange property available" + (type != null ? " of type: " + type.getName() : "") + reason(exchange, propertyName), exchange); this.propertyName = propertyName; @@ -41,7 +43,7 @@ public String getPropertyName() { return propertyName; } - public Class getType() { + public @Nullable Class getType() { return type; } @@ -50,7 +52,7 @@ protected static String reason(Exchange exchange, String propertyName) { return valueDescription(value); } - static String valueDescription(Object value) { + static String valueDescription(@Nullable Object value) { if (value == null) { return ""; } diff --git a/core/camel-api/src/main/java/org/apache/camel/NoSuchVariableException.java b/core/camel-api/src/main/java/org/apache/camel/NoSuchVariableException.java index 25dc319d8b446..2e6280a55ab70 100644 --- a/core/camel-api/src/main/java/org/apache/camel/NoSuchVariableException.java +++ b/core/camel-api/src/main/java/org/apache/camel/NoSuchVariableException.java @@ -16,13 +16,15 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * An exception caused when a mandatory variable is not available */ public class NoSuchVariableException extends CamelExchangeException { private final String variableName; - private final transient Class type; + private final transient @Nullable Class type; public NoSuchVariableException(Exchange exchange, String variableName) { super(String.format( @@ -46,7 +48,7 @@ public String getVariableName() { return variableName; } - public Class getType() { + public @Nullable Class getType() { return type; } diff --git a/core/camel-api/src/main/java/org/apache/camel/NoTypeConversionAvailableException.java b/core/camel-api/src/main/java/org/apache/camel/NoTypeConversionAvailableException.java index 824d4e26fd17a..48b9e44310dce 100644 --- a/core/camel-api/src/main/java/org/apache/camel/NoTypeConversionAvailableException.java +++ b/core/camel-api/src/main/java/org/apache/camel/NoTypeConversionAvailableException.java @@ -16,21 +16,23 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * An exception thrown if a value could not be converted to the required type */ public class NoTypeConversionAvailableException extends CamelException { - private final transient Object value; + private final transient @Nullable Object value; private final transient Class type; - public NoTypeConversionAvailableException(Object value, Class type) { + public NoTypeConversionAvailableException(@Nullable Object value, Class type) { super(createMessage(value, type)); this.value = value; this.type = type; } - public NoTypeConversionAvailableException(Object value, Class type, Throwable cause) { + public NoTypeConversionAvailableException(@Nullable Object value, Class type, Throwable cause) { super(createMessage(value, type, cause), cause); this.value = value; this.type = type; @@ -39,7 +41,7 @@ public NoTypeConversionAvailableException(Object value, Class type, Throwable /** * Returns the value which could not be converted */ - public Object getValue() { + public @Nullable Object getValue() { return value; } @@ -53,7 +55,7 @@ public Class getToType() { /** * Returns the required from type. Returns null if the provided value was null. */ - public Class getFromType() { + public @Nullable Class getFromType() { if (value != null) { return value.getClass(); } else { @@ -64,7 +66,7 @@ public Class getFromType() { /** * Returns an error message for no type converter available. */ - public static String createMessage(Object value, Class type) { + public static String createMessage(@Nullable Object value, Class type) { return "No type converter available to convert from type: " + (value != null ? value.getClass().getCanonicalName() : null) + " to the required type: " + type.getCanonicalName(); @@ -73,7 +75,7 @@ public static String createMessage(Object value, Class type) { /** * Returns an error message for no type converter available with the cause. */ - public static String createMessage(Object value, Class type, Throwable cause) { + public static String createMessage(@Nullable Object value, Class type, Throwable cause) { return "Converting Exception when converting from type: " + (value != null ? value.getClass().getCanonicalName() : null) + " to the required type: " + type.getCanonicalName() + ", which is caused by " + cause; diff --git a/core/camel-api/src/main/java/org/apache/camel/PollingConsumer.java b/core/camel-api/src/main/java/org/apache/camel/PollingConsumer.java index 5964f1e611156..92589494f8200 100644 --- a/core/camel-api/src/main/java/org/apache/camel/PollingConsumer.java +++ b/core/camel-api/src/main/java/org/apache/camel/PollingConsumer.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * Represents a Polling Consumer where the caller polls for * messages when it is ready. @@ -43,6 +45,7 @@ public interface PollingConsumer extends Consumer { * * @return the message exchange received. */ + @Nullable Exchange receive(); /** @@ -54,6 +57,7 @@ public interface PollingConsumer extends Consumer { * * @return the message exchange if one is immediately available otherwise null */ + @Nullable Exchange receiveNoWait(); /** @@ -69,5 +73,6 @@ public interface PollingConsumer extends Consumer { * @return the message exchange if one was available within the timeout period, or null if the * timeout expired */ + @Nullable Exchange receive(long timeout); } diff --git a/core/camel-api/src/main/java/org/apache/camel/ProducerTemplate.java b/core/camel-api/src/main/java/org/apache/camel/ProducerTemplate.java index 22c5e761800ff..ffec2a1c9621a 100644 --- a/core/camel-api/src/main/java/org/apache/camel/ProducerTemplate.java +++ b/core/camel-api/src/main/java/org/apache/camel/ProducerTemplate.java @@ -23,6 +23,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.jspecify.annotations.Nullable; + /** * Template for working with Camel and sending {@link Message} instances in an {@link Exchange} to an {@link Endpoint}. *
@@ -115,6 +117,7 @@ public interface ProducerTemplate extends Service { * * @return the default endpoint instance */ + @Nullable Endpoint getDefaultEndpoint(); /** @@ -377,6 +380,7 @@ public interface ProducerTemplate extends Service { * @return the result if {@link ExchangePattern} is OUT capable, otherwise null * @throws CamelExecutionException if the processing of the exchange failed */ + @Nullable Object sendBody(Endpoint endpoint, ExchangePattern pattern, Object body) throws CamelExecutionException; /** @@ -393,6 +397,7 @@ public interface ProducerTemplate extends Service { * @return the result if {@link ExchangePattern} is OUT capable, otherwise null * @throws CamelExecutionException if the processing of the exchange failed */ + @Nullable Object sendBody(String endpointUri, ExchangePattern pattern, Object body) throws CamelExecutionException; /** @@ -441,6 +446,7 @@ public interface ProducerTemplate extends Service { * @return the result if {@link ExchangePattern} is OUT capable, otherwise null * @throws CamelExecutionException if the processing of the exchange failed */ + @Nullable Object sendBodyAndHeader( Endpoint endpoint, ExchangePattern pattern, Object body, String header, Object headerValue) @@ -462,6 +468,7 @@ Object sendBodyAndHeader( * @return the result if {@link ExchangePattern} is OUT capable, otherwise null * @throws CamelExecutionException if the processing of the exchange failed */ + @Nullable Object sendBodyAndHeader( String endpoint, ExchangePattern pattern, Object body, String header, Object headerValue) @@ -515,6 +522,7 @@ void sendBodyAndProperty(Endpoint endpoint, Object body, String property, Object * @return the result if {@link ExchangePattern} is OUT capable, otherwise null * @throws CamelExecutionException if the processing of the exchange failed */ + @Nullable Object sendBodyAndProperty( Endpoint endpoint, ExchangePattern pattern, Object body, String property, Object propertyValue) @@ -536,6 +544,7 @@ Object sendBodyAndProperty( * @return the result if {@link ExchangePattern} is OUT capable, otherwise null * @throws CamelExecutionException if the processing of the exchange failed */ + @Nullable Object sendBodyAndProperty( String endpoint, ExchangePattern pattern, Object body, String property, Object propertyValue) @@ -584,6 +593,7 @@ Object sendBodyAndProperty( * @return the result if {@link ExchangePattern} is OUT capable, otherwise null * @throws CamelExecutionException if the processing of the exchange failed */ + @Nullable Object sendBodyAndHeaders( String endpointUri, ExchangePattern pattern, Object body, Map headers) @@ -604,6 +614,7 @@ Object sendBodyAndHeaders( * @return the result if {@link ExchangePattern} is OUT capable, otherwise null * @throws CamelExecutionException if the processing of the exchange failed */ + @Nullable Object sendBodyAndHeaders( Endpoint endpoint, ExchangePattern pattern, Object body, Map headers) @@ -652,6 +663,7 @@ Object sendBodyAndHeaders( * @return the result (see class javadoc) * @throws CamelExecutionException if the processing of the exchange failed */ + @Nullable Object requestBody(Object body) throws CamelExecutionException; /** @@ -667,7 +679,7 @@ Object sendBodyAndHeaders( * @return the result (see class javadoc) * @throws CamelExecutionException if the processing of the exchange failed */ - T requestBody(Object body, Class type) throws CamelExecutionException; + @Nullable T requestBody(Object body, Class type) throws CamelExecutionException; /** * Send the body to an endpoint returning any result output body. Uses an {@link ExchangePattern#InOut} message @@ -682,6 +694,7 @@ Object sendBodyAndHeaders( * @return the result (see class javadoc) * @throws CamelExecutionException if the processing of the exchange failed */ + @Nullable Object requestBody(Endpoint endpoint, Object body) throws CamelExecutionException; /** @@ -698,7 +711,7 @@ Object sendBodyAndHeaders( * @return the result (see class javadoc) * @throws CamelExecutionException if the processing of the exchange failed */ - T requestBody(Endpoint endpoint, Object body, Class type) throws CamelExecutionException; + @Nullable T requestBody(Endpoint endpoint, Object body, Class type) throws CamelExecutionException; /** * Send the body to an endpoint returning any result output body. Uses an {@link ExchangePattern#InOut} message @@ -713,6 +726,7 @@ Object sendBodyAndHeaders( * @return the result (see class javadoc) * @throws CamelExecutionException if the processing of the exchange failed */ + @Nullable Object requestBody(String endpointUri, Object body) throws CamelExecutionException; /** @@ -729,7 +743,7 @@ Object sendBodyAndHeaders( * @return the result (see class javadoc) * @throws CamelExecutionException if the processing of the exchange failed */ - T requestBody(String endpointUri, Object body, Class type) throws CamelExecutionException; + @Nullable T requestBody(String endpointUri, Object body, Class type) throws CamelExecutionException; /** * Sends the body to the default endpoint and returns the result content Uses an {@link ExchangePattern#InOut} @@ -745,6 +759,7 @@ Object sendBodyAndHeaders( * @return the result (see class javadoc) * @throws CamelExecutionException if the processing of the exchange failed */ + @Nullable Object requestBodyAndHeader(Object body, String header, Object headerValue) throws CamelExecutionException; /** @@ -762,6 +777,7 @@ Object sendBodyAndHeaders( * @return the result (see class javadoc) * @throws CamelExecutionException if the processing of the exchange failed */ + @Nullable Object requestBodyAndHeader(Endpoint endpoint, Object body, String header, Object headerValue) throws CamelExecutionException; @@ -781,7 +797,7 @@ Object requestBodyAndHeader(Endpoint endpoint, Object body, String header, Objec * @return the result (see class javadoc) * @throws CamelExecutionException if the processing of the exchange failed */ - T requestBodyAndHeader(Endpoint endpoint, Object body, String header, Object headerValue, Class type) + @Nullable T requestBodyAndHeader(Endpoint endpoint, Object body, String header, Object headerValue, Class type) throws CamelExecutionException; /** @@ -799,6 +815,7 @@ T requestBodyAndHeader(Endpoint endpoint, Object body, String header, Object * @return the result (see class javadoc) * @throws CamelExecutionException if the processing of the exchange failed */ + @Nullable Object requestBodyAndHeader(String endpointUri, Object body, String header, Object headerValue) throws CamelExecutionException; @@ -818,7 +835,7 @@ Object requestBodyAndHeader(String endpointUri, Object body, String header, Obje * @return the result (see class javadoc) * @throws CamelExecutionException if the processing of the exchange failed */ - T requestBodyAndHeader(String endpointUri, Object body, String header, Object headerValue, Class type) + @Nullable T requestBodyAndHeader(String endpointUri, Object body, String header, Object headerValue, Class type) throws CamelExecutionException; /** @@ -835,6 +852,7 @@ T requestBodyAndHeader(String endpointUri, Object body, String header, Objec * @return the result (see class javadoc) * @throws CamelExecutionException if the processing of the exchange failed */ + @Nullable Object requestBodyAndHeaders(String endpointUri, Object body, Map headers) throws CamelExecutionException; /** @@ -852,7 +870,7 @@ T requestBodyAndHeader(String endpointUri, Object body, String header, Objec * @return the result (see class javadoc) * @throws CamelExecutionException if the processing of the exchange failed */ - T requestBodyAndHeaders(String endpointUri, Object body, Map headers, Class type) + @Nullable T requestBodyAndHeaders(String endpointUri, Object body, Map headers, Class type) throws CamelExecutionException; /** @@ -869,6 +887,7 @@ T requestBodyAndHeaders(String endpointUri, Object body, Map * @return the result (see class javadoc) * @throws CamelExecutionException if the processing of the exchange failed */ + @Nullable Object requestBodyAndHeaders(Endpoint endpoint, Object body, Map headers) throws CamelExecutionException; /** @@ -884,6 +903,7 @@ T requestBodyAndHeaders(String endpointUri, Object body, Map * @return the result (see class javadoc) * @throws CamelExecutionException if the processing of the exchange failed */ + @Nullable Object requestBodyAndHeaders(Object body, Map headers) throws CamelExecutionException; /** @@ -901,7 +921,7 @@ T requestBodyAndHeaders(String endpointUri, Object body, Map * @return the result (see class javadoc) * @throws CamelExecutionException if the processing of the exchange failed */ - T requestBodyAndHeaders(Endpoint endpoint, Object body, Map headers, Class type) + @Nullable T requestBodyAndHeaders(Endpoint endpoint, Object body, Map headers, Class type) throws CamelExecutionException; // Asynchronous methods @@ -1119,7 +1139,7 @@ CompletableFuture asyncRequestBodyAndHeaders( * @return the result (see class javadoc) * @throws CamelExecutionException if the processing of the exchange failed */ - T extractFutureBody(Future future, Class type) throws CamelExecutionException; + @Nullable T extractFutureBody(Future future, Class type) throws CamelExecutionException; /** * Gets the response body from the future handle, will wait at most the given time for the response to be ready. @@ -1135,7 +1155,7 @@ CompletableFuture asyncRequestBodyAndHeaders( * @throws java.util.concurrent.TimeoutException if the wait timed out * @throws CamelExecutionException if the processing of the exchange failed */ - T extractFutureBody(Future future, long timeout, TimeUnit unit, Class type) + @Nullable T extractFutureBody(Future future, long timeout, TimeUnit unit, Class type) throws TimeoutException, CamelExecutionException; } diff --git a/core/camel-api/src/main/java/org/apache/camel/PropertiesLookupListener.java b/core/camel-api/src/main/java/org/apache/camel/PropertiesLookupListener.java index 1c9c4c158af1f..4c2dcfcd4ef68 100644 --- a/core/camel-api/src/main/java/org/apache/camel/PropertiesLookupListener.java +++ b/core/camel-api/src/main/java/org/apache/camel/PropertiesLookupListener.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * Listener to trigger when the properties component is looking up and found a property. */ @@ -30,6 +32,6 @@ public interface PropertiesLookupListener { * @param defaultValue optional default value * @param source optional source containing the properties */ - void onLookup(String name, String value, String defaultValue, String source); + void onLookup(String name, @Nullable String value, @Nullable String defaultValue, @Nullable String source); } diff --git a/core/camel-api/src/main/java/org/apache/camel/PropertyBindingException.java b/core/camel-api/src/main/java/org/apache/camel/PropertyBindingException.java index ce6020e824972..3a08b25d5c6ae 100644 --- a/core/camel-api/src/main/java/org/apache/camel/PropertyBindingException.java +++ b/core/camel-api/src/main/java/org/apache/camel/PropertyBindingException.java @@ -16,18 +16,20 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * Error binding property to a bean. */ public class PropertyBindingException extends RuntimeCamelException { private final Object target; - private final String propertyName; - private final Object value; - private final String optionPrefix; - private final String optionKey; + private final @Nullable String propertyName; + private final @Nullable Object value; + private final @Nullable String optionPrefix; + private final @Nullable String optionKey; - public PropertyBindingException(Object target, String propertyName, Object value) { + public PropertyBindingException(Object target, @Nullable String propertyName, @Nullable Object value) { this.target = target; this.propertyName = propertyName; this.value = value; @@ -35,7 +37,7 @@ public PropertyBindingException(Object target, String propertyName, Object value this.optionKey = null; } - public PropertyBindingException(Object target, String propertyName, Object value, Throwable e) { + public PropertyBindingException(Object target, @Nullable String propertyName, @Nullable Object value, Throwable e) { initCause(e); this.target = target; this.propertyName = propertyName; @@ -53,8 +55,8 @@ public PropertyBindingException(Object target, Throwable e) { this.optionKey = null; } - public PropertyBindingException(Object target, String propertyName, Object value, String optionPrefix, String optionKey, - Throwable e) { + public PropertyBindingException(Object target, @Nullable String propertyName, @Nullable Object value, + @Nullable String optionPrefix, @Nullable String optionKey, Throwable e) { initCause(e); this.target = target; this.propertyName = propertyName; @@ -82,19 +84,19 @@ public Object getTarget() { return target; } - public String getPropertyName() { + public @Nullable String getPropertyName() { return propertyName; } - public Object getValue() { + public @Nullable Object getValue() { return value; } - public String getOptionPrefix() { + public @Nullable String getOptionPrefix() { return optionPrefix; } - public String getOptionKey() { + public @Nullable String getOptionKey() { return optionKey; } diff --git a/core/camel-api/src/main/java/org/apache/camel/Route.java b/core/camel-api/src/main/java/org/apache/camel/Route.java index dfc1c7eaace4c..9c404330993fd 100644 --- a/core/camel-api/src/main/java/org/apache/camel/Route.java +++ b/core/camel-api/src/main/java/org/apache/camel/Route.java @@ -29,6 +29,7 @@ import org.apache.camel.spi.RouteController; import org.apache.camel.spi.RouteError; import org.apache.camel.spi.RoutePolicy; +import org.jspecify.annotations.Nullable; /** * A Route defines the processing used on an inbound message exchange @@ -63,6 +64,7 @@ public interface Route extends RuntimeConfiguration { /** * Gets the node prefix id */ + @Nullable String getNodePrefixId(); /** @@ -92,6 +94,7 @@ public interface Route extends RuntimeConfiguration { * * @return the route group */ + @Nullable String getGroup(); /** @@ -148,6 +151,7 @@ public interface Route extends RuntimeConfiguration { * * @return the description, or null if no description has been configured. */ + @Nullable String getDescription(); /** @@ -157,6 +161,7 @@ public interface Route extends RuntimeConfiguration { * * @return the note, or null if no note has been configured. */ + @Nullable String getNote(); /** @@ -167,6 +172,7 @@ public interface Route extends RuntimeConfiguration { * * @return the configuration, or null if no configuration has been configured. */ + @Nullable String getConfigurationId(); /** @@ -174,16 +180,19 @@ public interface Route extends RuntimeConfiguration { * * @return the source, or null if this route is not loaded from a resource */ + @Nullable Resource getSourceResource(); /** * The source:line-number where the route input is located in the source code */ + @Nullable String getSourceLocation(); /** * The source:line-number in short format that can be used for logging or summary purposes. */ + @Nullable String getSourceLocationShort(); /** @@ -258,6 +267,7 @@ public interface Route extends RuntimeConfiguration { * * @return the error or null if no error */ + @Nullable RouteError getLastError(); /** @@ -269,17 +279,18 @@ public interface Route extends RuntimeConfiguration { * * @param error the error */ - void setLastError(RouteError error); + void setLastError(@Nullable RouteError error); /** * Gets the route startup order */ + @Nullable Integer getStartupOrder(); /** * Sets the route startup order */ - void setStartupOrder(Integer startupOrder); + void setStartupOrder(@Nullable Integer startupOrder); /** * Gets the {@link RouteController} for this route. @@ -321,11 +332,13 @@ public interface Route extends RuntimeConfiguration { /** * Gets the route description */ + @Nullable String getRouteDescription(); /** * Gets the route note */ + @Nullable String getRouteNote(); /** @@ -335,6 +348,7 @@ public interface Route extends RuntimeConfiguration { * * @return the route type during creation of the route, is null after the route has been created. */ + @Nullable NamedNode getRoute(); /** @@ -373,6 +387,7 @@ public interface Route extends RuntimeConfiguration { * * @return the managed intercept strategy, or null if not managed */ + @Nullable ManagementInterceptStrategy getManagementInterceptStrategy(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/RouteAware.java b/core/camel-api/src/main/java/org/apache/camel/RouteAware.java index 1aa7b5b5f65ce..953c1793dd0f4 100644 --- a/core/camel-api/src/main/java/org/apache/camel/RouteAware.java +++ b/core/camel-api/src/main/java/org/apache/camel/RouteAware.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * An interface to represent an object which wishes to be injected with a {@link Route} such as {@link Consumer} which * is the consumer for a route. @@ -27,13 +29,14 @@ public interface RouteAware { * * @param route the route */ - void setRoute(Route route); + void setRoute(@Nullable Route route); /** * Gets the {@link Route} * * @return the route, or null if no route has been set. */ + @Nullable Route getRoute(); } diff --git a/core/camel-api/src/main/java/org/apache/camel/RouteTemplateContext.java b/core/camel-api/src/main/java/org/apache/camel/RouteTemplateContext.java index 75d3c46ac28b1..ab87cc331acb3 100644 --- a/core/camel-api/src/main/java/org/apache/camel/RouteTemplateContext.java +++ b/core/camel-api/src/main/java/org/apache/camel/RouteTemplateContext.java @@ -22,6 +22,7 @@ import org.apache.camel.spi.BeanRepository; import org.apache.camel.spi.HasCamelContext; +import org.jspecify.annotations.Nullable; /** * The context used during creating a {@link Route} from a route template. @@ -106,6 +107,7 @@ default void bind(String id, Object bean) { * @param name name of property * @return the property value or null if no property exists */ + @Nullable Object getProperty(String name); /** @@ -117,6 +119,7 @@ default void bind(String id, Object bean) { * @param name name of property * @return the property value or null if no property exists */ + @Nullable Object getEnvironmentVariable(String name); /** @@ -127,7 +130,7 @@ default void bind(String id, Object bean) { * @return the property value or null if no property exists * @throws TypeConversionException is thrown if error during type conversion */ - T getProperty(String name, Class type); + @Nullable T getProperty(String name, Class type); /** * Sets a parameter @@ -173,11 +176,12 @@ default void bind(String id, Object bean) { * * @param configurer the configurer with callback to invoke with the given route template context */ - void setConfigurer(Consumer configurer); + void setConfigurer(@Nullable Consumer configurer); /** * Gets the custom configurer. */ + @Nullable Consumer getConfigurer(); } diff --git a/core/camel-api/src/main/java/org/apache/camel/RuntimeCamelException.java b/core/camel-api/src/main/java/org/apache/camel/RuntimeCamelException.java index 8a467f975b3b5..398dc10d0a3b7 100644 --- a/core/camel-api/src/main/java/org/apache/camel/RuntimeCamelException.java +++ b/core/camel-api/src/main/java/org/apache/camel/RuntimeCamelException.java @@ -18,6 +18,8 @@ import java.io.Serial; +import org.jspecify.annotations.Nullable; + /** * Base class for all Camel unchecked exceptions. */ @@ -27,15 +29,15 @@ public class RuntimeCamelException extends RuntimeException { public RuntimeCamelException() { } - public RuntimeCamelException(String message) { + public RuntimeCamelException(@Nullable String message) { super(message); } - public RuntimeCamelException(String message, Throwable cause) { + public RuntimeCamelException(@Nullable String message, @Nullable Throwable cause) { super(message, cause); } - public RuntimeCamelException(Throwable cause) { + public RuntimeCamelException(@Nullable Throwable cause) { super(cause); } diff --git a/core/camel-api/src/main/java/org/apache/camel/RuntimeConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/RuntimeConfiguration.java index bf504cb30c04d..4aef5cda746ba 100644 --- a/core/camel-api/src/main/java/org/apache/camel/RuntimeConfiguration.java +++ b/core/camel-api/src/main/java/org/apache/camel/RuntimeConfiguration.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * Various runtime configuration options used by {@link org.apache.camel.CamelContext} and {@link Route} for cross * cutting functions such as tracing, delayer, stream cache and the like. @@ -58,13 +60,14 @@ public interface RuntimeConfiguration { * Tracing pattern to match which node EIPs to trace. For example to match all To EIP nodes, use to*. The pattern * matches by node and route id's Multiple patterns can be separated by comma. */ + @Nullable String getTracingPattern(); /** * Tracing pattern to match which node EIPs to trace. For example to match all To EIP nodes, use to*. The pattern * matches by node and route id's Multiple patterns can be separated by comma. */ - void setTracingPattern(String tracePattern); + void setTracingPattern(@Nullable String tracePattern); /** * Sets whether backlog tracing is enabled or not (default is disabled). @@ -157,6 +160,7 @@ public interface RuntimeConfiguration { * * @return delay in millis, or null if disabled */ + @Nullable Long getDelayer(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/RuntimeExchangeException.java b/core/camel-api/src/main/java/org/apache/camel/RuntimeExchangeException.java index 567cdc024da6f..7c6f2c034aac1 100644 --- a/core/camel-api/src/main/java/org/apache/camel/RuntimeExchangeException.java +++ b/core/camel-api/src/main/java/org/apache/camel/RuntimeExchangeException.java @@ -16,11 +16,13 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * A runtime exception caused by a specific message {@link Exchange} */ public class RuntimeExchangeException extends RuntimeCamelException { - private final transient Exchange exchange; + private final transient @Nullable Exchange exchange; public RuntimeExchangeException(String message, Exchange exchange) { super(createMessage(message, exchange)); @@ -37,11 +39,11 @@ public RuntimeExchangeException(String message, Exchange exchange, Throwable cau *

* Can be null */ - public Exchange getExchange() { + public @Nullable Exchange getExchange() { return exchange; } - protected static String createMessage(String message, Exchange exchange) { + protected static String createMessage(String message, @Nullable Exchange exchange) { if (exchange != null) { return message + " on the exchange: " + exchange; } else { diff --git a/core/camel-api/src/main/java/org/apache/camel/SSLContextParametersAware.java b/core/camel-api/src/main/java/org/apache/camel/SSLContextParametersAware.java index bd5dfce4b6b62..533bfe60f4dde 100644 --- a/core/camel-api/src/main/java/org/apache/camel/SSLContextParametersAware.java +++ b/core/camel-api/src/main/java/org/apache/camel/SSLContextParametersAware.java @@ -17,6 +17,7 @@ package org.apache.camel; import org.apache.camel.support.jsse.SSLContextParameters; +import org.jspecify.annotations.Nullable; /** * Indicates that an object is able to use the global {@link SSLContextParameters} if configured. @@ -26,7 +27,7 @@ public interface SSLContextParametersAware extends CamelContextAware { /** * Returns the global {@link SSLContextParameters} if enabled on the implementing object, null otherwise. */ - default SSLContextParameters retrieveGlobalSslContextParameters() { + default @Nullable SSLContextParameters retrieveGlobalSslContextParameters() { if (isUseGlobalSslContextParameters()) { return getCamelContext().getSSLContextParameters(); } diff --git a/core/camel-api/src/main/java/org/apache/camel/StreamCache.java b/core/camel-api/src/main/java/org/apache/camel/StreamCache.java index 4dc5223799413..289cd120cf7a4 100644 --- a/core/camel-api/src/main/java/org/apache/camel/StreamCache.java +++ b/core/camel-api/src/main/java/org/apache/camel/StreamCache.java @@ -19,6 +19,8 @@ import java.io.IOException; import java.io.OutputStream; +import org.jspecify.annotations.Nullable; + /** * Tagging interface to indicate that a type is capable of caching the underlying data stream. *

@@ -64,6 +66,7 @@ public interface StreamCache { * @return a copy, or null if copy is not possible * @throws java.io.IOException is thrown if the copy fails */ + @Nullable StreamCache copy(Exchange exchange) throws IOException; /** diff --git a/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java b/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java index 6fa8fd3ab8062..e644ab02f262b 100644 --- a/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java +++ b/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java @@ -16,9 +16,11 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + public class StreamCacheException extends TypeConversionException { - public StreamCacheException(Object value, Throwable cause) { + public StreamCacheException(@Nullable Object value, Throwable cause) { super(value, StreamCache.class, cause); } } diff --git a/core/camel-api/src/main/java/org/apache/camel/TimeoutMap.java b/core/camel-api/src/main/java/org/apache/camel/TimeoutMap.java index aa187829fc2f3..726b4c3e2a497 100644 --- a/core/camel-api/src/main/java/org/apache/camel/TimeoutMap.java +++ b/core/camel-api/src/main/java/org/apache/camel/TimeoutMap.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * Represents a map of values which timeout after a period of inactivity. */ @@ -27,6 +29,7 @@ public interface TimeoutMap extends Service { * @param key the key of the value to search for * @return the value for the given key or null if it is not present (or has timed out) */ + @Nullable V get(K key); /** @@ -45,6 +48,7 @@ public interface TimeoutMap extends Service { * @return the previous value associated with key, or null if there was no mapping * for key. */ + @Nullable V put(K key, V value, long timeoutMillis); /** @@ -57,6 +61,7 @@ public interface TimeoutMap extends Service { * @return the value associated with key, or null if there was no mapping for * key. */ + @Nullable V putIfAbsent(K key, V value, long timeoutMillis); /** @@ -65,6 +70,7 @@ public interface TimeoutMap extends Service { * @param key key for the object to remove * @return the value for the given key or null if it is not present (or has timed out) */ + @Nullable V remove(K key); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/TypeConversionException.java b/core/camel-api/src/main/java/org/apache/camel/TypeConversionException.java index 5096e4e117467..a4363beef9fa9 100644 --- a/core/camel-api/src/main/java/org/apache/camel/TypeConversionException.java +++ b/core/camel-api/src/main/java/org/apache/camel/TypeConversionException.java @@ -16,15 +16,17 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * Exception when failing during type conversion. */ public class TypeConversionException extends RuntimeCamelException { - private final transient Object value; + private final transient @Nullable Object value; private final transient Class type; - public TypeConversionException(Object value, Class type, Throwable cause) { + public TypeConversionException(@Nullable Object value, Class type, Throwable cause) { super(createMessage(value, type, cause), cause); this.value = value; this.type = type; @@ -33,7 +35,7 @@ public TypeConversionException(Object value, Class type, Throwable cause) { /** * Returns the value which could not be converted */ - public Object getValue() { + public @Nullable Object getValue() { return value; } @@ -47,7 +49,7 @@ public Class getToType() { /** * Returns the required from type. Returns null if the provided value was null. */ - public Class getFromType() { + public @Nullable Class getFromType() { if (value != null) { return value.getClass(); } else { @@ -58,7 +60,7 @@ public Class getFromType() { /** * Returns an error message for type conversion failed. */ - public static String createMessage(Object value, Class type, Throwable cause) { + public static String createMessage(@Nullable Object value, Class type, Throwable cause) { return "Error during type conversion from type: " + (value != null ? value.getClass().getCanonicalName() : null) + " to the required type: " + type.getCanonicalName() + " with value " + value + " due to " + cause.getClass().getName() + ": " + cause.getMessage(); diff --git a/core/camel-api/src/main/java/org/apache/camel/TypeConverter.java b/core/camel-api/src/main/java/org/apache/camel/TypeConverter.java index f959082528d7c..a41ce99bfa445 100644 --- a/core/camel-api/src/main/java/org/apache/camel/TypeConverter.java +++ b/core/camel-api/src/main/java/org/apache/camel/TypeConverter.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * A pluggable strategy to be able to convert objects to different * types such as to and from String, InputStream/OutputStream, Reader/Writer, Document, byte[], ByteBuffer etc @@ -39,7 +41,7 @@ public interface TypeConverter { * @return the converted value, or null if not possible to convert * @throws TypeConversionException is thrown if error during type conversion */ - T convertTo(Class type, Object value) throws TypeConversionException; + @Nullable T convertTo(Class type, @Nullable Object value) throws TypeConversionException; /** * Converts the value to the specified type in the context of an exchange @@ -52,7 +54,8 @@ public interface TypeConverter { * @return the converted value, or null if not possible to convert * @throws TypeConversionException is thrown if error during type conversion */ - T convertTo(Class type, Exchange exchange, Object value) throws TypeConversionException; + @Nullable T convertTo(Class type, @Nullable Exchange exchange, @Nullable Object value) + throws TypeConversionException; /** * Converts the value to the specified type @@ -63,7 +66,8 @@ public interface TypeConverter { * @throws TypeConversionException is thrown if error during type conversion * @throws NoTypeConversionAvailableException if no type converters exists to convert to the given type */ - T mandatoryConvertTo(Class type, Object value) throws TypeConversionException, NoTypeConversionAvailableException; + T mandatoryConvertTo(Class type, @Nullable Object value) + throws TypeConversionException, NoTypeConversionAvailableException; /** * Converts the value to the specified type in the context of an exchange @@ -77,7 +81,7 @@ public interface TypeConverter { * @throws TypeConversionException is thrown if error during type conversion * @throws NoTypeConversionAvailableException if no type converters exists to convert to the given type */ - T mandatoryConvertTo(Class type, Exchange exchange, Object value) + T mandatoryConvertTo(Class type, @Nullable Exchange exchange, @Nullable Object value) throws TypeConversionException, NoTypeConversionAvailableException; /** @@ -89,7 +93,7 @@ T mandatoryConvertTo(Class type, Exchange exchange, Object value) * @param value the value to be converted * @return the converted value, or null if not possible to convert */ - T tryConvertTo(Class type, Object value); + @Nullable T tryConvertTo(Class type, @Nullable Object value); /** * Tries to convert the value to the specified type in the context of an exchange, returning null if not @@ -105,5 +109,5 @@ T mandatoryConvertTo(Class type, Exchange exchange, Object value) * @param value the value to be converted * @return the converted value, or null if not possible to convert */ - T tryConvertTo(Class type, Exchange exchange, Object value); + @Nullable T tryConvertTo(Class type, @Nullable Exchange exchange, @Nullable Object value); } diff --git a/core/camel-api/src/main/java/org/apache/camel/VariableAware.java b/core/camel-api/src/main/java/org/apache/camel/VariableAware.java index 4fd26d8ea2ed8..dddbae261e317 100644 --- a/core/camel-api/src/main/java/org/apache/camel/VariableAware.java +++ b/core/camel-api/src/main/java/org/apache/camel/VariableAware.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * An interface to represent an object that supports variables. */ @@ -31,6 +33,7 @@ public interface VariableAware { * @param name the name of the variable * @return the value of the given variable or null if there is no variable for the given name */ + @Nullable Object getVariable(String name); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/ai/package-info.java b/core/camel-api/src/main/java/org/apache/camel/ai/package-info.java new file mode 100644 index 0000000000000..db56553e1a366 --- /dev/null +++ b/core/camel-api/src/main/java/org/apache/camel/ai/package-info.java @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +package org.apache.camel.ai; + +import org.jspecify.annotations.NullMarked; diff --git a/core/camel-api/src/main/java/org/apache/camel/catalog/ConfigurationPropertiesValidationResult.java b/core/camel-api/src/main/java/org/apache/camel/catalog/ConfigurationPropertiesValidationResult.java index 920c7b009d2aa..6bdcd7984e1d9 100644 --- a/core/camel-api/src/main/java/org/apache/camel/catalog/ConfigurationPropertiesValidationResult.java +++ b/core/camel-api/src/main/java/org/apache/camel/catalog/ConfigurationPropertiesValidationResult.java @@ -21,32 +21,34 @@ import java.util.LinkedHashMap; import java.util.Map; +import org.jspecify.annotations.Nullable; + /** * Details result of validating configuration properties (eg application.properties for camel-main). */ public class ConfigurationPropertiesValidationResult extends PropertiesValidationResult implements Serializable { - private String fileName; - private String text; + private @Nullable String fileName; + private @Nullable String text; private int lineNumber; private boolean accepted; public ConfigurationPropertiesValidationResult() { } - public String getFileName() { + public @Nullable String getFileName() { return fileName; } - public void setFileName(String fileName) { + public void setFileName(@Nullable String fileName) { this.fileName = fileName; } - public String getText() { + public @Nullable String getText() { return text; } - public void setText(String text) { + public void setText(@Nullable String text) { this.text = text; } @@ -72,7 +74,7 @@ public void setAccepted(boolean accepted) { * @param includeHeader whether to include a header * @return the summary, or null if no validation errors */ - public String summaryErrorMessage(boolean includeHeader) { + public @Nullable String summaryErrorMessage(boolean includeHeader) { return summaryErrorMessage(includeHeader, true, false); } @@ -84,7 +86,7 @@ public String summaryErrorMessage(boolean includeHeader) { * @param includeWarnings whether to include warnings as an error or not * @return the summary, or null if no validation errors */ - public String summaryErrorMessage(boolean includeHeader, boolean ignoreDeprecated, boolean includeWarnings) { + public @Nullable String summaryErrorMessage(boolean includeHeader, boolean ignoreDeprecated, boolean includeWarnings) { boolean ok = isSuccess(); // special check if we should ignore deprecated options being used diff --git a/core/camel-api/src/main/java/org/apache/camel/catalog/EndpointValidationResult.java b/core/camel-api/src/main/java/org/apache/camel/catalog/EndpointValidationResult.java index 512e669c34d3b..eb03e70730b7f 100644 --- a/core/camel-api/src/main/java/org/apache/camel/catalog/EndpointValidationResult.java +++ b/core/camel-api/src/main/java/org/apache/camel/catalog/EndpointValidationResult.java @@ -23,26 +23,28 @@ import java.util.Map; import java.util.Set; +import org.jspecify.annotations.Nullable; + /** * Details result of validating endpoint uri. */ public class EndpointValidationResult extends PropertiesValidationResult implements Serializable { - private final String uri; + private final @Nullable String uri; - private Set lenient; - private Set notConsumerOnly; - private Set notProducerOnly; + private @Nullable Set lenient; + private @Nullable Set notConsumerOnly; + private @Nullable Set notProducerOnly; public EndpointValidationResult() { this(null); } - public EndpointValidationResult(String uri) { + public EndpointValidationResult(@Nullable String uri) { this.uri = uri; } - public String getUri() { + public @Nullable String getUri() { return uri; } @@ -82,15 +84,15 @@ public void addNotProducerOnly(String name) { } } - public Set getNotConsumerOnly() { + public @Nullable Set getNotConsumerOnly() { return notConsumerOnly; } - public Set getNotProducerOnly() { + public @Nullable Set getNotProducerOnly() { return notProducerOnly; } - public Set getLenient() { + public @Nullable Set getLenient() { return lenient; } @@ -100,7 +102,7 @@ public Set getLenient() { * @param includeHeader whether to include a header * @return the summary, or null if no validation errors */ - public String summaryErrorMessage(boolean includeHeader) { + public @Nullable String summaryErrorMessage(boolean includeHeader) { return summaryErrorMessage(includeHeader, true, false); } @@ -112,7 +114,7 @@ public String summaryErrorMessage(boolean includeHeader) { * @param includeWarnings whether to include warnings as an error or not * @return the summary, or null if no validation errors */ - public String summaryErrorMessage(boolean includeHeader, boolean ignoreDeprecated, boolean includeWarnings) { + public @Nullable String summaryErrorMessage(boolean includeHeader, boolean ignoreDeprecated, boolean includeWarnings) { boolean ok = isSuccess(); // special check if we should ignore deprecated options being used diff --git a/core/camel-api/src/main/java/org/apache/camel/catalog/JSonSchemaResolver.java b/core/camel-api/src/main/java/org/apache/camel/catalog/JSonSchemaResolver.java index 7b8c99f4c57b3..47244433d1b14 100644 --- a/core/camel-api/src/main/java/org/apache/camel/catalog/JSonSchemaResolver.java +++ b/core/camel-api/src/main/java/org/apache/camel/catalog/JSonSchemaResolver.java @@ -16,6 +16,8 @@ */ package org.apache.camel.catalog; +import org.jspecify.annotations.Nullable; + /** * Pluggable resolver to load JSON schema files for components, data formats, languages etc. */ @@ -32,6 +34,7 @@ public interface JSonSchemaResolver { * @param name the component name * @return component details in JSon */ + @Nullable String getComponentJSonSchema(String name); /** @@ -40,6 +43,7 @@ public interface JSonSchemaResolver { * @param name the data format name * @return data format details in JSon */ + @Nullable String getDataFormatJSonSchema(String name); /** @@ -48,6 +52,7 @@ public interface JSonSchemaResolver { * @param name the language name * @return language details in JSon */ + @Nullable String getLanguageJSonSchema(String name); /** @@ -56,6 +61,7 @@ public interface JSonSchemaResolver { * @param name the transformer name * @return transformer details in JSon */ + @Nullable String getTransformerJSonSchema(String name); /** @@ -64,6 +70,7 @@ public interface JSonSchemaResolver { * @param name the dev console name * @return dev console details in JSon */ + @Nullable String getDevConsoleJSonSchema(String name); /** @@ -72,6 +79,7 @@ public interface JSonSchemaResolver { * @param name the other (miscellaneous) name * @return other (miscellaneous) details in JSon */ + @Nullable String getOtherJSonSchema(String name); /** @@ -80,6 +88,7 @@ public interface JSonSchemaResolver { * @param name the model name * @return model details in JSon */ + @Nullable String getModelJSonSchema(String name); /** @@ -87,6 +96,7 @@ public interface JSonSchemaResolver { * * @return the camel-main json schema */ + @Nullable String getMainJsonSchema(); /** @@ -94,6 +104,7 @@ public interface JSonSchemaResolver { * * @return the camel-jbang json schema */ + @Nullable String getJBangJsonSchema(); /** @@ -102,6 +113,7 @@ public interface JSonSchemaResolver { * @param name the pojo bean name * @return model details in JSon */ + @Nullable String getPojoBeanJSonSchema(String name); } diff --git a/core/camel-api/src/main/java/org/apache/camel/catalog/LanguageValidationResult.java b/core/camel-api/src/main/java/org/apache/camel/catalog/LanguageValidationResult.java index dd48a75cb6563..b91c05dcfd393 100644 --- a/core/camel-api/src/main/java/org/apache/camel/catalog/LanguageValidationResult.java +++ b/core/camel-api/src/main/java/org/apache/camel/catalog/LanguageValidationResult.java @@ -18,13 +18,15 @@ import java.io.Serializable; +import org.jspecify.annotations.Nullable; + /** * Validation result of parsing a language expression or predicate */ public class LanguageValidationResult implements Serializable { private final String text; - private String error; - private String shortError; + private @Nullable String error; + private @Nullable String shortError; private int index; public LanguageValidationResult(String text) { @@ -39,19 +41,19 @@ public boolean isSuccess() { return error == null; } - public void setError(String error) { + public void setError(@Nullable String error) { this.error = error; } - public String getError() { + public @Nullable String getError() { return error; } - public String getShortError() { + public @Nullable String getShortError() { return shortError; } - public void setShortError(String shortError) { + public void setShortError(@Nullable String shortError) { this.shortError = shortError; } diff --git a/core/camel-api/src/main/java/org/apache/camel/catalog/PropertiesValidationResult.java b/core/camel-api/src/main/java/org/apache/camel/catalog/PropertiesValidationResult.java index 115a420113a40..c6496bafb6a89 100644 --- a/core/camel-api/src/main/java/org/apache/camel/catalog/PropertiesValidationResult.java +++ b/core/camel-api/src/main/java/org/apache/camel/catalog/PropertiesValidationResult.java @@ -25,32 +25,52 @@ import java.util.Map; import java.util.Set; +import org.jspecify.annotations.Nullable; + abstract class PropertiesValidationResult implements Serializable { int errors; int warnings; // general error + @Nullable String syntaxError; // general warnings + @Nullable String unknownComponent; + @Nullable String incapable; // options + @Nullable Set unknown; + @Nullable Map unknownSuggestions; + @Nullable Set required; + @Nullable Set deprecated; + @Nullable Map invalidEnum; + @Nullable Map invalidEnumChoices; + @Nullable Map invalidEnumSuggestions; + @Nullable Map invalidMap; + @Nullable Map invalidArray; + @Nullable Map invalidReference; + @Nullable Map invalidBoolean; + @Nullable Map invalidInteger; + @Nullable Map invalidNumber; + @Nullable Map invalidDuration; + @Nullable Map defaultValues; public boolean hasErrors() { @@ -221,39 +241,39 @@ public void addDefaultValue(String name, String value) { defaultValues.put(name, value); } - public String getSyntaxError() { + public @Nullable String getSyntaxError() { return syntaxError; } - public String getIncapable() { + public @Nullable String getIncapable() { return incapable; } - public Set getUnknown() { + public @Nullable Set getUnknown() { return unknown; } - public Map getUnknownSuggestions() { + public @Nullable Map getUnknownSuggestions() { return unknownSuggestions; } - public String getUnknownComponent() { + public @Nullable String getUnknownComponent() { return unknownComponent; } - public Set getRequired() { + public @Nullable Set getRequired() { return required; } - public Set getDeprecated() { + public @Nullable Set getDeprecated() { return deprecated; } - public Map getInvalidEnum() { + public @Nullable Map getInvalidEnum() { return invalidEnum; } - public Map getInvalidEnumChoices() { + public @Nullable Map getInvalidEnumChoices() { return invalidEnumChoices; } @@ -268,35 +288,35 @@ public List getEnumChoices(String optionName) { return Collections.emptyList(); } - public Map getInvalidReference() { + public @Nullable Map getInvalidReference() { return invalidReference; } - public Map getInvalidMap() { + public @Nullable Map getInvalidMap() { return invalidMap; } - public Map getInvalidArray() { + public @Nullable Map getInvalidArray() { return invalidArray; } - public Map getInvalidBoolean() { + public @Nullable Map getInvalidBoolean() { return invalidBoolean; } - public Map getInvalidInteger() { + public @Nullable Map getInvalidInteger() { return invalidInteger; } - public Map getInvalidNumber() { + public @Nullable Map getInvalidNumber() { return invalidNumber; } - public Map getInvalidDuration() { + public @Nullable Map getInvalidDuration() { return invalidDuration; } - public Map getDefaultValues() { + public @Nullable Map getDefaultValues() { return defaultValues; } diff --git a/core/camel-api/src/main/java/org/apache/camel/catalog/RuntimeCamelCatalog.java b/core/camel-api/src/main/java/org/apache/camel/catalog/RuntimeCamelCatalog.java index dec884fc7d168..3876ab31dbabb 100644 --- a/core/camel-api/src/main/java/org/apache/camel/catalog/RuntimeCamelCatalog.java +++ b/core/camel-api/src/main/java/org/apache/camel/catalog/RuntimeCamelCatalog.java @@ -23,6 +23,7 @@ import org.apache.camel.StaticService; import org.apache.camel.component.extension.ComponentVerifierExtension; import org.apache.camel.spi.SendDynamicAware; +import org.jspecify.annotations.Nullable; /** * Runtime catalog which limited API needed by components that supports {@link ComponentVerifierExtension}. @@ -42,6 +43,7 @@ public interface RuntimeCamelCatalog extends StaticService, CamelContextAware { * @param name the component name * @return component details in JSon */ + @Nullable String componentJSonSchema(String name); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/catalog/package-info.java b/core/camel-api/src/main/java/org/apache/camel/catalog/package-info.java new file mode 100644 index 0000000000000..5126e2c32af90 --- /dev/null +++ b/core/camel-api/src/main/java/org/apache/camel/catalog/package-info.java @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +package org.apache.camel.catalog; + +import org.jspecify.annotations.NullMarked; diff --git a/core/camel-api/src/main/java/org/apache/camel/clock/ContextClock.java b/core/camel-api/src/main/java/org/apache/camel/clock/ContextClock.java index 6ce9dc918165a..c5f6097b2cccd 100644 --- a/core/camel-api/src/main/java/org/apache/camel/clock/ContextClock.java +++ b/core/camel-api/src/main/java/org/apache/camel/clock/ContextClock.java @@ -21,6 +21,7 @@ import java.util.EnumMap; import org.apache.camel.ContextEvents; +import org.jspecify.annotations.Nullable; /** * An event clock that tracks the pass of time for different types of context-related events (see {@link ContextEvents}) @@ -44,7 +45,7 @@ public void add(ContextEvents event, Clock clock) { } @Override - public Clock get(ContextEvents event) { + public @Nullable Clock get(ContextEvents event) { return events.get(event); } diff --git a/core/camel-api/src/main/java/org/apache/camel/clock/EventClock.java b/core/camel-api/src/main/java/org/apache/camel/clock/EventClock.java index 181369042297a..abd3d194a1ac6 100644 --- a/core/camel-api/src/main/java/org/apache/camel/clock/EventClock.java +++ b/core/camel-api/src/main/java/org/apache/camel/clock/EventClock.java @@ -17,6 +17,8 @@ package org.apache.camel.clock; +import org.jspecify.annotations.Nullable; + /** * A specialized clock that tracks the pass of time for one or more types of events * @@ -38,5 +40,6 @@ public interface EventClock> extends Clock { * @param event the event to get the clock for * @return the clock instance or null if not set */ + @Nullable Clock get(T event); } diff --git a/core/camel-api/src/main/java/org/apache/camel/clock/package-info.java b/core/camel-api/src/main/java/org/apache/camel/clock/package-info.java new file mode 100644 index 0000000000000..39b7aea3c8695 --- /dev/null +++ b/core/camel-api/src/main/java/org/apache/camel/clock/package-info.java @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +package org.apache.camel.clock; + +import org.jspecify.annotations.NullMarked; diff --git a/core/camel-api/src/main/java/org/apache/camel/cloudevents/package-info.java b/core/camel-api/src/main/java/org/apache/camel/cloudevents/package-info.java new file mode 100644 index 0000000000000..2b522bdfc8f2d --- /dev/null +++ b/core/camel-api/src/main/java/org/apache/camel/cloudevents/package-info.java @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +package org.apache.camel.cloudevents; + +import org.jspecify.annotations.NullMarked; diff --git a/core/camel-api/src/main/java/org/apache/camel/cluster/package-info.java b/core/camel-api/src/main/java/org/apache/camel/cluster/package-info.java new file mode 100644 index 0000000000000..93a65c4c32f66 --- /dev/null +++ b/core/camel-api/src/main/java/org/apache/camel/cluster/package-info.java @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +package org.apache.camel.cluster; + +import org.jspecify.annotations.NullMarked; diff --git a/core/camel-api/src/main/java/org/apache/camel/component/extension/ComponentVerifierExtension.java b/core/camel-api/src/main/java/org/apache/camel/component/extension/ComponentVerifierExtension.java index 97bc253cf39e6..53a08d1ae654e 100644 --- a/core/camel-api/src/main/java/org/apache/camel/component/extension/ComponentVerifierExtension.java +++ b/core/camel-api/src/main/java/org/apache/camel/component/extension/ComponentVerifierExtension.java @@ -28,6 +28,7 @@ import org.apache.camel.component.extension.ComponentVerifierExtensionHelper.GroupErrorAttribute; import org.apache.camel.component.extension.ComponentVerifierExtensionHelper.HttpErrorAttribute; import org.apache.camel.component.extension.ComponentVerifierExtensionHelper.StandardErrorCode; +import org.jspecify.annotations.Nullable; /** * Defines the interface used for validating component/endpoint parameters. The central method of this interface is @@ -153,6 +154,7 @@ interface VerificationError extends Serializable { * * @return the error description (if available) */ + @Nullable String getDescription(); /** @@ -179,7 +181,7 @@ interface VerificationError extends Serializable { * @param attribute the attribute to lookup * @return the detail value or null if no such attribute exists */ - default Object getDetail(Attribute attribute) { + default @Nullable Object getDetail(Attribute attribute) { Map details = getDetails(); if (details != null) { return details.get(attribute); @@ -193,7 +195,7 @@ default Object getDetail(Attribute attribute) { * @param attribute the attribute to lookup * @return the detail value or null if no such attribute exists */ - default Object getDetail(String attribute) { + default @Nullable Object getDetail(String attribute) { return getDetail(asAttribute(attribute)); } diff --git a/core/camel-api/src/main/java/org/apache/camel/component/extension/MetaDataExtension.java b/core/camel-api/src/main/java/org/apache/camel/component/extension/MetaDataExtension.java index c9f38c8e9592e..78274008dbb6a 100644 --- a/core/camel-api/src/main/java/org/apache/camel/component/extension/MetaDataExtension.java +++ b/core/camel-api/src/main/java/org/apache/camel/component/extension/MetaDataExtension.java @@ -21,6 +21,7 @@ import org.apache.camel.Exchange; import org.apache.camel.TypeConversionException; +import org.jspecify.annotations.Nullable; @Deprecated(since = "4.11.0") public interface MetaDataExtension extends ComponentExtension { @@ -42,6 +43,7 @@ interface MetaData { * @param name the attribute name * @return the attribute */ + @Nullable Object getAttribute(String name); /** @@ -59,13 +61,14 @@ interface MetaData { * for the given name * @throws TypeConversionException is thrown if error during type conversion */ - T getAttribute(String name, Class type); + @Nullable T getAttribute(String name, Class type); /** * Returns the payload of the meta data as a POJO. * * @return the body, can be null */ + @Nullable Object getPayload(); /** @@ -75,6 +78,6 @@ interface MetaData { * @return the payload of the meta data as the specified type. * @throws TypeConversionException is thrown if error during type conversion */ - T getPayload(Class type); + @Nullable T getPayload(Class type); } } diff --git a/core/camel-api/src/main/java/org/apache/camel/component/extension/package-info.java b/core/camel-api/src/main/java/org/apache/camel/component/extension/package-info.java new file mode 100644 index 0000000000000..1bc7fecebbe26 --- /dev/null +++ b/core/camel-api/src/main/java/org/apache/camel/component/extension/package-info.java @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +package org.apache.camel.component.extension; + +import org.jspecify.annotations.NullMarked; diff --git a/core/camel-api/src/main/java/org/apache/camel/console/DevConsoleRegistry.java b/core/camel-api/src/main/java/org/apache/camel/console/DevConsoleRegistry.java index 8a70cdcd8af81..cc5a1b675c6a4 100644 --- a/core/camel-api/src/main/java/org/apache/camel/console/DevConsoleRegistry.java +++ b/core/camel-api/src/main/java/org/apache/camel/console/DevConsoleRegistry.java @@ -25,6 +25,7 @@ import org.apache.camel.StaticService; import org.apache.camel.spi.IdAware; import org.apache.camel.util.ObjectHelper; +import org.jspecify.annotations.Nullable; /** * A registry for dev console. @@ -59,6 +60,7 @@ public interface DevConsoleRegistry extends CamelContextAware, StaticService, Id * * @return either {@link DevConsole}, or null if none found. */ + @Nullable DevConsole resolveById(String id); /** @@ -95,7 +97,7 @@ default Optional getConsole(String id) { * * This registry is not used by the camel context, but it is up to the implementation to properly use it. */ - static DevConsoleRegistry get(CamelContext context) { + static @Nullable DevConsoleRegistry get(CamelContext context) { return context.getCamelContextExtension().getContextPlugin(DevConsoleRegistry.class); } diff --git a/core/camel-api/src/main/java/org/apache/camel/console/DevConsoleResolver.java b/core/camel-api/src/main/java/org/apache/camel/console/DevConsoleResolver.java index 4ff39eff4ec36..dd1f3418d7055 100644 --- a/core/camel-api/src/main/java/org/apache/camel/console/DevConsoleResolver.java +++ b/core/camel-api/src/main/java/org/apache/camel/console/DevConsoleResolver.java @@ -20,6 +20,7 @@ import org.apache.camel.CamelContextAware; import org.apache.camel.StaticService; +import org.jspecify.annotations.Nullable; /** * A pluggable strategy for resolving dev consoles in a loosely coupled manner @@ -32,6 +33,7 @@ public interface DevConsoleResolver extends CamelContextAware, StaticService { * @param id the id of the {@link DevConsole} * @return the resolved {@link DevConsole}, or null if not found */ + @Nullable DevConsole resolveDevConsole(String id); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/console/package-info.java b/core/camel-api/src/main/java/org/apache/camel/console/package-info.java new file mode 100644 index 0000000000000..f0ec3840de36a --- /dev/null +++ b/core/camel-api/src/main/java/org/apache/camel/console/package-info.java @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +package org.apache.camel.console; + +import org.jspecify.annotations.NullMarked; diff --git a/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckHelper.java b/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckHelper.java index d27d7ef14108e..c7ad8652a4f32 100644 --- a/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckHelper.java +++ b/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckHelper.java @@ -28,6 +28,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.util.ObjectHelper; +import org.jspecify.annotations.Nullable; /** * Helper for invoking {@link HealthCheck}'s. @@ -56,7 +57,7 @@ public static Collection invoke(CamelContext camelContext) { * @param camelContext the camel context * @param exposureLevel level of exposure (full, oneline or default) */ - public static Collection invoke(CamelContext camelContext, String exposureLevel) { + public static Collection invoke(CamelContext camelContext, @Nullable String exposureLevel) { return invoke(camelContext, check -> Map.of(HealthCheck.CHECK_KIND, HealthCheck.Kind.ALL), check -> false, exposureLevel); } @@ -75,7 +76,7 @@ public static Collection invokeReadiness(CamelContext camelC * @param camelContext the camel context * @param exposureLevel level of exposure (full, oneline or default) */ - public static Collection invokeReadiness(CamelContext camelContext, String exposureLevel) { + public static Collection invokeReadiness(CamelContext camelContext, @Nullable String exposureLevel) { return invoke(camelContext, check -> Map.of(HealthCheck.CHECK_KIND, HealthCheck.Kind.READINESS), check -> !check.isReadiness(), exposureLevel); } @@ -94,7 +95,7 @@ public static Collection invokeLiveness(CamelContext camelCo * @param camelContext the camel context * @param exposureLevel level of exposure (full, oneline or default) */ - public static Collection invokeLiveness(CamelContext camelContext, String exposureLevel) { + public static Collection invokeLiveness(CamelContext camelContext, @Nullable String exposureLevel) { return invoke(camelContext, check -> Map.of(HealthCheck.CHECK_KIND, HealthCheck.Kind.LIVENESS), check -> !check.isLiveness(), exposureLevel); } @@ -131,7 +132,7 @@ public static Collection invoke( CamelContext camelContext, Function> optionsSupplier, Predicate filter, - String exposureLevel) { + @Nullable String exposureLevel) { final HealthCheckRegistry registry = HealthCheckRegistry.get(camelContext); @@ -206,7 +207,7 @@ public static Optional invoke(CamelContext camelContext, Str * @param context the camel context * @return the health check registry, or null if health-check is not enabled. */ - public static HealthCheckRegistry getHealthCheckRegistry(CamelContext context) { + public static @Nullable HealthCheckRegistry getHealthCheckRegistry(CamelContext context) { return context.getCamelContextExtension().getContextPlugin(HealthCheckRegistry.class); } @@ -217,7 +218,7 @@ public static HealthCheckRegistry getHealthCheckRegistry(CamelContext context) { * @param id the id of the health check * @return the health check, or null if no health check exists with this id */ - public static HealthCheck getHealthCheck(CamelContext context, String id) { + public static @Nullable HealthCheck getHealthCheck(CamelContext context, String id) { HealthCheck answer = null; HealthCheckRegistry hcr = context.getCamelContextExtension().getContextPlugin(HealthCheckRegistry.class); @@ -248,7 +249,7 @@ public static HealthCheck getHealthCheck(CamelContext context, String id) { * @param type the expected type of the health check repository * @return the health check, or null if no health check exists with this id */ - public static T getHealthCheck(CamelContext context, String id, Class type) { + public static @Nullable T getHealthCheck(CamelContext context, String id, Class type) { HealthCheck answer = getHealthCheck(context, id); if (answer != null) { return type.cast(answer); @@ -263,7 +264,7 @@ public static T getHealthCheck(CamelContext context, Str * @param id the id of the health check repository * @return the health check repository, or null if no health check repository exists with this id */ - public static HealthCheckRepository getHealthCheckRepository(CamelContext context, String id) { + public static @Nullable HealthCheckRepository getHealthCheckRepository(CamelContext context, String id) { HealthCheckRepository answer = null; HealthCheckRegistry hcr = context.getCamelContextExtension().getContextPlugin(HealthCheckRegistry.class); @@ -294,7 +295,8 @@ public static HealthCheckRepository getHealthCheckRepository(CamelContext contex * @param type the expected type of the health check repository * @return the health check repository, or null if no health check repository exists with this id */ - public static T getHealthCheckRepository(CamelContext context, String id, Class type) { + public static @Nullable T getHealthCheckRepository( + CamelContext context, String id, Class type) { HealthCheckRepository answer = getHealthCheckRepository(context, id); if (answer != null) { return type.cast(answer); diff --git a/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckRegistry.java b/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckRegistry.java index f48ac1a565a56..4c463fe653237 100644 --- a/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckRegistry.java +++ b/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckRegistry.java @@ -25,6 +25,7 @@ import org.apache.camel.StaticService; import org.apache.camel.spi.IdAware; import org.apache.camel.util.ObjectHelper; +import org.jspecify.annotations.Nullable; /** * A registry for health checks. @@ -61,6 +62,7 @@ public interface HealthCheckRegistry extends CamelContextAware, StaticService, I * * @return either {@link HealthCheck} or {@link HealthCheckRepository}, or null if none found. */ + @Nullable Object resolveById(String id); /** @@ -106,7 +108,7 @@ default Optional getCheck(String id) { * a RouteController could use the registry to decide to restart a route with failing health checks - spring boot * could integrate such checks within its health endpoint or make it available only as separate endpoint. */ - static HealthCheckRegistry get(CamelContext context) { + static @Nullable HealthCheckRegistry get(@Nullable CamelContext context) { return context != null ? context.getCamelContextExtension().getContextPlugin(HealthCheckRegistry.class) : null; } @@ -124,13 +126,14 @@ static HealthCheckRegistry get(CamelContext context) { * Pattern to exclude health checks from being invoked by Camel when checking healths. Multiple patterns can be * separated by comma. */ + @Nullable String getExcludePattern(); /** * Pattern to exclude health checks from being invoked by Camel when checking healths. Multiple patterns can be * separated by comma. */ - void setExcludePattern(String excludePattern); + void setExcludePattern(@Nullable String excludePattern); /** * Whether the given health check has been excluded diff --git a/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckResolver.java b/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckResolver.java index 342102a303bac..3b167772fbbc4 100644 --- a/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckResolver.java +++ b/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckResolver.java @@ -17,6 +17,7 @@ package org.apache.camel.health; import org.apache.camel.CamelContextAware; +import org.jspecify.annotations.Nullable; /** * A pluggable strategy for resolving health checks in a loosely coupled manner @@ -29,6 +30,7 @@ public interface HealthCheckResolver extends CamelContextAware { * @param id the id of the {@link HealthCheck} * @return the resolved {@link HealthCheck}, or null if not found */ + @Nullable HealthCheck resolveHealthCheck(String id); /** @@ -37,6 +39,7 @@ public interface HealthCheckResolver extends CamelContextAware { * @param id the id of the {@link HealthCheckRepository} * @return the resolved {@link HealthCheckRepository}, or null if not found */ + @Nullable HealthCheckRepository resolveHealthCheckRepository(String id); } diff --git a/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckResultBuilder.java b/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckResultBuilder.java index 3aee92b6d6442..f5cf826dddf09 100644 --- a/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckResultBuilder.java +++ b/core/camel-api/src/main/java/org/apache/camel/health/HealthCheckResultBuilder.java @@ -23,6 +23,7 @@ import org.apache.camel.Builder; import org.apache.camel.util.ObjectHelper; +import org.jspecify.annotations.Nullable; /** * A builder helper to create a {@link HealthCheck} result. @@ -30,34 +31,34 @@ public final class HealthCheckResultBuilder implements Builder { private final HealthCheck check; - private String message; - private Throwable error; - private Map details; - private HealthCheck.State state; + private @Nullable String message; + private @Nullable Throwable error; + private @Nullable Map details; + private HealthCheck.@Nullable State state; private HealthCheckResultBuilder(HealthCheck check) { this.check = check; } - public String message() { + public @Nullable String message() { return this.message; } - public HealthCheckResultBuilder message(String message) { + public HealthCheckResultBuilder message(@Nullable String message) { this.message = message; return this; } - public Throwable error() { + public @Nullable Throwable error() { return this.error; } - public HealthCheckResultBuilder error(Throwable error) { + public HealthCheckResultBuilder error(@Nullable Throwable error) { this.error = error; return this; } - public Object detail(String key) { + public @Nullable Object detail(String key) { return this.details != null ? this.details.get(key) : null; } @@ -78,7 +79,7 @@ public HealthCheckResultBuilder details(Map details) { return this; } - public HealthCheck.State state() { + public HealthCheck.@Nullable State state() { return this.state; } diff --git a/core/camel-api/src/main/java/org/apache/camel/health/package-info.java b/core/camel-api/src/main/java/org/apache/camel/health/package-info.java new file mode 100644 index 0000000000000..becfd29bf2119 --- /dev/null +++ b/core/camel-api/src/main/java/org/apache/camel/health/package-info.java @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +package org.apache.camel.health; + +import org.jspecify.annotations.NullMarked; diff --git a/core/camel-api/src/main/java/org/apache/camel/package-info.java b/core/camel-api/src/main/java/org/apache/camel/package-info.java index 7b279bbee92fc..58a81092949b7 100644 --- a/core/camel-api/src/main/java/org/apache/camel/package-info.java +++ b/core/camel-api/src/main/java/org/apache/camel/package-info.java @@ -17,6 +17,9 @@ /** * The core Camel API. */ +@NullMarked @jakarta.xml.bind.annotation.XmlSchema(namespace = "http://camel.apache.org/schema/spring", elementFormDefault = jakarta.xml.bind.annotation.XmlNsForm.QUALIFIED) package org.apache.camel; + +import org.jspecify.annotations.NullMarked; diff --git a/core/camel-api/src/main/java/org/apache/camel/resume/Deserializable.java b/core/camel-api/src/main/java/org/apache/camel/resume/Deserializable.java index 599c170a7b31b..a62002f5fbc13 100644 --- a/core/camel-api/src/main/java/org/apache/camel/resume/Deserializable.java +++ b/core/camel-api/src/main/java/org/apache/camel/resume/Deserializable.java @@ -20,6 +20,8 @@ import java.io.File; import java.nio.ByteBuffer; +import org.jspecify.annotations.Nullable; + public interface Deserializable { /** @@ -28,7 +30,7 @@ public interface Deserializable { * @param buffer the buffer containing the object * @return the deserialized object */ - default Object deserializeObject(ByteBuffer buffer) { + default @Nullable Object deserializeObject(ByteBuffer buffer) { buffer.clear(); int dataType = buffer.getInt(); @@ -65,7 +67,7 @@ default Object deserializeObject(ByteBuffer buffer) { * @param keyBuffer the buffer containing the key data * @return the deserialized object */ - default Object deserializeKey(ByteBuffer keyBuffer) { + default @Nullable Object deserializeKey(ByteBuffer keyBuffer) { return deserializeObject(keyBuffer); } @@ -75,7 +77,7 @@ default Object deserializeKey(ByteBuffer keyBuffer) { * @param valueBuffer the buffer containing the value data * @return the deserialized object */ - default Object deserializeValue(ByteBuffer valueBuffer) { + default @Nullable Object deserializeValue(ByteBuffer valueBuffer) { return deserializeObject(valueBuffer); } diff --git a/core/camel-api/src/main/java/org/apache/camel/resume/Offset.java b/core/camel-api/src/main/java/org/apache/camel/resume/Offset.java index ca05ae67035fc..faa477d78ed82 100644 --- a/core/camel-api/src/main/java/org/apache/camel/resume/Offset.java +++ b/core/camel-api/src/main/java/org/apache/camel/resume/Offset.java @@ -19,6 +19,8 @@ import java.nio.ByteBuffer; +import org.jspecify.annotations.Nullable; + /** * Generic offset without a concrete type * @@ -46,7 +48,7 @@ public interface Offset extends Serializable { * @param tClass type to convert the value to * @return the offset value or null if it cannot be converted */ - default V getValue(Class tClass) { + default @Nullable V getValue(Class tClass) { try { return tClass.cast(getValue()); } catch (ClassCastException e) { diff --git a/core/camel-api/src/main/java/org/apache/camel/resume/Resumable.java b/core/camel-api/src/main/java/org/apache/camel/resume/Resumable.java index dd98f3f47272e..761282859c1c4 100644 --- a/core/camel-api/src/main/java/org/apache/camel/resume/Resumable.java +++ b/core/camel-api/src/main/java/org/apache/camel/resume/Resumable.java @@ -17,6 +17,8 @@ package org.apache.camel.resume; +import org.jspecify.annotations.Nullable; + /** * This provides an interface for resumable objects. Such objects allow its users to address them at a specific offset. * For example, when reading large files, it may be possible to inform the last offset that was read, thus allowing @@ -31,6 +33,7 @@ public interface Resumable { * @return An OffsetKey instance with the addressable part of the object. May return null or an EmptyOffset * depending on the type of the resumable */ + @Nullable OffsetKey getOffsetKey(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/resume/ResumeStrategy.java b/core/camel-api/src/main/java/org/apache/camel/resume/ResumeStrategy.java index eee4389904310..187be962eab47 100644 --- a/core/camel-api/src/main/java/org/apache/camel/resume/ResumeStrategy.java +++ b/core/camel-api/src/main/java/org/apache/camel/resume/ResumeStrategy.java @@ -18,6 +18,7 @@ package org.apache.camel.resume; import org.apache.camel.Service; +import org.jspecify.annotations.Nullable; /** * Defines a strategy for handling resume operations. Implementations can define different ways to handle how to resume @@ -34,7 +35,7 @@ interface UpdateCallBack { * * @param throwable an instance of a Throwable if an exception was thrown during the update process */ - void onUpdate(Throwable throwable); + void onUpdate(@Nullable Throwable throwable); } String DEFAULT_NAME = "resumeStrategy"; @@ -86,7 +87,7 @@ default void loadCache() throws Exception { * @param updateCallBack a callback to be executed after the updated has occurred (null if not available) * @throws Exception if unable to update the offset */ - void updateLastOffset(T offset, UpdateCallBack updateCallBack) throws Exception; + void updateLastOffset(T offset, @Nullable UpdateCallBack updateCallBack) throws Exception; /** * Updates the last processed offset @@ -105,7 +106,7 @@ default void loadCache() throws Exception { * @param updateCallBack a callback to be executed after the updated has occurred (null if not available) * @throws Exception if unable to update the offset */ - void updateLastOffset(OffsetKey offsetKey, Offset offset, UpdateCallBack updateCallBack) throws Exception; + void updateLastOffset(OffsetKey offsetKey, Offset offset, @Nullable UpdateCallBack updateCallBack) throws Exception; void setResumeStrategyConfiguration(ResumeStrategyConfiguration resumeStrategyConfiguration); diff --git a/core/camel-api/src/main/java/org/apache/camel/resume/ResumeStrategyConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/resume/ResumeStrategyConfiguration.java index eb99746fc3b2c..53d439d2045aa 100644 --- a/core/camel-api/src/main/java/org/apache/camel/resume/ResumeStrategyConfiguration.java +++ b/core/camel-api/src/main/java/org/apache/camel/resume/ResumeStrategyConfiguration.java @@ -18,20 +18,21 @@ package org.apache.camel.resume; import org.apache.camel.resume.cache.ResumeCache; +import org.jspecify.annotations.Nullable; /** * Basic configuration holder for resume strategies */ public abstract class ResumeStrategyConfiguration { - private Cacheable.FillPolicy cacheFillPolicy; - private ResumeCache resumeCache; + private Cacheable.@Nullable FillPolicy cacheFillPolicy; + private @Nullable ResumeCache resumeCache; /** * Gets the {@link org.apache.camel.resume.Cacheable.FillPolicy} for the cache used in the strategy * * @return the fill policy to use */ - public Cacheable.FillPolicy getCacheFillPolicy() { + public Cacheable.@Nullable FillPolicy getCacheFillPolicy() { return cacheFillPolicy; } @@ -53,7 +54,7 @@ public void setCacheFillPolicy(Cacheable.FillPolicy cacheFillPolicy) { */ public abstract String resumeStrategyService(); - public ResumeCache getResumeCache() { + public @Nullable ResumeCache getResumeCache() { return resumeCache; } diff --git a/core/camel-api/src/main/java/org/apache/camel/resume/Serializable.java b/core/camel-api/src/main/java/org/apache/camel/resume/Serializable.java index 0103d57e883f3..34496cf2e6495 100644 --- a/core/camel-api/src/main/java/org/apache/camel/resume/Serializable.java +++ b/core/camel-api/src/main/java/org/apache/camel/resume/Serializable.java @@ -21,6 +21,7 @@ import java.nio.ByteBuffer; import org.apache.camel.util.ObjectHelper; +import org.jspecify.annotations.Nullable; /** * An interface that represents resumable objects that can be serialized to a medium @@ -40,7 +41,7 @@ public interface Serializable { * @param obj the object to serialize * @return a ByteBuffer instance with the serialized contents of this object */ - default ByteBuffer serialize(Object obj) { + default @Nullable ByteBuffer serialize(Object obj) { ObjectHelper.notNull(obj, "Cannot perform serialization on a null object"); if (obj instanceof Long value) { diff --git a/core/camel-api/src/main/java/org/apache/camel/resume/cache/ResumeCache.java b/core/camel-api/src/main/java/org/apache/camel/resume/cache/ResumeCache.java index 14afe5981c4d0..51941bf1094b3 100644 --- a/core/camel-api/src/main/java/org/apache/camel/resume/cache/ResumeCache.java +++ b/core/camel-api/src/main/java/org/apache/camel/resume/cache/ResumeCache.java @@ -21,6 +21,7 @@ import java.util.function.Function; import org.apache.camel.resume.ResumeStrategy; +import org.jspecify.annotations.Nullable; /** * This cache stored the resumed data from a {@link ResumeStrategy}. @@ -84,7 +85,7 @@ public interface ResumeCache { * @param clazz the class object representing the value to be obtained * @return the offset value wrapped in an optional */ - T get(K key, Class clazz); + @Nullable T get(K key, Class clazz); /** * Gets the offset entry for the key @@ -92,6 +93,7 @@ public interface ResumeCache { * @param key the key * @return the offset value */ + @Nullable Object get(K key); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/resume/cache/package-info.java b/core/camel-api/src/main/java/org/apache/camel/resume/cache/package-info.java new file mode 100644 index 0000000000000..48d2fc72529bf --- /dev/null +++ b/core/camel-api/src/main/java/org/apache/camel/resume/cache/package-info.java @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +package org.apache.camel.resume.cache; + +import org.jspecify.annotations.NullMarked; diff --git a/core/camel-api/src/main/java/org/apache/camel/resume/package-info.java b/core/camel-api/src/main/java/org/apache/camel/resume/package-info.java new file mode 100644 index 0000000000000..a22f8db94fcd3 --- /dev/null +++ b/core/camel-api/src/main/java/org/apache/camel/resume/package-info.java @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +package org.apache.camel.resume; + +import org.jspecify.annotations.NullMarked; diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/AggregationRepository.java b/core/camel-api/src/main/java/org/apache/camel/spi/AggregationRepository.java index b999765d09049..26eeb38833e8e 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/AggregationRepository.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/AggregationRepository.java @@ -20,6 +20,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.Exchange; +import org.jspecify.annotations.Nullable; /** * Access to a repository to store aggregated exchanges to support pluggable implementations. @@ -40,6 +41,7 @@ public interface AggregationRepository { * @param exchange the aggregated exchange * @return the old exchange if any existed */ + @Nullable Exchange add(CamelContext camelContext, String key, Exchange exchange); /** @@ -51,6 +53,7 @@ public interface AggregationRepository { * @param key the correlation key * @return the exchange, or null if no exchange was previously added */ + @Nullable Exchange get(CamelContext camelContext, String key); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/AsyncProcessorAwaitManager.java b/core/camel-api/src/main/java/org/apache/camel/spi/AsyncProcessorAwaitManager.java index 9bd94216b898f..2bed568ce967a 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/AsyncProcessorAwaitManager.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/AsyncProcessorAwaitManager.java @@ -21,6 +21,7 @@ import org.apache.camel.AsyncProcessor; import org.apache.camel.Exchange; import org.apache.camel.StaticService; +import org.jspecify.annotations.Nullable; /** * A manager to handle async routing engine, when {@link Exchange}s are being handed over from one thread to another, @@ -110,6 +111,7 @@ interface AwaitThread { *

* Is null if message history is disabled. */ + @Nullable String getRouteId(); /** @@ -117,6 +119,7 @@ interface AwaitThread { *

* Is null if message history is disabled. */ + @Nullable String getNodeId(); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/BacklogDebugger.java b/core/camel-api/src/main/java/org/apache/camel/spi/BacklogDebugger.java index a660b43c5e185..f28b6fcdaf4b7 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/BacklogDebugger.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/BacklogDebugger.java @@ -24,6 +24,7 @@ import org.apache.camel.Processor; import org.apache.camel.StatefulService; import org.apache.camel.util.StopWatch; +import org.jspecify.annotations.Nullable; /** * A {@link org.apache.camel.spi.Debugger} that has easy debugging functionality which can be used from JMX with @@ -312,6 +313,7 @@ void setExchangeVariableOnBreakpoint(String nodeId, String variableName, Object * @param id node id for the breakpoint * @return the suspended exchange or null if there isn't one suspended at the given breakpoint. */ + @Nullable Exchange getSuspendedExchange(String id); /** @@ -320,6 +322,7 @@ void setExchangeVariableOnBreakpoint(String nodeId, String variableName, Object * @param id node id for the breakpoint * @return the trace event or null if there isn't one suspended at the given breakpoint. */ + @Nullable BacklogTracerEventMessage getSuspendedBreakpointMessage(String id); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/BacklogTracer.java b/core/camel-api/src/main/java/org/apache/camel/spi/BacklogTracer.java index 95f46b0679b45..384ed1160172e 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/BacklogTracer.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/BacklogTracer.java @@ -19,6 +19,8 @@ import java.util.Collection; import java.util.List; +import org.jspecify.annotations.Nullable; + /** * Backlog tracer that captures the last N messages during routing in a backlog. */ @@ -153,22 +155,24 @@ public interface BacklogTracer { /** * Filter for tracing by route or node id */ + @Nullable String getTracePattern(); /** * Filter for tracing by route or node id */ - void setTracePattern(String tracePattern); + void setTracePattern(@Nullable String tracePattern); /** * Filter for tracing messages */ + @Nullable String getTraceFilter(); /** * Filter for tracing messages */ - void setTraceFilter(String filter); + void setTraceFilter(@Nullable String filter); /** * Gets the trace counter (total number of traced messages) diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/BacklogTracerEventMessage.java b/core/camel-api/src/main/java/org/apache/camel/spi/BacklogTracerEventMessage.java index 8ef5c16479701..80218fe1cb231 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/BacklogTracerEventMessage.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/BacklogTracerEventMessage.java @@ -19,6 +19,7 @@ import java.util.Map; import org.apache.camel.Endpoint; +import org.jspecify.annotations.Nullable; /** * Represents a traced message by the BacklogTracer. @@ -53,6 +54,7 @@ public interface BacklogTracerEventMessage { /** * The location of the trace (source code name:line) if possible. */ + @Nullable String getLocation(); /** @@ -78,21 +80,25 @@ public interface BacklogTracerEventMessage { /** * Node id where the message is being routed to */ + @Nullable String getToNode(); /** * Parent node id for this node */ + @Nullable String getToNodeParentId(); /** * Special for choice where we want to know which when predicate was triggered */ + @Nullable String getToNodeParentWhenId(); /** * Special for choice where we want to know which when predicate was triggered */ + @Nullable String getToNodeParentWhenLabel(); /** @@ -118,6 +124,7 @@ public interface BacklogTracerEventMessage { /** * The correlation id to a parent exchange (if any) */ + @Nullable String getCorrelationExchangeId(); /** @@ -163,17 +170,20 @@ public interface BacklogTracerEventMessage { /** * The exception as XML (exception type, message and stacktrace) */ + @Nullable String getExceptionAsXml(); /** * The exception as JSon (exception type, message and stacktrace) */ + @Nullable String getExceptionAsJSon(); /** * The endpoint uri if this trace is either from a route input (from), or the exchange was sent to an endpoint such * as (to, toD, wireTap) etc. */ + @Nullable String getEndpointUri(); /** @@ -190,6 +200,7 @@ public interface BacklogTracerEventMessage { * @return the address or null if no address can be determined. * @see EndpointServiceLocation */ + @Nullable String getEndpointServiceUrl(); /** @@ -197,6 +208,7 @@ public interface BacklogTracerEventMessage { * * @see EndpointServiceLocation */ + @Nullable String getEndpointServiceProtocol(); /** @@ -207,6 +219,7 @@ public interface BacklogTracerEventMessage { * @return optional metadata or null if no data * @see EndpointServiceLocation */ + @Nullable Map getEndpointServiceMetadata(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/BeanIntrospection.java b/core/camel-api/src/main/java/org/apache/camel/spi/BeanIntrospection.java index ad01fc882b2f7..7b19a0913d6e3 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/BeanIntrospection.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/BeanIntrospection.java @@ -25,6 +25,7 @@ import org.apache.camel.LoggingLevel; import org.apache.camel.StaticService; import org.apache.camel.TypeConverter; +import org.jspecify.annotations.Nullable; /** * Used for introspecting beans properties via Java reflection; such as extracting current property values, or updating @@ -100,7 +101,7 @@ final class MethodInfo { * @param optionPrefix an optional prefix to append the property key * @return true if any properties was found, false otherwise. */ - boolean getProperties(Object target, Map properties, String optionPrefix); + boolean getProperties(Object target, Map properties, @Nullable String optionPrefix); /** * Will inspect the target for properties. @@ -113,7 +114,7 @@ final class MethodInfo { * @param includeNull whether to include null values * @return true if any properties was found, false otherwise. */ - boolean getProperties(Object target, Map properties, String optionPrefix, boolean includeNull); + boolean getProperties(Object target, Map properties, @Nullable String optionPrefix, boolean includeNull); /** * Introspects the given class. @@ -179,7 +180,7 @@ final class MethodInfo { * found matching the property name on the {@code target} bean. For this mode to be triggered the parameters * {@code context} and {@code refName} must NOT be NULL, and {@code value} MUST be NULL. */ - boolean setProperty(CamelContext context, Object target, String name, Object value) throws Exception; + boolean setProperty(CamelContext context, Object target, String name, @Nullable Object value) throws Exception; /** * This method supports three modes to set a property: @@ -195,7 +196,8 @@ final class MethodInfo { * {@code context} and {@code refName} must NOT be NULL, and {@code value} MUST be NULL. */ boolean setProperty( - CamelContext context, TypeConverter typeConverter, Object target, String name, Object value, String refName, + CamelContext context, TypeConverter typeConverter, Object target, String name, @Nullable Object value, + @Nullable String refName, boolean allowBuilderPattern, boolean allowPrivateSetter, boolean ignoreCase) throws Exception; diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/BeanProcessorFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/BeanProcessorFactory.java index 89c9fa69af02d..c56410d3bac15 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/BeanProcessorFactory.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/BeanProcessorFactory.java @@ -21,6 +21,7 @@ import org.apache.camel.BeanScope; import org.apache.camel.CamelContext; import org.apache.camel.Processor; +import org.jspecify.annotations.Nullable; /** * Factory for creating a {@link Processor} that can invoke a method on a bean and supporting using Camel bean parameter @@ -61,8 +62,9 @@ public interface BeanProcessorFactory { * @throws Exception is thrown if error creating the processor */ Processor createBeanProcessor( - CamelContext camelContext, Object bean, String beanType, Class beanClass, String ref, - String method, BeanScope scope) + CamelContext camelContext, @Nullable Object bean, @Nullable String beanType, @Nullable Class beanClass, + @Nullable String ref, + @Nullable String method, BeanScope scope) throws Exception; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/BeanRepository.java b/core/camel-api/src/main/java/org/apache/camel/spi/BeanRepository.java index ecb9ab936753e..1a11d7125daaa 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/BeanRepository.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/BeanRepository.java @@ -20,6 +20,7 @@ import java.util.Set; import org.apache.camel.NoSuchBeanTypeException; +import org.jspecify.annotations.Nullable; /** * Represents a bean repository used to lookup components by name and type. This allows Camel to plugin to third-party @@ -38,6 +39,7 @@ public interface BeanRepository { * @param name the name of the bean * @return the bean from the registry or null if it could not be found */ + @Nullable Object lookupByName(String name); /** @@ -47,7 +49,7 @@ public interface BeanRepository { * @param type the type of the required bean * @return the bean from the registry or null if it could not be found */ - T lookupByNameAndType(String name, Class type); + @Nullable T lookupByNameAndType(String name, Class type); /** * Finds beans in the registry by their type. @@ -71,7 +73,7 @@ public interface BeanRepository { * @param type the type of the beans * @return the single bean instance, or null if none found or there are more than one bean of the given type. */ - default T findSingleByType(Class type) { + default @Nullable T findSingleByType(Class type) { Set set = findByType(type); if (set.size() == 1) { return set.iterator().next(); diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/Breakpoint.java b/core/camel-api/src/main/java/org/apache/camel/spi/Breakpoint.java index a2ef9a890c029..e4a2b45628cd9 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/Breakpoint.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/Breakpoint.java @@ -22,6 +22,7 @@ import org.apache.camel.NamedNode; import org.apache.camel.Processor; import org.apache.camel.spi.CamelEvent.ExchangeEvent; +import org.jspecify.annotations.Nullable; /** * {@link org.apache.camel.spi.Breakpoint} are used by the {@link org.apache.camel.spi.Debugger} API. @@ -92,6 +93,6 @@ enum State { * possible to resolve from tracing * @see ExchangeEvent */ - void onEvent(Exchange exchange, ExchangeEvent event, NamedNode definition); + void onEvent(Exchange exchange, ExchangeEvent event, @Nullable NamedNode definition); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/BulkTypeConverters.java b/core/camel-api/src/main/java/org/apache/camel/spi/BulkTypeConverters.java index 76f475f115d86..8b0bdc09c7c99 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/BulkTypeConverters.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/BulkTypeConverters.java @@ -21,6 +21,7 @@ import org.apache.camel.Ordered; import org.apache.camel.TypeConversionException; import org.apache.camel.TypeConverter; +import org.jspecify.annotations.Nullable; /** * Bulk type converters that often comes out of the box with Apache Camel. Camel does a build phase where the Camel @@ -37,6 +38,7 @@ public interface BulkTypeConverters extends Ordered, TypeConverter { * @param fromType the type to convert from * @return the type converter or null if not found. */ + @Nullable TypeConverter lookup(Class toType, Class fromType); /** @@ -53,7 +55,8 @@ public interface BulkTypeConverters extends Ordered, TypeConverter { * return null. * @throws TypeConversionException is thrown if error during type conversion */ - T convertTo(Class from, Class to, Exchange exchange, Object value) throws TypeConversionException; + @Nullable T convertTo(Class from, Class to, @Nullable Exchange exchange, Object value) + throws TypeConversionException; /** * Tries to convert the value to the specified type, returning null if not possible to convert. @@ -65,7 +68,8 @@ public interface BulkTypeConverters extends Ordered, TypeConverter { * @param value the value to be converted * @return the converted value, or null if not possible to convert */ - default T tryConvertTo(Class from, Class to, Exchange exchange, Object value) throws TypeConversionException { + default @Nullable T tryConvertTo(Class from, Class to, @Nullable Exchange exchange, Object value) + throws TypeConversionException { try { Object t = convertTo(from, to, exchange, value); if (t == Void.class) { diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/CamelBeanPostProcessor.java b/core/camel-api/src/main/java/org/apache/camel/spi/CamelBeanPostProcessor.java index ce38b989e30c5..df8a2a963c6ed 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/CamelBeanPostProcessor.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/CamelBeanPostProcessor.java @@ -17,6 +17,7 @@ package org.apache.camel.spi; import org.apache.camel.BindToRegistry; +import org.jspecify.annotations.Nullable; /** * Bean post processor. @@ -34,7 +35,7 @@ public interface CamelBeanPostProcessor { * subsequent BeanPostProcessors will be invoked * @throws Exception is thrown if error post processing bean */ - default Object postProcessBeforeInitialization(Object bean, String beanName) throws Exception { + default @Nullable Object postProcessBeforeInitialization(Object bean, @Nullable String beanName) throws Exception { return bean; } @@ -49,7 +50,7 @@ default Object postProcessBeforeInitialization(Object bean, String beanName) thr * subsequent BeanPostProcessors will be invoked * @throws Exception is thrown if error post processing bean */ - default Object postProcessAfterInitialization(Object bean, String beanName) throws Exception { + default @Nullable Object postProcessAfterInitialization(Object bean, @Nullable String beanName) throws Exception { return bean; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/CamelBeanPostProcessorInjector.java b/core/camel-api/src/main/java/org/apache/camel/spi/CamelBeanPostProcessorInjector.java index 6c70ab2958129..c9ecebf4243f5 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/CamelBeanPostProcessorInjector.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/CamelBeanPostProcessorInjector.java @@ -19,6 +19,8 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; +import org.jspecify.annotations.Nullable; + /** * Used for custom injection when doing {@link CamelBeanPostProcessor} bean post-processing. Can be used to support * 3rd-party annotations for dependency injections. @@ -32,7 +34,7 @@ public interface CamelBeanPostProcessorInjector { * @param bean the bean instance where the field is present * @param beanName optional bean id of the bean */ - void onFieldInject(Field field, Object bean, String beanName); + void onFieldInject(Field field, Object bean, @Nullable String beanName); /** * Method injection @@ -41,6 +43,6 @@ public interface CamelBeanPostProcessorInjector { * @param bean the bean instance where the method is present * @param beanName optional bean id of the bean */ - void onMethodInject(Method method, Object bean, String beanName); + void onMethodInject(Method method, Object bean, @Nullable String beanName); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/CamelEvent.java b/core/camel-api/src/main/java/org/apache/camel/spi/CamelEvent.java index a1907ed9df8eb..f56368357b3ca 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/CamelEvent.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/CamelEvent.java @@ -21,6 +21,7 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.Route; +import org.jspecify.annotations.Nullable; /** * This interface is implemented by all events. @@ -285,6 +286,7 @@ interface ExchangeFailureEvent extends ExchangeEvent { boolean isDeadLetterChannel(); + @Nullable String getDeadLetterUri(); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/CamelInternalProcessorAdvice.java b/core/camel-api/src/main/java/org/apache/camel/spi/CamelInternalProcessorAdvice.java index d5782b2072d7c..84285c4855cbb 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/CamelInternalProcessorAdvice.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/CamelInternalProcessorAdvice.java @@ -17,6 +17,7 @@ package org.apache.camel.spi; import org.apache.camel.Exchange; +import org.jspecify.annotations.Nullable; /** * An advice (before and after) to execute cross-cutting functionality in the Camel routing engine. @@ -37,6 +38,7 @@ public interface CamelInternalProcessorAdvice { * method, or use null for no state. * @throws Exception is thrown if error during the call. */ + @Nullable T before(Exchange exchange) throws Exception; /** @@ -46,7 +48,7 @@ public interface CamelInternalProcessorAdvice { * @param data the state, if any, returned in the {@link #before(org.apache.camel.Exchange)} method. * @throws Exception is thrown if error during the call. */ - void after(Exchange exchange, T data) throws Exception; + void after(Exchange exchange, @Nullable T data) throws Exception; /** * Whether this advice has state or not. diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/CamelLogger.java b/core/camel-api/src/main/java/org/apache/camel/spi/CamelLogger.java index c6c28aa1625ad..3595dd5754bcf 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/CamelLogger.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/CamelLogger.java @@ -18,6 +18,7 @@ import org.apache.camel.LoggingLevel; import org.apache.camel.util.ObjectHelper; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.Marker; @@ -46,7 +47,7 @@ public CamelLogger(Logger log, LoggingLevel level) { this(log, level, null); } - public CamelLogger(Logger log, LoggingLevel level, String marker) { + public CamelLogger(Logger log, LoggingLevel level, @Nullable String marker) { this.log = log; setLevel(level); setMarker(marker); @@ -60,7 +61,7 @@ public CamelLogger(String logName, LoggingLevel level) { this(logName, level, null); } - public CamelLogger(String logName, LoggingLevel level, String marker) { + public CamelLogger(String logName, LoggingLevel level, @Nullable String marker) { this(LoggerFactory.getLogger(logName), level, marker); } @@ -138,15 +139,15 @@ public void setLogName(String logName) { this.log = LoggerFactory.getLogger(logName); } - public Marker getMarker() { + public @Nullable Marker getMarker() { return marker; } - public void setMarker(Marker marker) { + public void setMarker(@Nullable Marker marker) { this.marker = marker; } - public void setMarker(String marker) { + public void setMarker(@Nullable String marker) { if (ObjectHelper.isNotEmpty(marker)) { this.marker = MarkerFactory.getMarker(marker); } else { @@ -217,7 +218,7 @@ public static void log(Logger log, LoggingLevel level, String message, Throwable } } - public static void log(Logger log, LoggingLevel level, Marker marker, String message, Throwable th) { + public static void log(Logger log, LoggingLevel level, @Nullable Marker marker, String message, Throwable th) { if (marker == null) { log(log, level, message, th); return; diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ClaimCheckRepository.java b/core/camel-api/src/main/java/org/apache/camel/spi/ClaimCheckRepository.java index cc07b5d916608..2357824e2a5f4 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ClaimCheckRepository.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ClaimCheckRepository.java @@ -18,6 +18,7 @@ import org.apache.camel.Exchange; import org.apache.camel.Service; +import org.jspecify.annotations.Nullable; /** * Access to a repository of keys to implement the Claim Check @@ -52,6 +53,7 @@ public interface ClaimCheckRepository extends Service { * * @param key the claim check key */ + @Nullable Exchange get(String key); /** @@ -60,6 +62,7 @@ public interface ClaimCheckRepository extends Service { * @param key the claim check key * @return the removed exchange, or null if the key did not exists. */ + @Nullable Exchange getAndRemove(String key); /** @@ -70,6 +73,7 @@ public interface ClaimCheckRepository extends Service { /** * Pops the repository and returns the latest. Or returns null if the stack is empty. */ + @Nullable Exchange pop(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ClassResolver.java b/core/camel-api/src/main/java/org/apache/camel/spi/ClassResolver.java index fa0897d1ab4ce..8dae03544b2c3 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ClassResolver.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ClassResolver.java @@ -21,6 +21,8 @@ import java.util.Enumeration; import java.util.Set; +import org.jspecify.annotations.Nullable; + /** * A class resolver for loading classes in a loosly coupled manner to cater for different platforms such as standalone, * Spring Boot, Quarkus, JBang etc. @@ -45,6 +47,7 @@ public interface ClassResolver { * @param name the name of the custom classloader * @return the class loader or null if not found */ + @Nullable ClassLoader getClassLoader(String name); /** @@ -53,6 +56,7 @@ public interface ClassResolver { * @param name full qualified name of class * @return the class if resolved, null if not found. */ + @Nullable Class resolveClass(String name); /** @@ -62,7 +66,7 @@ public interface ClassResolver { * @param type the expected type of the class * @return the class if resolved, null if not found. */ - Class resolveClass(String name, Class type); + @Nullable Class resolveClass(String name, Class type); /** * Resolves the given class by its name @@ -71,6 +75,7 @@ public interface ClassResolver { * @param loader use the provided class loader * @return the class if resolved, null if not found. */ + @Nullable Class resolveClass(String name, ClassLoader loader); /** @@ -81,7 +86,7 @@ public interface ClassResolver { * @param loader use the provided class loader * @return the class if resolved, null if not found. */ - Class resolveClass(String name, Class type, ClassLoader loader); + @Nullable Class resolveClass(String name, Class type, ClassLoader loader); /** * Resolves the given class by its name @@ -129,6 +134,7 @@ public interface ClassResolver { * @param uri the uri of the resource * @return as a stream */ + @Nullable InputStream loadResourceAsStream(String uri); /** @@ -137,6 +143,7 @@ public interface ClassResolver { * @param uri the uri of the resource * @return as a URL */ + @Nullable URL loadResourceAsURL(String uri); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/CompilePostProcessor.java b/core/camel-api/src/main/java/org/apache/camel/spi/CompilePostProcessor.java index 0024c25466ab7..18bdfbc6146ab 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/CompilePostProcessor.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/CompilePostProcessor.java @@ -17,6 +17,7 @@ package org.apache.camel.spi; import org.apache.camel.CamelContext; +import org.jspecify.annotations.Nullable; /** * Allows to plugin custom post-processors that are processed after the DSL has loaded the source and compiled into a @@ -41,7 +42,7 @@ public interface CompilePostProcessor { */ void postCompile( CamelContext camelContext, String name, - Class clazz, byte[] byteCode, Object instance) + Class clazz, byte @Nullable [] byteCode, @Nullable Object instance) throws Exception; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ComponentResolver.java b/core/camel-api/src/main/java/org/apache/camel/spi/ComponentResolver.java index d836a74ff526d..3847bf8a02e21 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ComponentResolver.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ComponentResolver.java @@ -18,6 +18,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.Component; +import org.jspecify.annotations.Nullable; /** * Represents a resolver of components from a URI to be able to autoload them using some discovery mechanism. @@ -32,5 +33,6 @@ public interface ComponentResolver { * @return the component which is added to the context or null if it cannot be resolved * @throws Exception is thrown if the component could not be loaded */ + @Nullable Component resolveComponent(String name, CamelContext context) throws Exception; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ConfigurerResolver.java b/core/camel-api/src/main/java/org/apache/camel/spi/ConfigurerResolver.java index 0033d33415755..2e872cd6a1b7c 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ConfigurerResolver.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ConfigurerResolver.java @@ -17,6 +17,7 @@ package org.apache.camel.spi; import org.apache.camel.CamelContext; +import org.jspecify.annotations.Nullable; /** * A pluggable strategy for resolving different configurers in a loosely coupled manner @@ -32,5 +33,6 @@ public interface ConfigurerResolver { * @param context the camel context * @return the resolved configurer, or null if no configurer could be found */ + @Nullable PropertyConfigurer resolvePropertyConfigurer(String name, CamelContext context); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ConsumerCache.java b/core/camel-api/src/main/java/org/apache/camel/spi/ConsumerCache.java index 38be3addd27d3..a99c29ee2d406 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ConsumerCache.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ConsumerCache.java @@ -20,6 +20,7 @@ import org.apache.camel.Exchange; import org.apache.camel.PollingConsumer; import org.apache.camel.Service; +import org.jspecify.annotations.Nullable; /** * Cache containing created {@link PollingConsumer}. @@ -55,6 +56,7 @@ public interface ConsumerCache extends Service { * @param endpoint the endpoint to receive from * @return the message exchange received. */ + @Nullable Exchange receive(Endpoint endpoint); /** @@ -71,6 +73,7 @@ public interface ConsumerCache extends Service { * @return the message exchange if one was available within the timeout period, or null if the * timeout expired */ + @Nullable Exchange receive(Endpoint endpoint, long timeout); /** @@ -84,6 +87,7 @@ public interface ConsumerCache extends Service { * * @return the message exchange if one is immediately available otherwise null */ + @Nullable Exchange receiveNoWait(Endpoint endpoint); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ContentTypeAware.java b/core/camel-api/src/main/java/org/apache/camel/spi/ContentTypeAware.java index d50553c7a69b3..2f498a75ab9ed 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ContentTypeAware.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ContentTypeAware.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * Represents an object that can have an associated content type. Such as a file or http resource. */ @@ -25,6 +27,7 @@ public interface ContentTypeAware { * * @return The content type string. Can be {@code null} if the content type has not been set or is not known. */ + @Nullable String getContentType(); /** @@ -32,5 +35,5 @@ public interface ContentTypeAware { * * @param contentType The content type string */ - void setContentType(String contentType); + void setContentType(@Nullable String contentType); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/Contract.java b/core/camel-api/src/main/java/org/apache/camel/spi/Contract.java index d6383b3ffbb2b..00664e0a8e62e 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/Contract.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/Contract.java @@ -18,6 +18,7 @@ import org.apache.camel.Endpoint; import org.apache.camel.Processor; +import org.jspecify.annotations.Nullable; /** * A Contract which represents the input type and/or output type of the {@link Endpoint} or {@link Processor}. @@ -30,7 +31,7 @@ public class Contract { private boolean validateOutput; private String contractString; - public DataType getInputType() { + public @Nullable DataType getInputType() { return inputType; } @@ -54,7 +55,7 @@ public void setInputType(Class clazz) { this.contractString = null; } - public DataType getOutputType() { + public @Nullable DataType getOutputType() { return outputType; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/DataFormatResolver.java b/core/camel-api/src/main/java/org/apache/camel/spi/DataFormatResolver.java index b2ada308dd81b..aa8aa4cbf9127 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/DataFormatResolver.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/DataFormatResolver.java @@ -17,6 +17,7 @@ package org.apache.camel.spi; import org.apache.camel.CamelContext; +import org.jspecify.annotations.Nullable; /** * Represents a resolver of data formats. @@ -30,5 +31,6 @@ public interface DataFormatResolver { * @param context the camel context * @return the data format or null if not possible to resolve */ + @Nullable DataFormat createDataFormat(String name, CamelContext context); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/DataType.java b/core/camel-api/src/main/java/org/apache/camel/spi/DataType.java index eff7ab184a163..537893173ba29 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/DataType.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/DataType.java @@ -17,6 +17,7 @@ package org.apache.camel.spi; import org.apache.camel.util.StringHelper; +import org.jspecify.annotations.Nullable; /** * Represents the data type URN which is used for message data type contract. @@ -76,7 +77,7 @@ public String getScheme() { return scheme; } - public String getName() { + public @Nullable String getName() { return name; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/DataTypeAware.java b/core/camel-api/src/main/java/org/apache/camel/spi/DataTypeAware.java index 9a22e4c13b211..1ba5a601db80e 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/DataTypeAware.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/DataTypeAware.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * Allows {@link org.apache.camel.Message} to store a {@link DataType} which represents the data type of the Message. * Sometimes message content is marshaled into {@code String}, {@code InputStream} or etc, and the data type structure @@ -44,6 +46,7 @@ public interface DataTypeAware { * * @return data type */ + @Nullable DataType getDataType(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/EndpointServiceLocation.java b/core/camel-api/src/main/java/org/apache/camel/spi/EndpointServiceLocation.java index 1a32da721f9b3..db594c49859a3 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/EndpointServiceLocation.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/EndpointServiceLocation.java @@ -18,6 +18,8 @@ import java.util.Map; +import org.jspecify.annotations.Nullable; + /** * Used for getting information about location to (hosted or external) network services. * @@ -36,11 +38,13 @@ public interface EndpointServiceLocation { * * @return the address or null if no address can be determined. */ + @Nullable String getServiceUrl(); /** * Get the protocol the service is using such as http, amqp, tcp. */ + @Nullable String getServiceProtocol(); /** @@ -50,7 +54,7 @@ public interface EndpointServiceLocation { * * @return optional metadata or null if no data */ - default Map getServiceMetadata() { + default @Nullable Map getServiceMetadata() { return null; } } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/EndpointServiceRegistry.java b/core/camel-api/src/main/java/org/apache/camel/spi/EndpointServiceRegistry.java index 1d70e670fee4d..3b91c96b7261f 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/EndpointServiceRegistry.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/EndpointServiceRegistry.java @@ -20,6 +20,7 @@ import java.util.Map; import org.apache.camel.StaticService; +import org.jspecify.annotations.Nullable; /** * Registry for {@link EndpointServiceLocation} to make it easy to find information about usage of external services @@ -49,11 +50,13 @@ interface EndpointService { * * @return the address or null if no address can be determined. */ + @Nullable String getServiceUrl(); /** * Get the protocol the service is using such as http, amqp, tcp. */ + @Nullable String getServiceProtocol(); /** @@ -63,7 +66,7 @@ interface EndpointService { * * @return optional metadata or null if no data */ - default Map getServiceMetadata() { + default @Nullable Map getServiceMetadata() { return null; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ErrorRegistryEntry.java b/core/camel-api/src/main/java/org/apache/camel/spi/ErrorRegistryEntry.java index b8bb1dea77cf5..076b6e0bc7ed6 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ErrorRegistryEntry.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ErrorRegistryEntry.java @@ -18,6 +18,8 @@ import java.time.Instant; +import org.jspecify.annotations.Nullable; + /** * A snapshot of an error that occurred during message routing. *

@@ -38,6 +40,7 @@ public interface ErrorRegistryEntry { /** * The endpoint URI where the error occurred (if available) */ + @Nullable String endpointUri(); /** @@ -65,12 +68,12 @@ public interface ErrorRegistryEntry { *

* Each element represents one line of the stack trace. */ - String[] stackTrace(); + String @Nullable [] stackTrace(); /** * The message history trace, or {@code null} if message history is not enabled. *

* Each element represents one step in the routing history (e.g. "routeId[nodeId]"). */ - String[] messageHistory(); + String @Nullable [] messageHistory(); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/EventFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/EventFactory.java index af3387fe56327..185af1b4b5233 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/EventFactory.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/EventFactory.java @@ -21,6 +21,7 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.Route; +import org.jspecify.annotations.Nullable; /** * Factory to create {@link CamelEvent events} that are emitted when such an event occur. @@ -303,7 +304,7 @@ public interface EventFactory { */ CamelEvent createExchangeFailureHandlingEvent( Exchange exchange, Processor failureHandler, - boolean deadLetterChannel, String deadLetterUri); + boolean deadLetterChannel, @Nullable String deadLetterUri); /** * Creates an {@link CamelEvent} when an {@link org.apache.camel.Exchange} has failed but was handled by the Camel @@ -320,7 +321,7 @@ CamelEvent createExchangeFailureHandlingEvent( */ CamelEvent createExchangeFailureHandledEvent( Exchange exchange, Processor failureHandler, - boolean deadLetterChannel, String deadLetterUri); + boolean deadLetterChannel, @Nullable String deadLetterUri); /** * Creates an {@link CamelEvent} when an {@link org.apache.camel.Exchange} is about to be redelivered diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ExecutorServiceManager.java b/core/camel-api/src/main/java/org/apache/camel/spi/ExecutorServiceManager.java index 34bdcc3826a6e..4e3ae04c32d27 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ExecutorServiceManager.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ExecutorServiceManager.java @@ -23,6 +23,7 @@ import org.apache.camel.ShutdownableService; import org.apache.camel.StaticService; +import org.jspecify.annotations.Nullable; /** * Strategy to create thread pools. @@ -110,6 +111,7 @@ interface ThreadFactoryListener { * @param id id of the thread pool profile to get * @return the found profile, or null if not found */ + @Nullable ThreadPoolProfile getThreadPoolProfile(String id); /** @@ -218,6 +220,7 @@ interface ThreadFactoryListener { * @param profileId the id of the profile with the thread pool settings to use * @return the created thread pool, or null if the thread pool profile could not be found */ + @Nullable ExecutorService newThreadPool(Object source, String name, String profileId); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ExpressionResultTypeAware.java b/core/camel-api/src/main/java/org/apache/camel/spi/ExpressionResultTypeAware.java index 0e95d606b933b..8ac4084e03da7 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ExpressionResultTypeAware.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ExpressionResultTypeAware.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * Represents an {@link org.apache.camel.Expression} or {@link org.apache.camel.Predicate} that supports a result type. */ @@ -29,6 +31,7 @@ public interface ExpressionResultTypeAware { /** * Gets the result type */ + @Nullable Class getResultType(); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/GroupAware.java b/core/camel-api/src/main/java/org/apache/camel/spi/GroupAware.java index 6df1a6f5d9766..1d8fc9c908323 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/GroupAware.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/GroupAware.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * To allow objects to be injected with an group. */ @@ -26,6 +28,6 @@ public interface GroupAware extends HasGroup { * * @param group the group */ - void setGroup(String group); + void setGroup(@Nullable String group); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/HasGroup.java b/core/camel-api/src/main/java/org/apache/camel/spi/HasGroup.java index f327d4e7f19a6..58cb623ab02a9 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/HasGroup.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/HasGroup.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * A simple marker interface for an object which has belongs to a group Group which is useful for group related * operation such as clustering, JMX style API @@ -27,5 +29,6 @@ public interface HasGroup { * * @return the group */ + @Nullable String getGroup(); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/HeaderFilterStrategy.java b/core/camel-api/src/main/java/org/apache/camel/spi/HeaderFilterStrategy.java index 9a2d6519e3055..8768e0d044a78 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/HeaderFilterStrategy.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/HeaderFilterStrategy.java @@ -17,6 +17,7 @@ package org.apache.camel.spi; import org.apache.camel.Exchange; +import org.jspecify.annotations.Nullable; /** * Interface to allow plug-able implementation to filter header to and from Camel message. @@ -43,7 +44,7 @@ enum Direction { * @param exchange the context to perform filtering * @return true if this header should be filtered (skipped). */ - boolean applyFilterToCamelHeaders(String headerName, Object headerValue, Exchange exchange); + boolean applyFilterToCamelHeaders(String headerName, @Nullable Object headerValue, Exchange exchange); /** * Applies filtering logic to an external message header such as CXF and JMS message that is going to be copied to @@ -57,6 +58,6 @@ enum Direction { * @param exchange the context to perform filtering * @return true if this header should be filtered (skipped). */ - boolean applyFilterToExternalHeaders(String headerName, Object headerValue, Exchange exchange); + boolean applyFilterToExternalHeaders(String headerName, @Nullable Object headerValue, Exchange exchange); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/HeaderFilterStrategyAware.java b/core/camel-api/src/main/java/org/apache/camel/spi/HeaderFilterStrategyAware.java index 3e84e84bc9bd3..4b836e7cde317 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/HeaderFilterStrategyAware.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/HeaderFilterStrategyAware.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * An interface to represent an object which can make use of injected {@link HeaderFilterStrategy}. */ @@ -26,6 +28,7 @@ public interface HeaderFilterStrategyAware { * * @return the strategy */ + @Nullable HeaderFilterStrategy getHeaderFilterStrategy(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/HttpResponseAware.java b/core/camel-api/src/main/java/org/apache/camel/spi/HttpResponseAware.java index a9bf0ebd19a17..2efa06f4ba5eb 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/HttpResponseAware.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/HttpResponseAware.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * Represents an object which is aware of HTTP responses. */ @@ -34,10 +36,11 @@ public interface HttpResponseAware { /** * The HTTP status line */ + @Nullable String getHttpResponseStatus(); /** * Sets the HTTP status line */ - void setHttpResponseStatus(String status); + void setHttpResponseStatus(@Nullable String status); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/InflightRepository.java b/core/camel-api/src/main/java/org/apache/camel/spi/InflightRepository.java index a4704984055ba..046ac36f9a7ef 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/InflightRepository.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/InflightRepository.java @@ -20,6 +20,7 @@ import org.apache.camel.Exchange; import org.apache.camel.StaticService; +import org.jspecify.annotations.Nullable; /** * A repository which tracks in flight {@link Exchange}s. @@ -51,6 +52,7 @@ interface InflightExchange { *

* Is null if message history is disabled. */ + @Nullable String getNodeId(); /** @@ -68,6 +70,7 @@ interface InflightExchange { *

* Is null if message history is disabled. */ + @Nullable String getAtRouteId(); } @@ -166,7 +169,7 @@ interface InflightExchange { * * @param fromRouteId the route id, or null for all routes. */ - Collection browse(String fromRouteId); + Collection browse(@Nullable String fromRouteId); /** * A read-only browser of the {@link InflightExchange}s that are currently inflight. @@ -186,7 +189,7 @@ interface InflightExchange { * @param sortByLongestDuration to sort by the longest duration. Set to true to include the exchanges that * has been inflight the longest time, set to false to sort by exchange id */ - Collection browse(String fromRouteId, int limit, boolean sortByLongestDuration); + Collection browse(@Nullable String fromRouteId, int limit, boolean sortByLongestDuration); /** * Gets the oldest {@link InflightExchange} that are currently inflight that started from the given route. @@ -194,6 +197,7 @@ interface InflightExchange { * @param fromRouteId the route id, or null for all routes. * @return the oldest, or null if none inflight */ - InflightExchange oldest(String fromRouteId); + @Nullable + InflightExchange oldest(@Nullable String fromRouteId); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/InterceptEndpointFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/InterceptEndpointFactory.java index f150e441e72d2..c52158770b7cb 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/InterceptEndpointFactory.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/InterceptEndpointFactory.java @@ -20,6 +20,7 @@ import org.apache.camel.Endpoint; import org.apache.camel.Predicate; import org.apache.camel.Processor; +import org.jspecify.annotations.Nullable; /** * A factory to create {@link Endpoint} which are intercepted. @@ -39,6 +40,6 @@ public interface InterceptEndpointFactory { */ InterceptSendToEndpoint createInterceptSendToEndpoint( CamelContext camelContext, Endpoint endpoint, boolean skip, - Predicate onWhen, Processor before, Processor after); + @Nullable Predicate onWhen, @Nullable Processor before, @Nullable Processor after); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/InterceptSendToEndpoint.java b/core/camel-api/src/main/java/org/apache/camel/spi/InterceptSendToEndpoint.java index 5a4417f353ff7..b8badf4fb22b1 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/InterceptSendToEndpoint.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/InterceptSendToEndpoint.java @@ -19,6 +19,7 @@ import org.apache.camel.Endpoint; import org.apache.camel.Predicate; import org.apache.camel.Processor; +import org.jspecify.annotations.Nullable; /** * This is an endpoint when sending to it, is intercepted and is routed in a detour, with the following flow: before, @@ -34,32 +35,35 @@ public interface InterceptSendToEndpoint extends Endpoint { /** * Optional predicate that must match to trigger this interceptor. */ + @Nullable Predicate getOnWhen(); /** * Optional predicate that must match to trigger this interceptor. */ - void setOnWhen(Predicate onWhen); + void setOnWhen(@Nullable Predicate onWhen); /** * The processor for routing in a detour before sending to the original endpoint. */ + @Nullable Processor getBefore(); /** * Sets the processor for routing in a detour before sending to the original endpoint. */ - void setBefore(Processor before); + void setBefore(@Nullable Processor before); /** * The processor (optional) for routing after sending to the original endpoint. */ + @Nullable Processor getAfter(); /** * Sets the processor (optional) for routing after sending to the original endpoint. */ - void setAfter(Processor after); + void setAfter(@Nullable Processor after); /** * Whether to skip sending to the original endpoint. diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/InterceptStrategy.java b/core/camel-api/src/main/java/org/apache/camel/spi/InterceptStrategy.java index b290b73b4b1bd..6044968658bc4 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/InterceptStrategy.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/InterceptStrategy.java @@ -19,6 +19,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.NamedNode; import org.apache.camel.Processor; +import org.jspecify.annotations.Nullable; /** * The purpose of this interface is to allow an implementation to wrap processors in a route with interceptors. For @@ -48,6 +49,6 @@ public interface InterceptStrategy { */ Processor wrapProcessorInInterceptors( CamelContext context, NamedNode definition, - Processor target, Processor nextTarget) + Processor target, @Nullable Processor nextTarget) throws Exception; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/InternalProcessor.java b/core/camel-api/src/main/java/org/apache/camel/spi/InternalProcessor.java index 3e338080e7dac..92f31c1039b11 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/InternalProcessor.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/InternalProcessor.java @@ -23,6 +23,7 @@ import org.apache.camel.NamedRoute; import org.apache.camel.Processor; import org.apache.camel.Route; +import org.jspecify.annotations.Nullable; /** * Internal {@link Processor} that Camel routing engine used during routing for cross cutting functionality such as: @@ -54,7 +55,7 @@ public interface InternalProcessor extends AsyncProcessor { * @param type the type of the advice * @return the advice if exists, or null if no advices has been added with the given type. */ - T getAdvice(Class type); + @Nullable T getAdvice(Class type); /** * Removes an {@link CamelInternalProcessorAdvice} advice from the list of advices. diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/InternalProcessorFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/InternalProcessorFactory.java index 7344c3a6962a6..b2ebbc38d856c 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/InternalProcessorFactory.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/InternalProcessorFactory.java @@ -26,6 +26,7 @@ import org.apache.camel.Processor; import org.apache.camel.Producer; import org.apache.camel.Route; +import org.jspecify.annotations.Nullable; /** * A factory used internally by Camel to create {@link Processor} and other internal building blocks. This factory is @@ -51,7 +52,8 @@ public interface InternalProcessorFactory { Channel createChannel(CamelContext camelContext); AsyncProducer createInterceptSendToEndpointProcessor( - InterceptSendToEndpoint endpoint, Endpoint delegate, AsyncProducer producer, boolean skip, Predicate onWhen); + InterceptSendToEndpoint endpoint, Endpoint delegate, AsyncProducer producer, boolean skip, + @Nullable Predicate onWhen); AsyncProcessor createWrapProcessor(Processor processor, Processor wrapped); diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/InvokeOnHeaderStrategy.java b/core/camel-api/src/main/java/org/apache/camel/spi/InvokeOnHeaderStrategy.java index 07060b516423a..7f562757c04e4 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/InvokeOnHeaderStrategy.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/InvokeOnHeaderStrategy.java @@ -18,6 +18,7 @@ import org.apache.camel.AsyncCallback; import org.apache.camel.Exchange; +import org.jspecify.annotations.Nullable; /** * Pluggable strategy for invoking {@link InvokeOnHeader}. @@ -39,5 +40,6 @@ public interface InvokeOnHeaderStrategy { * returned, then this value is stored as result on the message body. * @throws Exception is thrown if error invoking the method. */ + @Nullable Object invoke(Object target, String key, Exchange exchange, AsyncCallback callback) throws Exception; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/LanguageCustomizer.java b/core/camel-api/src/main/java/org/apache/camel/spi/LanguageCustomizer.java index 970fbf25a914a..33953efe2cce5 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/LanguageCustomizer.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/LanguageCustomizer.java @@ -23,6 +23,7 @@ import org.apache.camel.util.ObjectHelper; import org.apache.camel.util.function.ThrowingBiConsumer; import org.apache.camel.util.function.ThrowingConsumer; +import org.jspecify.annotations.Nullable; /** * To apply custom configurations to {@link Language} instances. @@ -139,7 +140,7 @@ public boolean test(String s, Language target) { */ class Builder { private final Class type; - private BiPredicate condition; + private @Nullable BiPredicate condition; private int order; public Builder(Class type) { 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 c035c773be147..737de85ab25da 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 @@ -26,6 +26,7 @@ import org.apache.camel.Route; import org.apache.camel.Service; import org.apache.camel.VetoCamelContextStartException; +import org.jspecify.annotations.Nullable; /** * Strategy for lifecycle notifications. @@ -144,7 +145,7 @@ default void onLanguageCreated(String name, Language language) { * @param service the added service * @param route the route the service belongs to if any possible to determine */ - void onServiceAdd(CamelContext context, Service service, Route route); + void onServiceAdd(CamelContext context, Service service, @Nullable Route route); /** * Notification on removing a {@link Service}. @@ -153,7 +154,7 @@ default void onLanguageCreated(String name, Language language) { * @param service the removed service * @param route the route the service belongs to if any possible to determine */ - void onServiceRemove(CamelContext context, Service service, Route route); + void onServiceRemove(CamelContext context, Service service, @Nullable Route route); /** * Notification on removing a {@link Service}. @@ -163,7 +164,7 @@ default void onLanguageCreated(String name, Language language) { * @param route the route the service belongs to if any possible to determine * @param shutdown whether camel is being shutdown */ - default void onServiceRemove(CamelContext context, Service service, Route route, boolean shutdown) { + default void onServiceRemove(CamelContext context, Service service, @Nullable Route route, boolean shutdown) { onServiceRemove(context, service, route); } @@ -199,8 +200,8 @@ default void onServiceRemove(CamelContext context, Service service, Route route, * @param threadPoolProfileId id of the thread pool profile, if used for creating this thread pool (can be null) */ void onThreadPoolAdd( - CamelContext camelContext, ThreadPoolExecutor threadPool, String id, - String sourceId, String routeId, String threadPoolProfileId); + CamelContext camelContext, ThreadPoolExecutor threadPool, @Nullable String id, + @Nullable String sourceId, @Nullable String routeId, @Nullable String threadPoolProfileId); /** * Notification on removing a thread pool. @@ -222,8 +223,8 @@ void onThreadPoolAdd( * @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, String id, - String sourceId, String routeId, String threadPoolProfileId) { + CamelContext camelContext, ExecutorService executorService, @Nullable String id, + @Nullable String sourceId, @Nullable String routeId, @Nullable String threadPoolProfileId) { } /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/LocalBeanRepositoryAware.java b/core/camel-api/src/main/java/org/apache/camel/spi/LocalBeanRepositoryAware.java index f9a2c747f330f..71c0e436c53b8 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/LocalBeanRepositoryAware.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/LocalBeanRepositoryAware.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * Allows a {@link BeanRepository} to temporary have a local repository take precedence, such as when creating route * templates to give more flexibility. @@ -27,11 +29,12 @@ public interface LocalBeanRepositoryAware { * * @param repository the local repository, or null to unset when no longer needed. */ - void setLocalBeanRepository(BeanRepository repository); + void setLocalBeanRepository(@Nullable BeanRepository repository); /** * Gets the local bean repository (if any in use) */ + @Nullable BeanRepository getLocalBeanRepository(); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementAgent.java b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementAgent.java index 96b90989f8140..07196df0516c4 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementAgent.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementAgent.java @@ -23,6 +23,7 @@ import org.apache.camel.ManagementMBeansLevel; import org.apache.camel.ManagementStatisticsLevel; import org.apache.camel.Service; +import org.jspecify.annotations.Nullable; /** * Camel JMX service agent @@ -74,7 +75,7 @@ public interface ManagementAgent extends Service { * @param mbean the client interface, such as from the {@link org.apache.camel.api.management.mbean} package. * @return the client or null if mbean does not exist */ - T newProxyClient(ObjectName name, Class mbean); + @Nullable T newProxyClient(ObjectName name, Class mbean); /** * Get the MBeanServer which hosts managed objects. @@ -84,6 +85,7 @@ public interface ManagementAgent extends Service { * * @return the MBeanServer */ + @Nullable MBeanServer getMBeanServer(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementInterceptStrategy.java b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementInterceptStrategy.java index 828c080063b61..a0f96c5e751fb 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementInterceptStrategy.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementInterceptStrategy.java @@ -21,21 +21,25 @@ import org.apache.camel.NamedNode; import org.apache.camel.Ordered; import org.apache.camel.Processor; +import org.jspecify.annotations.Nullable; /** * A specialized {@link InterceptStrategy} which is used for JMX management for EIPs. */ public interface ManagementInterceptStrategy { + @Nullable InstrumentationProcessor createProcessor(NamedNode definition, Processor target); + @Nullable InstrumentationProcessor createProcessor(String type); interface InstrumentationProcessor extends AsyncProcessor, Ordered { + @Nullable T before(Exchange exchange); - void after(Exchange exchange, T data); + void after(Exchange exchange, @Nullable T data); void setProcessor(Processor processor); diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementMBeanAssembler.java b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementMBeanAssembler.java index b3d158aeefb17..7584e8464fac2 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementMBeanAssembler.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementMBeanAssembler.java @@ -22,6 +22,7 @@ import javax.management.modelmbean.ModelMBean; import org.apache.camel.StaticService; +import org.jspecify.annotations.Nullable; /** * An assembler to assemble a {@link javax.management.modelmbean.RequiredModelMBean} which can be used to register the @@ -39,6 +40,7 @@ public interface ManagementMBeanAssembler extends StaticService { * possible to assemble an MBean * @throws JMException is thrown if error assembling the mbean */ + @Nullable ModelMBean assemble(MBeanServer mBeanServer, Object obj, ObjectName name) throws JMException; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementNameStrategy.java b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementNameStrategy.java index a5afb8dd64ecb..b0b6207d413cb 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementNameStrategy.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementNameStrategy.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * Strategy for assigning the name part of the {@link javax.management.ObjectName} for a managed * {@link org.apache.camel.CamelContext}. @@ -41,6 +43,7 @@ public interface ManagementNameStrategy { * * @return the custom name pattern, or null if using the default pattern strategy. */ + @Nullable String getNamePattern(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementObjectNameStrategy.java b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementObjectNameStrategy.java index 64bd66b15e953..a8ae8a6cf75db 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementObjectNameStrategy.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementObjectNameStrategy.java @@ -32,12 +32,14 @@ import org.apache.camel.Route; import org.apache.camel.Service; import org.apache.camel.cluster.CamelClusterService; +import org.jspecify.annotations.Nullable; /** * Strategy for computing {@link ObjectName} names for the various beans that Camel register for management. */ public interface ManagementObjectNameStrategy { + @Nullable ObjectName getObjectName(Object managedObject) throws MalformedObjectNameException; ObjectName getObjectNameForCamelContext(String managementName, String name) throws MalformedObjectNameException; @@ -79,7 +81,7 @@ ObjectName getObjectNameForClusterService(CamelContext context, CamelClusterServ ObjectName getObjectNameForThreadPool(CamelContext context, ThreadPoolExecutor threadPool, String id, String sourceId) throws MalformedObjectNameException; - default ObjectName getObjectNameForThreadPool( + default @Nullable ObjectName getObjectNameForThreadPool( CamelContext context, ExecutorService executorService, String id, String sourceId) throws MalformedObjectNameException { return null; diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementObjectStrategy.java b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementObjectStrategy.java index 1a44a9887c0f1..26e1792958b3a 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementObjectStrategy.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementObjectStrategy.java @@ -30,6 +30,7 @@ import org.apache.camel.Service; import org.apache.camel.cluster.CamelClusterService; import org.apache.camel.health.HealthCheckRegistry; +import org.jspecify.annotations.Nullable; /** * Strategy for creating the managed object for the various beans Camel register for management. @@ -68,7 +69,7 @@ Object getManagedObjectForThreadPool( CamelContext context, ThreadPoolExecutor threadPool, String id, String sourceId, String routeId, String threadPoolProfileId); - default Object getManagedObjectForThreadPool( + default @Nullable Object getManagedObjectForThreadPool( CamelContext context, ExecutorService executorService, String id, String sourceId, String routeId, String threadPoolProfileId) { return null; diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementStrategyFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementStrategyFactory.java index 444cb9cd2d982..7666c72b07ca9 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ManagementStrategyFactory.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ManagementStrategyFactory.java @@ -19,6 +19,7 @@ import java.util.Map; import org.apache.camel.CamelContext; +import org.jspecify.annotations.Nullable; /** * Service Factory for ManagementStrategy @@ -53,6 +54,6 @@ public interface ManagementStrategyFactory { * @param strategy the management strategy * @param lifecycle the associated lifecycle strategy (optional) */ - void setupManagement(CamelContext camelContext, ManagementStrategy strategy, LifecycleStrategy lifecycle); + void setupManagement(CamelContext camelContext, ManagementStrategy strategy, @Nullable LifecycleStrategy lifecycle); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/MessageHistoryFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/MessageHistoryFactory.java index c3b7123bb709f..fe7ab740dc123 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/MessageHistoryFactory.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/MessageHistoryFactory.java @@ -21,6 +21,7 @@ import org.apache.camel.MessageHistory; import org.apache.camel.NamedNode; import org.apache.camel.StaticService; +import org.jspecify.annotations.Nullable; /** * A factory to create {@link MessageHistory} instances. @@ -56,6 +57,7 @@ public interface MessageHistoryFactory extends StaticService, CamelContextAware * only include nodes that are Step EIPs then use the EIP shortname, eg step. You can also include multiple nodes * separated by comma, eg step,wiretap,to */ + @Nullable String getNodePattern(); /** @@ -63,6 +65,6 @@ public interface MessageHistoryFactory extends StaticService, CamelContextAware * only include nodes that are Step EIPs then use the EIP shortname, eg step. You can also include multiple nodes * separated by comma, eg step,wiretap,to */ - void setNodePattern(String nodePattern); + void setNodePattern(@Nullable String nodePattern); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/MockSendToEndpointStrategyFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/MockSendToEndpointStrategyFactory.java index 781c4245e8f9c..b928475f4000a 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/MockSendToEndpointStrategyFactory.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/MockSendToEndpointStrategyFactory.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * Factory for intercepting sending to endpoint pattern and sending to mock component. This requires having camel-mock * on the classpath. @@ -31,6 +33,6 @@ public interface MockSendToEndpointStrategyFactory { * @param skip whether to skip sending to original endpoint (only to mock endpoint). * @return the endpoint strategy that intercepts. */ - EndpointStrategy mock(String pattern, boolean skip); + EndpointStrategy mock(@Nullable String pattern, boolean skip); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ModelDumpLine.java b/core/camel-api/src/main/java/org/apache/camel/spi/ModelDumpLine.java index 8b880b6500c2f..3aa638bb97c4e 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ModelDumpLine.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ModelDumpLine.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * Represents a line in a model dumper of the route structure (not with full details like a XML or YAML dump). * @@ -25,5 +27,5 @@ * @param level indent level of the EIP node * @param code EIP code such as label or short name that is human-readable or pseudocode */ -public record ModelDumpLine(String location, String type, String id, int level, String code) { +public record ModelDumpLine(@Nullable String location, String type, String id, int level, String code) { } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/OAuthClientConfig.java b/core/camel-api/src/main/java/org/apache/camel/spi/OAuthClientConfig.java index 3de233754e6c8..cea81550e705c 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/OAuthClientConfig.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/OAuthClientConfig.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * Configuration for OAuth 2.0 Client Credentials grant. *

@@ -24,15 +26,15 @@ */ public class OAuthClientConfig { - private String clientId; - private String clientSecret; - private String tokenEndpoint; - private String scope; + private @Nullable String clientId; + private @Nullable String clientSecret; + private @Nullable String tokenEndpoint; + private @Nullable String scope; private boolean cacheTokens = true; private long cachedTokensDefaultExpirySeconds = 3600; private long cachedTokensExpirationMarginSeconds = 5; - public String getClientId() { + public @Nullable String getClientId() { return clientId; } @@ -41,7 +43,7 @@ public OAuthClientConfig setClientId(String clientId) { return this; } - public String getClientSecret() { + public @Nullable String getClientSecret() { return clientSecret; } @@ -50,7 +52,7 @@ public OAuthClientConfig setClientSecret(String clientSecret) { return this; } - public String getTokenEndpoint() { + public @Nullable String getTokenEndpoint() { return tokenEndpoint; } @@ -59,11 +61,11 @@ public OAuthClientConfig setTokenEndpoint(String tokenEndpoint) { return this; } - public String getScope() { + public @Nullable String getScope() { return scope; } - public OAuthClientConfig setScope(String scope) { + public OAuthClientConfig setScope(@Nullable String scope) { this.scope = scope; return this; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/OptimisticLockingAggregationRepository.java b/core/camel-api/src/main/java/org/apache/camel/spi/OptimisticLockingAggregationRepository.java index a91d1e3fac3ba..ac885e02c9c71 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/OptimisticLockingAggregationRepository.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/OptimisticLockingAggregationRepository.java @@ -20,6 +20,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.Exchange; +import org.jspecify.annotations.Nullable; /** * A specialized {@link org.apache.camel.spi.AggregationRepository} which also supports optimistic locking. @@ -74,7 +75,8 @@ class OptimisticLockingException extends RuntimeException { * @throws OptimisticLockingException This should be thrown when the currently stored exchange differs from the * supplied oldExchange. */ - Exchange add(CamelContext camelContext, String key, Exchange oldExchange, Exchange newExchange) + @Nullable + Exchange add(CamelContext camelContext, String key, @Nullable Exchange oldExchange, Exchange newExchange) throws OptimisticLockingException; /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/PeriodTaskScheduler.java b/core/camel-api/src/main/java/org/apache/camel/spi/PeriodTaskScheduler.java index 61b35fc7e2748..c57bafd33d9eb 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/PeriodTaskScheduler.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/PeriodTaskScheduler.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * A shared scheduler to run small period tasks, such as updating internal statistics, or for custom components to have * a background task. @@ -49,6 +51,6 @@ public interface PeriodTaskScheduler { * @param type the type of the task * @return the task, or null if no tasks exists */ - T getTaskByType(Class type); + @Nullable T getTaskByType(Class type); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/PluginManager.java b/core/camel-api/src/main/java/org/apache/camel/spi/PluginManager.java index 8cbd505a87bce..cfc94a7dcf61a 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/PluginManager.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/PluginManager.java @@ -18,6 +18,8 @@ import java.util.function.Supplier; +import org.jspecify.annotations.Nullable; + /** * A manager for internal plugins. This is part of the internal Camel API and not meant for public usage. */ @@ -29,7 +31,7 @@ public interface PluginManager { * @param type the type of the extension * @return the extension, or null if no extension has been installed. */ - T getContextPlugin(Class type); + @Nullable T getContextPlugin(Class type); /** * Whether a plugin of the given type is already in use diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/PollDynamicAware.java b/core/camel-api/src/main/java/org/apache/camel/spi/PollDynamicAware.java index 9e6b22d6cd332..b01abcf268b86 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/PollDynamicAware.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/PollDynamicAware.java @@ -22,6 +22,7 @@ import org.apache.camel.Endpoint; import org.apache.camel.Exchange; import org.apache.camel.Service; +import org.jspecify.annotations.Nullable; /** * Used for components that can optimise the usage of {@link org.apache.camel.processor.PollProcessor} (poll/pollEnrich) @@ -114,6 +115,7 @@ public Map getLenientProperties() { * @return the static uri, or null to not let poll/pollEnrich use this optimisation. * @throws Exception is thrown if error resolving the static uri. */ + @Nullable String resolveStaticUri(Exchange exchange, DynamicAwareEntry entry) throws Exception; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/PooledObjectFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/PooledObjectFactory.java index 6b3053aa63252..d19179fbbd050 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/PooledObjectFactory.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/PooledObjectFactory.java @@ -18,6 +18,7 @@ import org.apache.camel.CamelContextAware; import org.apache.camel.Service; +import org.jspecify.annotations.Nullable; /** * Factory for pooled objects or tasks. @@ -96,6 +97,7 @@ interface Statistics { * * @return the statistics, or null if statistics is not enabled */ + @Nullable Statistics getStatistics(); /** @@ -108,6 +110,7 @@ interface Statistics { * * @return the object or null if the pool is empty */ + @Nullable T acquire(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/PredicateExceptionFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/PredicateExceptionFactory.java index 8e70a5ca9900c..44b0124c0425e 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/PredicateExceptionFactory.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/PredicateExceptionFactory.java @@ -18,6 +18,7 @@ import org.apache.camel.Exchange; import org.apache.camel.Predicate; +import org.jspecify.annotations.Nullable; /** * A factory that can be used to create a specific exception when a {@link Predicate} returning false, which can be used @@ -34,6 +35,7 @@ public interface PredicateExceptionFactory { * @return the exception, or null to not use a specific exception but let Camel use a standard * exception such as PredicateValidationException. */ - Exception newPredicateException(Exchange exchange, Predicate predicate, String nodeId); + @Nullable + Exception newPredicateException(Exchange exchange, Predicate predicate, @Nullable String nodeId); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ProcessorFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/ProcessorFactory.java index 56355c9ad1617..9a00403ae8ac9 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ProcessorFactory.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ProcessorFactory.java @@ -20,6 +20,7 @@ import org.apache.camel.NamedNode; import org.apache.camel.Processor; import org.apache.camel.Route; +import org.jspecify.annotations.Nullable; /** * A factory to create {@link Processor} based on the {@link org.apache.camel.model.ProcessorDefinition definition}. @@ -52,6 +53,7 @@ public interface ProcessorFactory { * processor. * @throws Exception can be thrown if error creating the processor */ + @Nullable Processor createChildProcessor(Route route, NamedNode definition, boolean mandatory) throws Exception; /** @@ -63,6 +65,7 @@ public interface ProcessorFactory { * processor. * @throws Exception can be thrown if error creating the processor */ + @Nullable Processor createProcessor(Route route, NamedNode definition) throws Exception; /** @@ -75,6 +78,7 @@ public interface ProcessorFactory { * @return the created processor, or null if this situation is not yet implemented. * @throws Exception can be thrown if error creating the processor */ + @Nullable Processor createProcessor(CamelContext camelContext, String definitionName, Object[] args) throws Exception; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ProducerCache.java b/core/camel-api/src/main/java/org/apache/camel/spi/ProducerCache.java index fb841d2b50b35..0aa0248e3f418 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ProducerCache.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ProducerCache.java @@ -28,6 +28,7 @@ import org.apache.camel.Processor; import org.apache.camel.Producer; import org.apache.camel.Service; +import org.jspecify.annotations.Nullable; /** * Cache containing created {@link Producer}. @@ -64,7 +65,7 @@ public interface ProducerCache extends Service { * @param exchange the exchange to send * @throws RejectedExecutionException is thrown if CamelContext is stopped */ - Exchange send(Endpoint endpoint, Exchange exchange, Processor resultProcessor); + Exchange send(Endpoint endpoint, Exchange exchange, @Nullable Processor resultProcessor); /** * Asynchronously sends an exchange to an endpoint using a supplied {@link Processor} to populate the exchange @@ -84,7 +85,8 @@ public interface ProducerCache extends Service { */ CompletableFuture asyncSendExchange( Endpoint endpoint, ExchangePattern pattern, - Processor processor, Processor resultProcessor, Exchange exchange, CompletableFuture future); + Processor processor, @Nullable Processor resultProcessor, @Nullable Exchange exchange, + @Nullable CompletableFuture future); /** * Gets the source which uses this cache diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/PropertiesComponent.java b/core/camel-api/src/main/java/org/apache/camel/spi/PropertiesComponent.java index fc1d586cfc016..250731b7128a4 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/PropertiesComponent.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/PropertiesComponent.java @@ -25,6 +25,7 @@ import org.apache.camel.PropertiesLookupListener; import org.apache.camel.StaticService; +import org.jspecify.annotations.Nullable; /** * Component for property placeholders and loading properties from sources (such as .properties file from classpath or @@ -197,6 +198,7 @@ default Map loadPropertiesAsMap(Predicate filter) { * @param name the name of the source * @return the source, or null if no source exists */ + @Nullable PropertiesSource getPropertiesSource(String name); /** @@ -215,6 +217,7 @@ default Map loadPropertiesAsMap(Predicate filter) { * @param name the function name * @return the function or null if no function exists */ + @Nullable PropertiesFunction getPropertiesFunction(String name); /** @@ -269,12 +272,13 @@ default Map loadPropertiesAsMap(Predicate filter) { * Sets a special list of local properties (ie thread local) that take precedence and will use first, if a property * exist. */ - void setLocalProperties(Properties localProperties); + void setLocalProperties(@Nullable Properties localProperties); /** * Gets a list of properties that are local for the current thread only (ie thread local), or null if not * currently in use. */ + @Nullable Properties getLocalProperties(); /** @@ -284,7 +288,7 @@ default Map loadPropertiesAsMap(Predicate filter) { * @return a {@link Map} representing the local properties, or null if not currently in use. */ @SuppressWarnings("unchecked") - default Map getLocalPropertiesAsMap() { + default @Nullable Map getLocalPropertiesAsMap() { return (Map) getLocalProperties(); } @@ -304,7 +308,7 @@ default Map getLocalPropertiesAsMap() { * @param pattern patterns, or null to reload from all known locations * @return true if some properties was reloaded */ - boolean reloadProperties(String pattern); + boolean reloadProperties(@Nullable String pattern); /** * Filters the given list of properties, by removing properties that are already loaded and have same key and value. diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/PropertiesResolvedValue.java b/core/camel-api/src/main/java/org/apache/camel/spi/PropertiesResolvedValue.java index 2863b5065f78a..03b9c934932d8 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/PropertiesResolvedValue.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/PropertiesResolvedValue.java @@ -16,9 +16,12 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * Data about a {@link PropertiesComponent} property placeholder that has been resolved to a value by Camel. */ -public record PropertiesResolvedValue(String name, String originalValue, String value, String defaultValue, String source) { +public record PropertiesResolvedValue(String name, String originalValue, String value, @Nullable String defaultValue, + @Nullable String source) { } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/PropertiesSource.java b/core/camel-api/src/main/java/org/apache/camel/spi/PropertiesSource.java index 0e0a6ff3db0a7..61ac1eaa0ba3b 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/PropertiesSource.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/PropertiesSource.java @@ -17,6 +17,7 @@ package org.apache.camel.spi; import org.apache.camel.Ordered; +import org.jspecify.annotations.Nullable; /** * A source for properties. @@ -37,6 +38,7 @@ public interface PropertiesSource { * @param name name of property * @return the property value, or null if no property exists */ + @Nullable String getProperty(String name); /** @@ -46,7 +48,7 @@ public interface PropertiesSource { * @param defaultValue default value to use as fallback * @return the property value, or null if no property exists */ - default String getProperty(String name, String defaultValue) { + default @Nullable String getProperty(String name, @Nullable String defaultValue) { return getProperty(name); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/PropertyConfigurerAware.java b/core/camel-api/src/main/java/org/apache/camel/spi/PropertyConfigurerAware.java index 6c1b7639b41f6..832675254496d 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/PropertyConfigurerAware.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/PropertyConfigurerAware.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * An interface to represent an object which is capable of configuring via {@link PropertyConfigurer}. */ @@ -26,6 +28,7 @@ public interface PropertyConfigurerAware { * * @param instance the bean instance */ + @Nullable PropertyConfigurer getPropertyConfigurer(Object instance); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/PropertyConfigurerGetter.java b/core/camel-api/src/main/java/org/apache/camel/spi/PropertyConfigurerGetter.java index ee617212e4e0d..79f7eb548263b 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/PropertyConfigurerGetter.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/PropertyConfigurerGetter.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * A marker interface to identify the object as being a configurer which can provide details about the options the * configurer supports. @@ -34,6 +36,7 @@ public interface PropertyConfigurerGetter { * @param name the property name * @return the class type, or null if no option exists with the name */ + @Nullable Class getOptionType(String name, boolean ignoreCase); /** @@ -41,7 +44,7 @@ public interface PropertyConfigurerGetter { * * @return the names as an array, or null if there are no autowire options. */ - default String[] getAutowiredNames() { + default String @Nullable [] getAutowiredNames() { return null; } @@ -56,7 +59,7 @@ default String[] getAutowiredNames() { * @return the class type, or null if the option is not a collection kind or not possible to * determine */ - default Object getCollectionValueType(Object target, String name, boolean ignoreCase) { + default @Nullable Object getCollectionValueType(Object target, String name, boolean ignoreCase) { return null; } @@ -69,6 +72,7 @@ default Object getCollectionValueType(Object target, String name, boolean ignore * @param ignoreCase whether to ignore case for matching the property name * @return the property value */ + @Nullable Object getOptionValue(Object target, String name, boolean ignoreCase); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/RecoverableAggregationRepository.java b/core/camel-api/src/main/java/org/apache/camel/spi/RecoverableAggregationRepository.java index b570fc0052f8e..4379bd2aefba5 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/RecoverableAggregationRepository.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/RecoverableAggregationRepository.java @@ -21,6 +21,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.Exchange; +import org.jspecify.annotations.Nullable; /** * A specialized {@link org.apache.camel.spi.AggregationRepository} which also supports recovery. This usually requires @@ -43,6 +44,7 @@ public interface RecoverableAggregationRepository extends AggregationRepository * @param exchangeId exchange id * @return the recovered exchange or null if not found */ + @Nullable Exchange recover(CamelContext camelContext, String exchangeId); /** @@ -101,13 +103,14 @@ default long getRecoveryIntervalInMillis() { * * @param deadLetterUri the uri of the dead letter channel */ - void setDeadLetterUri(String deadLetterUri); + void setDeadLetterUri(@Nullable String deadLetterUri); /** * Gets the dead letter channel * * @return the uri of the dead letter channel */ + @Nullable String getDeadLetterUri(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/Registry.java b/core/camel-api/src/main/java/org/apache/camel/spi/Registry.java index 48601f45adeae..345d50bfbe254 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/Registry.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/Registry.java @@ -20,6 +20,7 @@ import org.apache.camel.CamelContextAware; import org.apache.camel.RuntimeCamelException; +import org.jspecify.annotations.Nullable; /** * Represents a {@link BeanRepository} which may also be capable of binding beans to its repository. @@ -52,7 +53,8 @@ default void bind(String id, Object bean) throws RuntimeCamelException { * @param destroyMethod optional destroy method (invoked at unbind or stopping Camel) * @throws RuntimeCamelException is thrown if binding is not possible */ - default void bind(String id, Object bean, String initMethod, String destroyMethod) throws RuntimeCamelException { + default void bind(String id, Object bean, @Nullable String initMethod, @Nullable String destroyMethod) + throws RuntimeCamelException { if (bean != null) { bind(id, bean.getClass(), bean, initMethod, destroyMethod); } @@ -86,7 +88,8 @@ default void bind(String id, Object bean, String initMethod, String destroyMetho * @param destroyMethod optional destroy method (invoked at unbind or stopping Camel) * @throws RuntimeCamelException is thrown if binding is not possible */ - void bind(String id, Class type, Object bean, String initMethod, String destroyMethod) throws RuntimeCamelException; + void bind(String id, Class type, Object bean, @Nullable String initMethod, @Nullable String destroyMethod) + throws RuntimeCamelException; /** * Binds the bean (via a supplier) to the repository (if possible). @@ -120,7 +123,9 @@ default void bind(String id, Object bean, String initMethod, String destroyMetho * @param destroyMethod optional destroy method (invoked at unbind or stopping Camel) * @throws RuntimeCamelException is thrown if binding is not possible */ - void bind(String id, Class type, Supplier bean, String initMethod, String destroyMethod) + void bind( + String id, Class type, Supplier bean, @Nullable String initMethod, + @Nullable String destroyMethod) throws RuntimeCamelException; /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ReloadStrategy.java b/core/camel-api/src/main/java/org/apache/camel/spi/ReloadStrategy.java index ca32988afb277..2891c74a18caa 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ReloadStrategy.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ReloadStrategy.java @@ -18,6 +18,7 @@ import org.apache.camel.CamelContextAware; import org.apache.camel.StaticService; +import org.jspecify.annotations.Nullable; /** * SPI strategy for reloading. @@ -52,5 +53,6 @@ public interface ReloadStrategy extends StaticService, CamelContextAware { /** * Gets the last error if reloading failed */ + @Nullable Exception getLastError(); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/Resource.java b/core/camel-api/src/main/java/org/apache/camel/spi/Resource.java index b5c04bbb06d0a..e4763d00a228a 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/Resource.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/Resource.java @@ -26,6 +26,8 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import org.jspecify.annotations.Nullable; + /** * Describe a resource, such as a file or class path resource. */ @@ -60,7 +62,7 @@ default URI getURI() { *

* The default implementation creates a {@code URI} object from resource location. */ - default URL getURL() throws MalformedURLException { + default @Nullable URL getURL() throws MalformedURLException { URI uri = getURI(); return uri != null ? uri.toURL() : null; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ResourceAware.java b/core/camel-api/src/main/java/org/apache/camel/spi/ResourceAware.java index 3469b4ef0003b..2c6c2d7814e4c 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ResourceAware.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ResourceAware.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * An interface to represent an object which wishes to be injected with the {@link Resource} */ @@ -35,6 +37,7 @@ static T trySetResource(T object, Resource resource) { /** * Gets the {@link Resource}. */ + @Nullable Resource getResource(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ResourceResolver.java b/core/camel-api/src/main/java/org/apache/camel/spi/ResourceResolver.java index ea15a3d01fbfc..aa06690e564fa 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ResourceResolver.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ResourceResolver.java @@ -18,6 +18,7 @@ import org.apache.camel.CamelContextAware; import org.apache.camel.StaticService; +import org.jspecify.annotations.Nullable; /** * SPI for loading resources. @@ -47,5 +48,6 @@ public interface ResourceResolver extends StaticService, CamelContextAware { * @param location the location of the resource to resolve. * @return an {@link Resource}, null if was not possible to resolve the resource. */ + @Nullable Resource resolve(String location); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/RestBindingJacksonXmlDataFormatFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/RestBindingJacksonXmlDataFormatFactory.java index ac032e1d41b70..eabaf4d3179ef 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/RestBindingJacksonXmlDataFormatFactory.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/RestBindingJacksonXmlDataFormatFactory.java @@ -17,6 +17,7 @@ package org.apache.camel.spi; import org.apache.camel.CamelContext; +import org.jspecify.annotations.Nullable; /** * SPI for setting up XML data format (jacksonXml) for rest-dsl. @@ -33,7 +34,8 @@ public interface RestBindingJacksonXmlDataFormatFactory { */ void setupJacksonXml( CamelContext camelContext, RestConfiguration config, - String type, Class typeClass, String outType, Class outTypeClass, + @Nullable String type, @Nullable Class typeClass, @Nullable String outType, + @Nullable Class outTypeClass, DataFormat jacksonXml, DataFormat outJacksonXml) throws Exception; diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/RestBindingJaxbDataFormatFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/RestBindingJaxbDataFormatFactory.java index 12cfce11903b1..d6a6c337a70ce 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/RestBindingJaxbDataFormatFactory.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/RestBindingJaxbDataFormatFactory.java @@ -17,6 +17,7 @@ package org.apache.camel.spi; import org.apache.camel.CamelContext; +import org.jspecify.annotations.Nullable; /** * SPI for setting up XML data format (JAXB) for rest-dsl. @@ -33,7 +34,8 @@ public interface RestBindingJaxbDataFormatFactory { */ void setupJaxb( CamelContext camelContext, RestConfiguration config, - String type, Class typeClass, String outType, Class outTypeClass, + @Nullable String type, @Nullable Class typeClass, @Nullable String outType, + @Nullable Class outTypeClass, DataFormat jaxb, DataFormat outJaxb) throws Exception; diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/RestClientRequestValidator.java b/core/camel-api/src/main/java/org/apache/camel/spi/RestClientRequestValidator.java index 15479e86a9d8a..cf31e203f4cff 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/RestClientRequestValidator.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/RestClientRequestValidator.java @@ -20,6 +20,7 @@ import java.util.Set; import org.apache.camel.Exchange; +import org.jspecify.annotations.Nullable; /** * Used for validating incoming client requests with Camel Rest DSL. @@ -65,6 +66,7 @@ record ValidationContext(String consumes, String produces, * @param validationContent validation context * @return the validation error, or null if success */ + @Nullable ValidationError validate(Exchange exchange, ValidationContext validationContent); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/RestClientResponseValidator.java b/core/camel-api/src/main/java/org/apache/camel/spi/RestClientResponseValidator.java index b01d1dbc7d957..4168a89cc03c9 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/RestClientResponseValidator.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/RestClientResponseValidator.java @@ -20,6 +20,7 @@ import java.util.Set; import org.apache.camel.Exchange; +import org.jspecify.annotations.Nullable; /** * Used for validating incoming client responses with Camel Rest DSL. @@ -58,6 +59,7 @@ record ValidationContext(String consumes, String produces, * @param validationContent validation context * @return the validation error, or null if success */ + @Nullable ValidationError validate(Exchange exchange, ValidationContext validationContent); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/RestConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/spi/RestConfiguration.java index 413e9538f3466..66dbd4aa0b4f1 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/RestConfiguration.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/RestConfiguration.java @@ -18,6 +18,8 @@ import java.util.Map; +import org.jspecify.annotations.Nullable; + /** * Configuration use by {@link org.apache.camel.spi.RestConsumerFactory} and * {@link org.apache.camel.spi.RestApiConsumerFactory} for Camel components to support the Camel @@ -49,37 +51,37 @@ public enum RestHostNameResolver { none; } - private String component; - private String apiComponent; - private String producerComponent; - private String producerApiDoc; - private String scheme; - private String host; + private @Nullable String component; + private @Nullable String apiComponent; + private @Nullable String producerComponent; + private @Nullable String producerApiDoc; + private @Nullable String scheme; + private @Nullable String host; private boolean useXForwardHeaders; - private String apiHost; + private @Nullable String apiHost; private int port; - private String contextPath; - private String apiContextPath; - private String apiContextRouteId; + private @Nullable String contextPath; + private @Nullable String apiContextPath; + private @Nullable String apiContextRouteId; private boolean apiVendorExtension; private RestHostNameResolver hostNameResolver = RestHostNameResolver.allLocalIp; private RestBindingMode bindingMode = RestBindingMode.off; - private String bindingPackageScan; + private @Nullable String bindingPackageScan; private boolean skipBindingOnErrorCode = true; private boolean clientRequestValidation; private boolean clientResponseValidation; private boolean inlineRoutes = true; private boolean enableCORS; private boolean enableNoContentResponse; - private String jsonDataFormat; - private String xmlDataFormat; - private Map componentProperties; - private Map endpointProperties; - private Map consumerProperties; - private Map dataFormatProperties; - private Map apiProperties; - private Map corsHeaders; - private Map validationLevels; + private @Nullable String jsonDataFormat; + private @Nullable String xmlDataFormat; + private @Nullable Map componentProperties; + private @Nullable Map endpointProperties; + private @Nullable Map consumerProperties; + private @Nullable Map dataFormatProperties; + private @Nullable Map apiProperties; + private @Nullable Map corsHeaders; + private @Nullable Map validationLevels; /** * Gets the name of the Camel component to use as the REST consumer @@ -87,7 +89,7 @@ public enum RestHostNameResolver { * @return the component name, or null to let Camel search the {@link Registry} to find suitable * implementation */ - public String getComponent() { + public @Nullable String getComponent() { return component; } @@ -105,7 +107,7 @@ public void setComponent(String componentName) { * * @return the component name */ - public String getApiComponent() { + public @Nullable String getApiComponent() { return apiComponent; } @@ -124,7 +126,7 @@ public void setApiComponent(String apiComponent) { * @return the component name, or null to let Camel search the {@link Registry} to find suitable * implementation */ - public String getProducerComponent() { + public @Nullable String getProducerComponent() { return producerComponent; } @@ -141,7 +143,7 @@ public void setProducerComponent(String componentName) { * Gets the location of the api document (swagger api) the REST producer will use to validate the REST uri and query * parameters are valid accordingly to the api document. */ - public String getProducerApiDoc() { + public @Nullable String getProducerApiDoc() { return producerApiDoc; } @@ -162,7 +164,7 @@ public void setProducerApiDoc(String producerApiDoc) { * * @return the hostname, or null to use default hostname */ - public String getHost() { + public @Nullable String getHost() { return host; } @@ -197,7 +199,7 @@ public void setUseXForwardHeaders(boolean useXForwardHeaders) { this.useXForwardHeaders = useXForwardHeaders; } - public String getApiHost() { + public @Nullable String getApiHost() { return apiHost; } @@ -215,7 +217,7 @@ public void setApiHost(String apiHost) { * * @return the scheme, or null to use default scheme */ - public String getScheme() { + public @Nullable String getScheme() { return scheme; } @@ -251,7 +253,7 @@ public void setPort(int port) { * * @return the context path, or null if none configured. */ - public String getContextPath() { + public @Nullable String getContextPath() { return contextPath; } @@ -268,7 +270,7 @@ public void setContextPath(String contextPath) { this.contextPath = contextPath; } - public String getApiContextPath() { + public @Nullable String getApiContextPath() { return apiContextPath; } @@ -284,7 +286,7 @@ public void setApiContextPath(String contextPath) { this.apiContextPath = contextPath; } - public String getApiContextRouteId() { + public @Nullable String getApiContextRouteId() { return apiContextRouteId; } @@ -366,7 +368,7 @@ public void setBindingMode(String bindingMode) { this.bindingMode = RestBindingMode.valueOf(bindingMode); } - public String getBindingPackageScan() { + public @Nullable String getBindingPackageScan() { return bindingPackageScan; } @@ -496,7 +498,7 @@ public void setInlineRoutes(boolean inlineRoutes) { * * @return the name, or null to use default */ - public String getJsonDataFormat() { + public @Nullable String getJsonDataFormat() { return jsonDataFormat; } @@ -520,7 +522,7 @@ public void setJsonDataFormat(String name) { * * @return the name, or null to use default */ - public String getXmlDataFormat() { + public @Nullable String getXmlDataFormat() { return xmlDataFormat; } @@ -541,7 +543,7 @@ public void setXmlDataFormat(String name) { * * @return additional options */ - public Map getComponentProperties() { + public @Nullable Map getComponentProperties() { return componentProperties; } @@ -559,7 +561,7 @@ public void setComponentProperties(Map componentProperties) { * * @return additional options */ - public Map getEndpointProperties() { + public @Nullable Map getEndpointProperties() { return endpointProperties; } @@ -577,7 +579,7 @@ public void setEndpointProperties(Map endpointProperties) { * * @return additional options */ - public Map getConsumerProperties() { + public @Nullable Map getConsumerProperties() { return consumerProperties; } @@ -595,7 +597,7 @@ public void setConsumerProperties(Map consumerProperties) { * * @return additional options */ - public Map getDataFormatProperties() { + public @Nullable Map getDataFormatProperties() { return dataFormatProperties; } @@ -608,7 +610,7 @@ public void setDataFormatProperties(Map dataFormatProperties) { this.dataFormatProperties = dataFormatProperties; } - public Map getApiProperties() { + public @Nullable Map getApiProperties() { return apiProperties; } @@ -626,7 +628,7 @@ public void setApiProperties(Map apiProperties) { * * @return the CORS headers */ - public Map getCorsHeaders() { + public @Nullable Map getCorsHeaders() { return corsHeaders; } @@ -644,7 +646,7 @@ public void setCorsHeaders(Map corsHeaders) { * * @return the validation levels */ - public Map getValidationLevels() { + public @Nullable Map getValidationLevels() { return validationLevels; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/RestConsumerFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/RestConsumerFactory.java index 06ccdb8f94aeb..8b4ca6deb2a47 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/RestConsumerFactory.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/RestConsumerFactory.java @@ -21,6 +21,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.Consumer; import org.apache.camel.Processor; +import org.jspecify.annotations.Nullable; /** * Allows SPI to plugin a {@link RestConsumerFactory} that creates the Camel {@link Consumer} responsible for handling @@ -51,7 +52,9 @@ public interface RestConsumerFactory { * @throws Exception can be thrown */ Consumer createConsumer( - CamelContext camelContext, Processor processor, String verb, String basePath, String uriTemplate, - String consumes, String produces, RestConfiguration configuration, Map parameters) + CamelContext camelContext, Processor processor, String verb, String basePath, + @Nullable String uriTemplate, + @Nullable String consumes, @Nullable String produces, RestConfiguration configuration, + Map parameters) throws Exception; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/RestProducerFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/RestProducerFactory.java index 0f28fda5b5139..2430217633cba 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/RestProducerFactory.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/RestProducerFactory.java @@ -20,6 +20,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.Producer; +import org.jspecify.annotations.Nullable; /** * Allows SPI to plugin a {@link RestProducerFactory} that creates the Camel {@link Producer} responsible for performing @@ -46,7 +47,8 @@ public interface RestProducerFactory { */ Producer createProducer( CamelContext camelContext, String host, - String verb, String basePath, String uriTemplate, String queryParameters, - String consumes, String produces, RestConfiguration configuration, Map parameters) + String verb, String basePath, @Nullable String uriTemplate, @Nullable String queryParameters, + @Nullable String consumes, @Nullable String produces, RestConfiguration configuration, + Map parameters) throws Exception; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/RestRegistry.java b/core/camel-api/src/main/java/org/apache/camel/spi/RestRegistry.java index 483a2583946ee..401c9a257c681 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/RestRegistry.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/RestRegistry.java @@ -20,6 +20,7 @@ import org.apache.camel.Consumer; import org.apache.camel.StaticService; +import org.jspecify.annotations.Nullable; /** * A registry of all REST services running within the {@link org.apache.camel.CamelContext} which have been defined and @@ -70,6 +71,7 @@ interface RestService { /** * Gets the uri template */ + @Nullable String getUriTemplate(); /** @@ -80,11 +82,13 @@ interface RestService { /** * Optional details about what media-types the REST service accepts */ + @Nullable String getConsumes(); /** * Optional details about what media-types the REST service returns */ + @Nullable String getProduces(); /** @@ -92,6 +96,7 @@ interface RestService { *

* If the input accepts a list, then List<class name> is enclosed the name. */ + @Nullable String getInType(); /** @@ -99,11 +104,13 @@ interface RestService { *

* If the output accepts a list, then List<class name> is enclosed the name. */ + @Nullable String getOutType(); /** * Optional description about this rest service. */ + @Nullable String getDescription(); } @@ -126,9 +133,10 @@ interface RestService { * @param description optional description about the service */ void addRestService( - Consumer consumer, boolean contractFirst, String url, String baseUrl, String basePath, String uriTemplate, - String method, - String consumes, String produces, String inType, String outType, String routeId, String description); + Consumer consumer, boolean contractFirst, String url, String baseUrl, String basePath, + @Nullable String uriTemplate, String method, + @Nullable String consumes, @Nullable String produces, @Nullable String inType, @Nullable String outType, + String routeId, @Nullable String description); /** * Removes the REST service from the registry @@ -158,7 +166,7 @@ void addRestService( */ void addRestSpecification( Consumer consumer, boolean contractFirst, String url, String baseUrl, String basePath, String method, - String produces, String description); + @Nullable String produces, @Nullable String description); /** * List all REST API specification (ie api-doc) @@ -179,6 +187,7 @@ void addRestSpecification( * * @return the API docs in JSon, or null if camel-openapi-java is not on classpath */ + @Nullable String apiDocAsJson(); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/RouteFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/RouteFactory.java index 36363fa4bd641..fbf4f602eae2c 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/RouteFactory.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/RouteFactory.java @@ -20,6 +20,7 @@ import org.apache.camel.Endpoint; import org.apache.camel.NamedNode; import org.apache.camel.Route; +import org.jspecify.annotations.Nullable; /** * A factory to create {@link Route} @@ -40,7 +41,7 @@ public interface RouteFactory { */ Route createRoute( CamelContext camelContext, NamedNode routeDefinition, - String routeId, String routeDescription, String routeNote, - Endpoint endpoint, Resource resource); + String routeId, @Nullable String routeDescription, @Nullable String routeNote, + Endpoint endpoint, @Nullable Resource resource); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/RouteIdAware.java b/core/camel-api/src/main/java/org/apache/camel/spi/RouteIdAware.java index 6d8ce7c2cee85..dabd0779beb69 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/RouteIdAware.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/RouteIdAware.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * To allow objects to be injected with the route id *

@@ -26,6 +28,7 @@ public interface RouteIdAware { /** * Gets the route id */ + @Nullable String getRouteId(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/RoutePolicyFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/RoutePolicyFactory.java index a85a5e1600f89..f4918f861f6b9 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/RoutePolicyFactory.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/RoutePolicyFactory.java @@ -18,6 +18,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.NamedNode; +import org.jspecify.annotations.Nullable; /** * A factory to create {@link org.apache.camel.spi.RoutePolicy} and assign to routes automatic. @@ -33,5 +34,6 @@ public interface RoutePolicyFactory { * @return the created {@link org.apache.camel.spi.RoutePolicy}, or null to not use a policy * for this route */ + @Nullable RoutePolicy createRoutePolicy(CamelContext camelContext, String routeId, NamedNode route); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ScriptingLanguage.java b/core/camel-api/src/main/java/org/apache/camel/spi/ScriptingLanguage.java index c5306565c97db..a645dee91c2e2 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ScriptingLanguage.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ScriptingLanguage.java @@ -18,6 +18,8 @@ import java.util.Map; +import org.jspecify.annotations.Nullable; + /** * Represents a {@link Language} which is a general purpose scripting languages such as groovy, joor and others. */ @@ -32,5 +34,5 @@ public interface ScriptingLanguage { * @param resultType the expected result type * @return the result of the evaluation */ - T evaluate(String script, Map bindings, Class resultType); + T evaluate(String script, @Nullable Map bindings, Class resultType); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/SendDynamicAware.java b/core/camel-api/src/main/java/org/apache/camel/spi/SendDynamicAware.java index 5c48df877abca..f3bf12997c47d 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/SendDynamicAware.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/SendDynamicAware.java @@ -24,6 +24,7 @@ import org.apache.camel.Processor; import org.apache.camel.Producer; import org.apache.camel.Service; +import org.jspecify.annotations.Nullable; /** * Used for components that can optimise the usage of {@link org.apache.camel.processor.SendDynamicProcessor} (toD) to @@ -117,6 +118,7 @@ public Map getLenientProperties() { * @return the static uri, or null to not let toD use this optimisation. * @throws Exception is thrown if error resolving the static uri. */ + @Nullable String resolveStaticUri(Exchange exchange, DynamicAwareEntry entry) throws Exception; /** @@ -128,6 +130,7 @@ public Map getLenientProperties() { * @return the processor, or null to not let toD use this optimisation. * @throws Exception is thrown if error creating the pre processor. */ + @Nullable Processor createPreProcessor(Exchange exchange, DynamicAwareEntry entry) throws Exception; /** @@ -139,6 +142,7 @@ public Map getLenientProperties() { * @return the post processor, or null if no post processor is needed. * @throws Exception is thrown if error creating the post processor. */ + @Nullable Processor createPostProcessor(Exchange exchange, DynamicAwareEntry entry) throws Exception; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/SimpleFunction.java b/core/camel-api/src/main/java/org/apache/camel/spi/SimpleFunction.java index fc7ef152ac214..13d71d62e19cc 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/SimpleFunction.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/SimpleFunction.java @@ -17,6 +17,7 @@ package org.apache.camel.spi; import org.apache.camel.Exchange; +import org.jspecify.annotations.Nullable; /** * A custom simple language function @@ -40,7 +41,8 @@ public interface SimpleFunction { * @return the response * @throws Exception can be thrown if there was an error */ - Object apply(Exchange exchange, Object input) throws Exception; + @Nullable + Object apply(Exchange exchange, @Nullable Object input) throws Exception; /** * Whether this custom function allows null as input value. diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/SimpleFunctionRegistry.java b/core/camel-api/src/main/java/org/apache/camel/spi/SimpleFunctionRegistry.java index 0abf69d2cee44..b0535a430f8ea 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/SimpleFunctionRegistry.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/SimpleFunctionRegistry.java @@ -20,6 +20,7 @@ import org.apache.camel.Expression; import org.apache.camel.StaticService; +import org.jspecify.annotations.Nullable; /** * Registry for custom simple functions. @@ -54,6 +55,7 @@ public interface SimpleFunctionRegistry extends StaticService { * @param name name of function * @return the function, or null if no function exists */ + @Nullable Expression getFunction(String name); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/SimpleLanguageFunctionFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/SimpleLanguageFunctionFactory.java index 3eb0b27c9ce8c..f76341d84328e 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/SimpleLanguageFunctionFactory.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/SimpleLanguageFunctionFactory.java @@ -18,6 +18,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.Expression; +import org.jspecify.annotations.Nullable; /** * A factory for extending the simple language with functions from external components. @@ -40,6 +41,7 @@ public interface SimpleLanguageFunctionFactory { * * @return the created function as an expression, or null if not supported by this factory. */ + @Nullable Expression createFunction(CamelContext camelContext, String function, int index); /** @@ -50,6 +52,7 @@ public interface SimpleLanguageFunctionFactory { * @param index index of the function in the literal input * @return the source code or null if not supported by this factory. */ + @Nullable String createCode(CamelContext camelContext, String function, int index); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/StartupCondition.java b/core/camel-api/src/main/java/org/apache/camel/spi/StartupCondition.java index e0e1892896915..b94ff9341e989 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/StartupCondition.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/StartupCondition.java @@ -17,6 +17,7 @@ package org.apache.camel.spi; import org.apache.camel.CamelContext; +import org.jspecify.annotations.Nullable; /** * Pluggable condition that must be accepted before Camel can continue starting up. @@ -36,14 +37,14 @@ default String getName() { /** * Optional logging message to log before waiting for the condition */ - default String getWaitMessage() { + default @Nullable String getWaitMessage() { return null; } /** * Optional logging message to log if condition was not meet. */ - default String getFailureMessage() { + default @Nullable String getFailureMessage() { return null; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/StartupStepRecorder.java b/core/camel-api/src/main/java/org/apache/camel/spi/StartupStepRecorder.java index 0600f494c094c..a060b42f770f4 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/StartupStepRecorder.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/StartupStepRecorder.java @@ -20,6 +20,7 @@ import org.apache.camel.StartupStep; import org.apache.camel.StaticService; +import org.jspecify.annotations.Nullable; /** * To record {@link StartupStep} during startup to allow to capture diagnostic information to help troubleshoot Camel @@ -58,6 +59,7 @@ public interface StartupStepRecorder extends StaticService { */ void setStartupRecorderDuration(long startupRecorderDuration); + @Nullable String getRecordingDir(); /** @@ -65,6 +67,7 @@ public interface StartupStepRecorder extends StaticService { */ void setRecordingDir(String recordingDir); + @Nullable String getRecordingProfile(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/StateRepository.java b/core/camel-api/src/main/java/org/apache/camel/spi/StateRepository.java index 31f4cf66df9cf..8f92aba2a26dc 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/StateRepository.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/StateRepository.java @@ -17,6 +17,7 @@ package org.apache.camel.spi; import org.apache.camel.Service; +import org.jspecify.annotations.Nullable; /** * This {@link StateRepository} holds a set of key/value pairs for defining a particular state of a component. @@ -44,5 +45,6 @@ public interface StateRepository extends Service { * @param key State key * @return State value or null the key is unknown */ + @Nullable V getState(K key); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/StreamCachingStrategy.java b/core/camel-api/src/main/java/org/apache/camel/spi/StreamCachingStrategy.java index 267949c9ba6e6..85f13ac89baf1 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/StreamCachingStrategy.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/StreamCachingStrategy.java @@ -23,6 +23,7 @@ import org.apache.camel.Message; import org.apache.camel.StaticService; import org.apache.camel.StreamCache; +import org.jspecify.annotations.Nullable; /** * Strategy for using stream caching. @@ -222,6 +223,7 @@ interface SpoolRule { */ void setSpoolCipher(String cipher); + @Nullable String getSpoolCipher(); /** @@ -271,6 +273,7 @@ interface SpoolRule { * @return the body cached as a {@link StreamCache}, or null if not possible or no need to cache * the body */ + @Nullable StreamCache cache(Exchange exchange); /** @@ -280,6 +283,7 @@ interface SpoolRule { * @return the body cached as a {@link StreamCache}, or null if not possible or no need to cache * the body */ + @Nullable StreamCache cache(Message message); /** @@ -288,6 +292,7 @@ interface SpoolRule { * @param value the value * @return the value cached as a {@link StreamCache}, or null if not possible or no need to cache */ + @Nullable StreamCache cache(Object value); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/SupervisingRouteController.java b/core/camel-api/src/main/java/org/apache/camel/spi/SupervisingRouteController.java index 09c8661df793f..fddeddb80d7a1 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/SupervisingRouteController.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/SupervisingRouteController.java @@ -21,6 +21,7 @@ import org.apache.camel.Route; import org.apache.camel.util.backoff.BackOffTimer; +import org.jspecify.annotations.Nullable; /** * A supervising capable {@link RouteController} that delays the startup of the routes after the camel context startup @@ -29,6 +30,7 @@ */ public interface SupervisingRouteController extends RouteController { + @Nullable String getIncludeRoutes(); /** @@ -40,8 +42,9 @@ public interface SupervisingRouteController extends RouteController { * ids myRoute,myOtherRoute. The pattern supports wildcards and uses the matcher from * org.apache.camel.support.PatternHelper#matchPattern. */ - void setIncludeRoutes(String includeRoutes); + void setIncludeRoutes(@Nullable String includeRoutes); + @Nullable String getExcludeRoutes(); /** @@ -53,7 +56,7 @@ public interface SupervisingRouteController extends RouteController { * mySpecialRoute,myOtherSpecialRoute. The pattern supports wildcards and uses the matcher from * org.apache.camel.support.PatternHelper#matchPattern. */ - void setExcludeRoutes(String excludeRoutes); + void setExcludeRoutes(@Nullable String excludeRoutes); int getThreadPoolSize(); @@ -153,7 +156,7 @@ public interface SupervisingRouteController extends RouteController { * @param routeId the route id * @return the state, or null if the route is not under restarting */ - BackOffTimer.Task getRestartingRouteState(String routeId); + BackOffTimer.@Nullable Task getRestartingRouteState(String routeId); /** * Gets the last exception that caused the route to not startup for the given route @@ -161,6 +164,7 @@ public interface SupervisingRouteController extends RouteController { * @param routeId the route id * @return the caused exception */ + @Nullable Throwable getRestartException(String routeId); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/Synchronization.java b/core/camel-api/src/main/java/org/apache/camel/spi/Synchronization.java index ced9c7232a046..96fef9945ae7a 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/Synchronization.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/Synchronization.java @@ -17,6 +17,7 @@ package org.apache.camel.spi; import org.apache.camel.Exchange; +import org.jspecify.annotations.Nullable; /** * Provides a hook for custom {@link org.apache.camel.Processor} or {@link org.apache.camel.Component} instances to @@ -46,7 +47,7 @@ public interface Synchronization { * * @return An instance of {@link SynchronizationRouteAware} or null if unset for this synchronization */ - default SynchronizationRouteAware getRouteSynchronization() { + default @Nullable SynchronizationRouteAware getRouteSynchronization() { return null; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ThreadPoolProfile.java b/core/camel-api/src/main/java/org/apache/camel/spi/ThreadPoolProfile.java index 0f50a82135913..25474cfe1e59c 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ThreadPoolProfile.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ThreadPoolProfile.java @@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit; import org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy; +import org.jspecify.annotations.Nullable; /** * A profile which defines thread pool settings. @@ -32,15 +33,15 @@ public class ThreadPoolProfile implements Serializable, Cloneable { private static final @Serial long serialVersionUID = 1L; - private String id; - private Boolean defaultProfile; - private Integer poolSize; - private Integer maxPoolSize; - private Long keepAliveTime; - private TimeUnit timeUnit; - private Integer maxQueueSize; - private Boolean allowCoreThreadTimeOut; - private ThreadPoolRejectedPolicy rejectedPolicy; + private @Nullable String id; + private @Nullable Boolean defaultProfile; + private @Nullable Integer poolSize; + private @Nullable Integer maxPoolSize; + private @Nullable Long keepAliveTime; + private @Nullable TimeUnit timeUnit; + private @Nullable Integer maxQueueSize; + private @Nullable Boolean allowCoreThreadTimeOut; + private @Nullable ThreadPoolRejectedPolicy rejectedPolicy; /** * Creates a new thread pool profile, with no id set. @@ -62,7 +63,7 @@ public ThreadPoolProfile(String id) { * * @return the id of this profile */ - public String getId() { + public @Nullable String getId() { return id; } @@ -71,7 +72,7 @@ public String getId() { * * @param id profile id */ - public void setId(String id) { + public void setId(@Nullable String id) { this.id = id; } @@ -89,7 +90,7 @@ public Boolean isDefaultProfile() { * * @param defaultProfile the option */ - public void setDefaultProfile(Boolean defaultProfile) { + public void setDefaultProfile(@Nullable Boolean defaultProfile) { this.defaultProfile = defaultProfile; } @@ -98,7 +99,7 @@ public void setDefaultProfile(Boolean defaultProfile) { * * @return the pool size */ - public Integer getPoolSize() { + public @Nullable Integer getPoolSize() { return poolSize; } @@ -107,7 +108,7 @@ public Integer getPoolSize() { * * @param poolSize the pool size */ - public void setPoolSize(Integer poolSize) { + public void setPoolSize(@Nullable Integer poolSize) { this.poolSize = poolSize; } @@ -116,7 +117,7 @@ public void setPoolSize(Integer poolSize) { * * @return the maximum pool size */ - public Integer getMaxPoolSize() { + public @Nullable Integer getMaxPoolSize() { return maxPoolSize; } @@ -125,7 +126,7 @@ public Integer getMaxPoolSize() { * * @param maxPoolSize the max pool size */ - public void setMaxPoolSize(Integer maxPoolSize) { + public void setMaxPoolSize(@Nullable Integer maxPoolSize) { this.maxPoolSize = maxPoolSize; } @@ -134,7 +135,7 @@ public void setMaxPoolSize(Integer maxPoolSize) { * * @return the keep alive time */ - public Long getKeepAliveTime() { + public @Nullable Long getKeepAliveTime() { return keepAliveTime; } @@ -143,7 +144,7 @@ public Long getKeepAliveTime() { * * @param keepAliveTime the keep alive time */ - public void setKeepAliveTime(Long keepAliveTime) { + public void setKeepAliveTime(@Nullable Long keepAliveTime) { this.keepAliveTime = keepAliveTime; } @@ -152,7 +153,7 @@ public void setKeepAliveTime(Long keepAliveTime) { * * @return the time unit */ - public TimeUnit getTimeUnit() { + public @Nullable TimeUnit getTimeUnit() { return timeUnit; } @@ -161,7 +162,7 @@ public TimeUnit getTimeUnit() { * * @param timeUnit the time unit */ - public void setTimeUnit(TimeUnit timeUnit) { + public void setTimeUnit(@Nullable TimeUnit timeUnit) { this.timeUnit = timeUnit; } @@ -172,7 +173,7 @@ public void setTimeUnit(TimeUnit timeUnit) { * * @return the max queue size */ - public Integer getMaxQueueSize() { + public @Nullable Integer getMaxQueueSize() { return maxQueueSize; } @@ -183,7 +184,7 @@ public Integer getMaxQueueSize() { * * @param maxQueueSize the max queue size */ - public void setMaxQueueSize(Integer maxQueueSize) { + public void setMaxQueueSize(@Nullable Integer maxQueueSize) { this.maxQueueSize = maxQueueSize; } @@ -192,7 +193,7 @@ public void setMaxQueueSize(Integer maxQueueSize) { * * @return the allow core threads to timeout */ - public Boolean getAllowCoreThreadTimeOut() { + public @Nullable Boolean getAllowCoreThreadTimeOut() { return allowCoreThreadTimeOut; } @@ -201,7 +202,7 @@ public Boolean getAllowCoreThreadTimeOut() { * * @param allowCoreThreadTimeOut true to allow timeout */ - public void setAllowCoreThreadTimeOut(Boolean allowCoreThreadTimeOut) { + public void setAllowCoreThreadTimeOut(@Nullable Boolean allowCoreThreadTimeOut) { this.allowCoreThreadTimeOut = allowCoreThreadTimeOut; } @@ -210,7 +211,7 @@ public void setAllowCoreThreadTimeOut(Boolean allowCoreThreadTimeOut) { * * @return the policy for the handler */ - public ThreadPoolRejectedPolicy getRejectedPolicy() { + public @Nullable ThreadPoolRejectedPolicy getRejectedPolicy() { return rejectedPolicy; } @@ -219,7 +220,7 @@ public ThreadPoolRejectedPolicy getRejectedPolicy() { * * @return the handler, or null if none defined */ - public RejectedExecutionHandler getRejectedExecutionHandler() { + public @Nullable RejectedExecutionHandler getRejectedExecutionHandler() { if (rejectedPolicy != null) { return rejectedPolicy.asRejectedExecutionHandler(); } @@ -231,7 +232,7 @@ public RejectedExecutionHandler getRejectedExecutionHandler() { * * @param rejectedPolicy the policy for the handler */ - public void setRejectedPolicy(ThreadPoolRejectedPolicy rejectedPolicy) { + public void setRejectedPolicy(@Nullable ThreadPoolRejectedPolicy rejectedPolicy) { this.rejectedPolicy = rejectedPolicy; } @@ -240,7 +241,7 @@ public void setRejectedPolicy(ThreadPoolRejectedPolicy rejectedPolicy) { * * @param defaultProfile profile with default values */ - public void addDefaults(ThreadPoolProfile defaultProfile) { + public void addDefaults(@Nullable ThreadPoolProfile defaultProfile) { if (defaultProfile == null) { return; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/Tracer.java b/core/camel-api/src/main/java/org/apache/camel/spi/Tracer.java index b96558832aeb3..817c2a1271d5b 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/Tracer.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/Tracer.java @@ -21,6 +21,7 @@ import org.apache.camel.NamedNode; import org.apache.camel.NamedRoute; import org.apache.camel.StaticService; +import org.jspecify.annotations.Nullable; /** * SPI for tracing messages. @@ -139,13 +140,14 @@ public interface Tracer extends StaticService { * Tracing pattern to match which node EIPs to trace. For example to match all To EIP nodes, use to*. The pattern * matches by node and route id's Multiple patterns can be separated by comma. */ + @Nullable String getTracePattern(); /** * Tracing pattern to match which node EIPs to trace. For example to match all To EIP nodes, use to*. The pattern * matches by node and route id's Multiple patterns can be separated by comma. */ - void setTracePattern(String tracePattern); + void setTracePattern(@Nullable String tracePattern); /** * Whether to include tracing of before/after routes to trace the input and responses of routes. diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/Transformer.java b/core/camel-api/src/main/java/org/apache/camel/spi/Transformer.java index 09e48fd359b58..718cce4757a6d 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/Transformer.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/Transformer.java @@ -21,6 +21,7 @@ import org.apache.camel.Message; import org.apache.camel.support.service.ServiceSupport; import org.apache.camel.util.ObjectHelper; +import org.jspecify.annotations.Nullable; /** * Transformer performs message transformation according to the @@ -32,10 +33,10 @@ */ public abstract class Transformer extends ServiceSupport implements CamelContextAware { - private CamelContext camelContext; - private String name; - private DataType from; - private DataType to; + private @Nullable CamelContext camelContext; + private @Nullable String name; + private @Nullable DataType from; + private @Nullable DataType to; public Transformer() { if (this.getClass().isAnnotationPresent(DataTypeTransformer.class)) { @@ -70,21 +71,21 @@ public Transformer(String name) { /** * Get the transformer name that represents the supported data type model. */ - public String getName() { + public @Nullable String getName() { return name; } /** * Get 'from' data type. */ - public DataType getFrom() { + public @Nullable DataType getFrom() { return from; } /** * Get 'to' data type. */ - public DataType getTo() { + public @Nullable DataType getTo() { return to; } @@ -133,7 +134,7 @@ public Transformer setTo(String to) { } @Override - public CamelContext getCamelContext() { + public @Nullable CamelContext getCamelContext() { return this.camelContext; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/TransformerRegistry.java b/core/camel-api/src/main/java/org/apache/camel/spi/TransformerRegistry.java index 05cb8185d47fa..2821d5b59c54e 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/TransformerRegistry.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/TransformerRegistry.java @@ -19,6 +19,7 @@ import java.util.Map; import org.apache.camel.StaticService; +import org.jspecify.annotations.Nullable; /** * Registry to cache transformers in memory. @@ -44,6 +45,7 @@ public interface TransformerRegistry extends Map, S * @param key a key represents the from/to data types to transform * @return {@link Transformer} if matched, otherwise null */ + @Nullable Transformer resolveTransformer(TransformerKey key); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/TransformerResolver.java b/core/camel-api/src/main/java/org/apache/camel/spi/TransformerResolver.java index 23817d1affb68..61cbc5037bec5 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/TransformerResolver.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/TransformerResolver.java @@ -21,6 +21,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.util.StringHelper; +import org.jspecify.annotations.Nullable; /** * Resolves data type transformers from given transformer key. This represents the opportunity to lazy load transformers @@ -39,6 +40,7 @@ public interface TransformerResolver { * @param camelContext the current Camel context. * @return data type transformer resolved via URI factory finder or null if not found. */ + @Nullable Transformer resolve(K key, CamelContext camelContext); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/TypeConverterRegistry.java b/core/camel-api/src/main/java/org/apache/camel/spi/TypeConverterRegistry.java index 58667314a9a90..fa5f80c94cdd1 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/TypeConverterRegistry.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/TypeConverterRegistry.java @@ -25,6 +25,7 @@ import org.apache.camel.StaticService; import org.apache.camel.TypeConverter; import org.apache.camel.TypeConverterExists; +import org.jspecify.annotations.Nullable; /** * Registry for type converters. @@ -124,6 +125,7 @@ default void computeIfEnabled(LongSupplier supplier, LongConsumer consumer) { * @param fromType the type to convert from * @return the type converter or null if not found. */ + @Nullable TypeConverter lookup(Class toType, Class fromType); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/UnitOfWork.java b/core/camel-api/src/main/java/org/apache/camel/spi/UnitOfWork.java index d0c45e97fbd24..a72898dc14ab4 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/UnitOfWork.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/UnitOfWork.java @@ -23,6 +23,7 @@ import org.apache.camel.Message; import org.apache.camel.Processor; import org.apache.camel.Route; +import org.jspecify.annotations.Nullable; /** * An object representing the unit of work processing an {@link Exchange} which allows the use of @@ -104,7 +105,7 @@ public interface UnitOfWork { * @param target the target exchange * @param filter optional filter to only handover if filter returns true */ - void handoverSynchronization(Exchange target, Predicate filter); + void handoverSynchronization(Exchange target, @Nullable Predicate filter); /** * Invoked when this unit of work has been completed, whether it has failed or completed @@ -179,6 +180,7 @@ public interface UnitOfWork { * * @return the route, maybe be null if not routed through a route currently. */ + @Nullable Route getRoute(); /** @@ -196,6 +198,7 @@ public interface UnitOfWork { * * @return the route or null if none existed */ + @Nullable Route popRoute(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/UriFactoryResolver.java b/core/camel-api/src/main/java/org/apache/camel/spi/UriFactoryResolver.java index 602279d5a7a05..209cf70298a90 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/UriFactoryResolver.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/UriFactoryResolver.java @@ -17,6 +17,7 @@ package org.apache.camel.spi; import org.apache.camel.CamelContext; +import org.jspecify.annotations.Nullable; /** * A pluggable strategy for resolving different URI factories in a loosely coupled manner. @@ -30,5 +31,6 @@ public interface UriFactoryResolver { * @param context the camel context * @return the resolved factory, or null if no factory could be found */ + @Nullable EndpointUriFactory resolveFactory(String name, CamelContext context); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/Validator.java b/core/camel-api/src/main/java/org/apache/camel/spi/Validator.java index a39b6b6f37672..6fceb09ad10cb 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/Validator.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/Validator.java @@ -21,6 +21,7 @@ import org.apache.camel.Message; import org.apache.camel.ValidationException; import org.apache.camel.support.service.ServiceSupport; +import org.jspecify.annotations.Nullable; /** * Validator performs message content validation according to the @@ -32,8 +33,8 @@ */ public abstract class Validator extends ServiceSupport implements CamelContextAware { - private CamelContext camelContext; - private DataType type; + private @Nullable CamelContext camelContext; + private @Nullable DataType type; /** * Perform data validation with specified type. @@ -47,7 +48,7 @@ public abstract class Validator extends ServiceSupport implements CamelContextAw /** * Get 'from' data type. */ - public DataType getType() { + public @Nullable DataType getType() { return type; } @@ -62,7 +63,7 @@ public Validator setType(String type) { } @Override - public CamelContext getCamelContext() { + public @Nullable CamelContext getCamelContext() { return this.camelContext; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ValidatorRegistry.java b/core/camel-api/src/main/java/org/apache/camel/spi/ValidatorRegistry.java index da2f390e45aea..73cecf377ac32 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ValidatorRegistry.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ValidatorRegistry.java @@ -19,6 +19,7 @@ import java.util.Map; import org.apache.camel.StaticService; +import org.jspecify.annotations.Nullable; /** * Registry to cache validators in memory. @@ -44,6 +45,7 @@ public interface ValidatorRegistry extends Map, StaticS * @param key a key represents the data type * @return {@link Validator} if matched, otherwise null */ + @Nullable Validator resolveValidator(ValidatorKey key); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/VariableRepository.java b/core/camel-api/src/main/java/org/apache/camel/spi/VariableRepository.java index c186e66e1e648..8ba16d85079ae 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/VariableRepository.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/VariableRepository.java @@ -18,6 +18,7 @@ import org.apache.camel.StaticService; import org.apache.camel.VariableAware; +import org.jspecify.annotations.Nullable; /** * Repository for storing and accessing variables. @@ -35,6 +36,7 @@ public interface VariableRepository extends StaticService, VariableAware { * @param name of the variable * @return the old value of the variable, or null if there was no variable for the given name */ + @Nullable Object removeVariable(String name); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/VariableRepositoryFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/VariableRepositoryFactory.java index 3029963952e64..3d05af95f46db 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/VariableRepositoryFactory.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/VariableRepositoryFactory.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * Factory for {@link VariableRepository}. */ @@ -37,6 +39,7 @@ public interface VariableRepositoryFactory { * @param id the repository id * @return the repository or null if none found */ + @Nullable VariableRepository getVariableRepository(String id); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/package-info.java b/core/camel-api/src/main/java/org/apache/camel/spi/package-info.java new file mode 100644 index 0000000000000..ded66bb20cf3b --- /dev/null +++ b/core/camel-api/src/main/java/org/apache/camel/spi/package-info.java @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +package org.apache.camel.spi; + +import org.jspecify.annotations.NullMarked; diff --git a/core/camel-api/src/main/java/org/apache/camel/support/jsse/AliasedX509ExtendedKeyManager.java b/core/camel-api/src/main/java/org/apache/camel/support/jsse/AliasedX509ExtendedKeyManager.java index 477237203561b..83421575da574 100644 --- a/core/camel-api/src/main/java/org/apache/camel/support/jsse/AliasedX509ExtendedKeyManager.java +++ b/core/camel-api/src/main/java/org/apache/camel/support/jsse/AliasedX509ExtendedKeyManager.java @@ -25,6 +25,8 @@ import javax.net.ssl.X509ExtendedKeyManager; import javax.net.ssl.X509KeyManager; +import org.jspecify.annotations.Nullable; + /** * KeyManager to select a key with desired alias while delegating processing to specified KeyManager Can be used both * with server and client sockets @@ -45,42 +47,44 @@ public AliasedX509ExtendedKeyManager(String keyAlias, X509KeyManager keyManager) } @Override - public String chooseClientAlias(String[] keyType, Principal[] issuers, Socket socket) { + public @Nullable String chooseClientAlias(String[] keyType, Principal @Nullable [] issuers, @Nullable Socket socket) { return keyAlias == null ? keyManager.chooseClientAlias(keyType, issuers, socket) : keyAlias; } @Override - public String chooseServerAlias(String keyType, Principal[] issuers, Socket socket) { + public @Nullable String chooseServerAlias(String keyType, Principal @Nullable [] issuers, @Nullable Socket socket) { return keyAlias == null ? keyManager.chooseServerAlias(keyType, issuers, socket) : keyAlias; } @Override - public String[] getClientAliases(String keyType, Principal[] issuers) { + public String @Nullable [] getClientAliases(String keyType, Principal @Nullable [] issuers) { return keyManager.getClientAliases(keyType, issuers); } @Override - public String[] getServerAliases(String keyType, Principal[] issuers) { + public String @Nullable [] getServerAliases(String keyType, Principal @Nullable [] issuers) { return keyManager.getServerAliases(keyType, issuers); } @Override - public X509Certificate[] getCertificateChain(String alias) { + public X509Certificate @Nullable [] getCertificateChain(String alias) { return keyManager.getCertificateChain(alias); } @Override - public PrivateKey getPrivateKey(String alias) { + public @Nullable PrivateKey getPrivateKey(String alias) { return keyManager.getPrivateKey(alias); } @Override - public String chooseEngineServerAlias(String keyType, Principal[] issuers, SSLEngine engine) { + public @Nullable String chooseEngineServerAlias( + String keyType, Principal @Nullable [] issuers, @Nullable SSLEngine engine) { return keyAlias == null ? super.chooseEngineServerAlias(keyType, issuers, engine) : keyAlias; } @Override - public String chooseEngineClientAlias(String[] keyType, Principal[] issuers, SSLEngine engine) { + public @Nullable String chooseEngineClientAlias( + String[] keyType, Principal @Nullable [] issuers, @Nullable SSLEngine engine) { return keyAlias == null ? super.chooseEngineClientAlias(keyType, issuers, engine) : keyAlias; } } diff --git a/core/camel-api/src/main/java/org/apache/camel/support/jsse/BaseSSLContextParameters.java b/core/camel-api/src/main/java/org/apache/camel/support/jsse/BaseSSLContextParameters.java index 2107ace5366b5..2f0651f3f27a6 100644 --- a/core/camel-api/src/main/java/org/apache/camel/support/jsse/BaseSSLContextParameters.java +++ b/core/camel-api/src/main/java/org/apache/camel/support/jsse/BaseSSLContextParameters.java @@ -47,6 +47,7 @@ import javax.net.ssl.TrustManager; import org.apache.camel.support.jsse.FilterParameters.Patterns; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -119,7 +120,7 @@ public abstract class BaseSSLContextParameters extends JsseParameters { SET_SIGNATURE_SCHEMES = sss; } - static String[] getNamedGroupsFromParams(SSLParameters params) { + static String @Nullable [] getNamedGroupsFromParams(SSLParameters params) { if (GET_NAMED_GROUPS == null) { return null; } @@ -166,51 +167,51 @@ private static void setSignatureSchemesOnParams(SSLParameters params, String[] s /** * The optional explicitly configured cipher suites for this configuration. */ - private CipherSuitesParameters cipherSuites; + private @Nullable CipherSuitesParameters cipherSuites; /** * The optional cipher suite filter configuration for this configuration. */ - private FilterParameters cipherSuitesFilter; + private @Nullable FilterParameters cipherSuitesFilter; /** * The optional explicitly configured secure socket protocol names for this configuration. */ - private SecureSocketProtocolsParameters secureSocketProtocols; + private @Nullable SecureSocketProtocolsParameters secureSocketProtocols; /** * The option secure socket protocol name filter configuration for this configuration. */ - private FilterParameters secureSocketProtocolsFilter; + private @Nullable FilterParameters secureSocketProtocolsFilter; /** * The optional explicitly configured named groups (key exchange groups) for this configuration. Named groups * control which key exchange algorithms are available during the TLS handshake, including post-quantum hybrid * groups such as X25519MLKEM768. */ - private NamedGroupsParameters namedGroups; + private @Nullable NamedGroupsParameters namedGroups; /** * The optional named groups filter configuration for this configuration. */ - private FilterParameters namedGroupsFilter; + private @Nullable FilterParameters namedGroupsFilter; /** * The optional explicitly configured signature schemes for this configuration. Signature schemes control which * signature algorithms are available during the TLS handshake, including post-quantum signature algorithms such as * ML-DSA. */ - private SignatureSchemesParameters signatureSchemes; + private @Nullable SignatureSchemesParameters signatureSchemes; /** * The optional signature schemes filter configuration for this configuration. */ - private FilterParameters signatureSchemesFilter; + private @Nullable FilterParameters signatureSchemesFilter; /** * The optional {@link SSLSessionContext} timeout time for {@link javax.net.ssl.SSLSession}s in seconds. */ - private String sessionTimeout; + private @Nullable String sessionTimeout; protected List getSNIHostNames() { return Collections.emptyList(); @@ -223,7 +224,7 @@ protected List getSNIHostNames() { *

* These values override any filters supplied in {@link #setCipherSuitesFilter(FilterParameters)} */ - public CipherSuitesParameters getCipherSuites() { + public @Nullable CipherSuitesParameters getCipherSuites() { return cipherSuites; } @@ -236,7 +237,7 @@ public CipherSuitesParameters getCipherSuites() { * * @param cipherSuites the suite configuration */ - public void setCipherSuites(CipherSuitesParameters cipherSuites) { + public void setCipherSuites(@Nullable CipherSuitesParameters cipherSuites) { this.cipherSuites = cipherSuites; } @@ -248,7 +249,7 @@ public void setCipherSuites(CipherSuitesParameters cipherSuites) { * These values are ignored if {@link #setCipherSuites(CipherSuitesParameters)} is called with a non {@code null} * argument. */ - public FilterParameters getCipherSuitesFilter() { + public @Nullable FilterParameters getCipherSuitesFilter() { return cipherSuitesFilter; } @@ -262,7 +263,7 @@ public FilterParameters getCipherSuitesFilter() { * * @param cipherSuitesFilter the filter configuration */ - public void setCipherSuitesFilter(FilterParameters cipherSuitesFilter) { + public void setCipherSuitesFilter(@Nullable FilterParameters cipherSuitesFilter) { this.cipherSuitesFilter = cipherSuitesFilter; } @@ -273,7 +274,7 @@ public void setCipherSuitesFilter(FilterParameters cipherSuitesFilter) { *

* These values override any filters supplied in {@link #setSecureSocketProtocolsFilter(FilterParameters)} */ - public SecureSocketProtocolsParameters getSecureSocketProtocols() { + public @Nullable SecureSocketProtocolsParameters getSecureSocketProtocols() { return secureSocketProtocols; } @@ -284,7 +285,7 @@ public SecureSocketProtocolsParameters getSecureSocketProtocols() { *

* These values override any filters supplied in {@link #setSecureSocketProtocolsFilter(FilterParameters)} */ - public void setSecureSocketProtocols(SecureSocketProtocolsParameters secureSocketProtocols) { + public void setSecureSocketProtocols(@Nullable SecureSocketProtocolsParameters secureSocketProtocols) { this.secureSocketProtocols = secureSocketProtocols; } @@ -296,7 +297,7 @@ public void setSecureSocketProtocols(SecureSocketProtocolsParameters secureSocke * These values are ignored if {@link #setSecureSocketProtocols(SecureSocketProtocolsParameters)} is called with a * non-{@code null} argument. */ - public FilterParameters getSecureSocketProtocolsFilter() { + public @Nullable FilterParameters getSecureSocketProtocolsFilter() { return secureSocketProtocolsFilter; } @@ -310,7 +311,7 @@ public FilterParameters getSecureSocketProtocolsFilter() { * * @param secureSocketProtocolsFilter the filter configuration */ - public void setSecureSocketProtocolsFilter(FilterParameters secureSocketProtocolsFilter) { + public void setSecureSocketProtocolsFilter(@Nullable FilterParameters secureSocketProtocolsFilter) { this.secureSocketProtocolsFilter = secureSocketProtocolsFilter; } @@ -324,7 +325,7 @@ public void setSecureSocketProtocolsFilter(FilterParameters secureSocketProtocol *

* These values override any filters supplied in {@link #setNamedGroupsFilter(FilterParameters)} */ - public NamedGroupsParameters getNamedGroups() { + public @Nullable NamedGroupsParameters getNamedGroups() { return namedGroups; } @@ -340,7 +341,7 @@ public NamedGroupsParameters getNamedGroups() { * * @param namedGroups the named groups configuration */ - public void setNamedGroups(NamedGroupsParameters namedGroups) { + public void setNamedGroups(@Nullable NamedGroupsParameters namedGroups) { this.namedGroups = namedGroups; } @@ -352,7 +353,7 @@ public void setNamedGroups(NamedGroupsParameters namedGroups) { * These values are ignored if {@link #setNamedGroups(NamedGroupsParameters)} is called with a non {@code null} * argument. */ - public FilterParameters getNamedGroupsFilter() { + public @Nullable FilterParameters getNamedGroupsFilter() { return namedGroupsFilter; } @@ -366,7 +367,7 @@ public FilterParameters getNamedGroupsFilter() { * * @param namedGroupsFilter the filter configuration */ - public void setNamedGroupsFilter(FilterParameters namedGroupsFilter) { + public void setNamedGroupsFilter(@Nullable FilterParameters namedGroupsFilter) { this.namedGroupsFilter = namedGroupsFilter; } @@ -380,7 +381,7 @@ public void setNamedGroupsFilter(FilterParameters namedGroupsFilter) { *

* These values override any filters supplied in {@link #setSignatureSchemesFilter(FilterParameters)} */ - public SignatureSchemesParameters getSignatureSchemes() { + public @Nullable SignatureSchemesParameters getSignatureSchemes() { return signatureSchemes; } @@ -396,7 +397,7 @@ public SignatureSchemesParameters getSignatureSchemes() { * * @param signatureSchemes the signature schemes configuration */ - public void setSignatureSchemes(SignatureSchemesParameters signatureSchemes) { + public void setSignatureSchemes(@Nullable SignatureSchemesParameters signatureSchemes) { this.signatureSchemes = signatureSchemes; } @@ -408,7 +409,7 @@ public void setSignatureSchemes(SignatureSchemesParameters signatureSchemes) { * These values are ignored if {@link #setSignatureSchemes(SignatureSchemesParameters)} is called with a non * {@code null} argument. */ - public FilterParameters getSignatureSchemesFilter() { + public @Nullable FilterParameters getSignatureSchemesFilter() { return signatureSchemesFilter; } @@ -422,14 +423,14 @@ public FilterParameters getSignatureSchemesFilter() { * * @param signatureSchemesFilter the filter configuration */ - public void setSignatureSchemesFilter(FilterParameters signatureSchemesFilter) { + public void setSignatureSchemesFilter(@Nullable FilterParameters signatureSchemesFilter) { this.signatureSchemesFilter = signatureSchemesFilter; } /** * Returns the optional {@link SSLSessionContext} timeout time for {@link javax.net.ssl.SSLSession}s in seconds. */ - public String getSessionTimeout() { + public @Nullable String getSessionTimeout() { return sessionTimeout; } @@ -438,7 +439,7 @@ public String getSessionTimeout() { * * @param sessionTimeout the timeout value or {@code null} to use the default */ - public void setSessionTimeout(String sessionTimeout) { + public void setSessionTimeout(@Nullable String sessionTimeout) { this.sessionTimeout = sessionTimeout; } diff --git a/core/camel-api/src/main/java/org/apache/camel/support/jsse/CipherSuitesParameters.java b/core/camel-api/src/main/java/org/apache/camel/support/jsse/CipherSuitesParameters.java index a2b6214bb39a5..42f97cfd8b3df 100644 --- a/core/camel-api/src/main/java/org/apache/camel/support/jsse/CipherSuitesParameters.java +++ b/core/camel-api/src/main/java/org/apache/camel/support/jsse/CipherSuitesParameters.java @@ -19,11 +19,13 @@ import java.util.ArrayList; import java.util.List; +import org.jspecify.annotations.Nullable; + /** * Represents a list of TLS/SSL cipher suite names. */ public class CipherSuitesParameters { - private List cipherSuite; + private @Nullable List cipherSuite; /** * Returns a live reference to the list of cipher suite names. @@ -49,7 +51,7 @@ public void addCipherSuite(String cipher) { * * @param cipherSuite cipher suite */ - public void setCipherSuite(List cipherSuite) { + public void setCipherSuite(@Nullable List cipherSuite) { this.cipherSuite = cipherSuite == null ? null : new ArrayList<>(cipherSuite); } diff --git a/core/camel-api/src/main/java/org/apache/camel/support/jsse/FilterParameters.java b/core/camel-api/src/main/java/org/apache/camel/support/jsse/FilterParameters.java index a881526821d71..ece1af7637f83 100644 --- a/core/camel-api/src/main/java/org/apache/camel/support/jsse/FilterParameters.java +++ b/core/camel-api/src/main/java/org/apache/camel/support/jsse/FilterParameters.java @@ -23,13 +23,15 @@ import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; +import org.jspecify.annotations.Nullable; + /** * Represents a set of regular expression based filter patterns for including and excluding content of some type. */ public class FilterParameters extends JsseParameters { - protected List include; - protected List exclude; + protected @Nullable List include; + protected @Nullable List exclude; /** * Returns a live copy of the list of patterns to include. The list of excludes takes precedence over the include diff --git a/core/camel-api/src/main/java/org/apache/camel/support/jsse/JsseParameters.java b/core/camel-api/src/main/java/org/apache/camel/support/jsse/JsseParameters.java index 1f1984bd83989..e83f29e15fb4f 100644 --- a/core/camel-api/src/main/java/org/apache/camel/support/jsse/JsseParameters.java +++ b/core/camel-api/src/main/java/org/apache/camel/support/jsse/JsseParameters.java @@ -28,19 +28,20 @@ import org.apache.camel.spi.Resource; import org.apache.camel.spi.ResourceLoader; import org.apache.camel.util.ObjectHelper; +import org.jspecify.annotations.Nullable; /** * Base class that provides optional integration with core Camel capabilities. */ public class JsseParameters implements CamelContextAware { - private CamelContext context; + private @Nullable CamelContext context; /** * @see #setCamelContext(CamelContext) */ @Override - public CamelContext getCamelContext() { + public @Nullable CamelContext getCamelContext() { return context; } diff --git a/core/camel-api/src/main/java/org/apache/camel/support/jsse/KeyManagersParameters.java b/core/camel-api/src/main/java/org/apache/camel/support/jsse/KeyManagersParameters.java index 3a22524ba2a4d..4f27565370d18 100644 --- a/core/camel-api/src/main/java/org/apache/camel/support/jsse/KeyManagersParameters.java +++ b/core/camel-api/src/main/java/org/apache/camel/support/jsse/KeyManagersParameters.java @@ -24,6 +24,7 @@ import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,10 +35,10 @@ public class KeyManagersParameters extends JsseParameters { private static final Logger LOG = LoggerFactory.getLogger(KeyManagersParameters.class); - protected KeyStoreParameters keyStore; - protected String keyPassword; - protected String provider; - protected String algorithm; + protected @Nullable KeyStoreParameters keyStore; + protected @Nullable String keyPassword; + protected @Nullable String provider; + protected @Nullable String algorithm; /** * Creates {@link KeyManager}s based on this instance's configuration and the {@code KeyStore} produced by the @@ -86,7 +87,7 @@ public KeyManager[] createKeyManagers() throws GeneralSecurityException, IOExcep return keyManagers; } - public KeyStoreParameters getKeyStore() { + public @Nullable KeyStoreParameters getKeyStore() { return keyStore; } @@ -96,11 +97,11 @@ public KeyStoreParameters getKeyStore() { * * @param value the configuration to use */ - public void setKeyStore(KeyStoreParameters value) { + public void setKeyStore(@Nullable KeyStoreParameters value) { this.keyStore = value; } - public String getKeyPassword() { + public @Nullable String getKeyPassword() { return keyPassword; } @@ -110,11 +111,11 @@ public String getKeyPassword() { * * @param value the value to use */ - public void setKeyPassword(String value) { + public void setKeyPassword(@Nullable String value) { this.keyPassword = value; } - public String getProvider() { + public @Nullable String getProvider() { return provider; } @@ -127,11 +128,11 @@ public String getProvider() { * * @see Security#getProviders() */ - public void setProvider(String value) { + public void setProvider(@Nullable String value) { this.provider = value; } - public String getAlgorithm() { + public @Nullable String getAlgorithm() { return algorithm; } @@ -144,7 +145,7 @@ public String getAlgorithm() { * @param value the desired algorithm or {@code null} to use default * @see KeyManagerFactory#getDefaultAlgorithm() */ - public void setAlgorithm(String value) { + public void setAlgorithm(@Nullable String value) { this.algorithm = value; } diff --git a/core/camel-api/src/main/java/org/apache/camel/support/jsse/KeyStoreParameters.java b/core/camel-api/src/main/java/org/apache/camel/support/jsse/KeyStoreParameters.java index 113c246b07a66..6eb4ae62e2a12 100644 --- a/core/camel-api/src/main/java/org/apache/camel/support/jsse/KeyStoreParameters.java +++ b/core/camel-api/src/main/java/org/apache/camel/support/jsse/KeyStoreParameters.java @@ -26,6 +26,7 @@ import java.util.LinkedList; import java.util.List; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,13 +37,13 @@ public class KeyStoreParameters extends JsseParameters { private static final Logger LOG = LoggerFactory.getLogger(KeyStoreParameters.class); - protected String type; - protected String password; - protected String provider; - protected KeyStore keyStore; - protected String resource; + protected @Nullable String type; + protected @Nullable String password; + protected @Nullable String provider; + protected @Nullable KeyStore keyStore; + protected @Nullable String resource; - public String getType() { + public @Nullable String getType() { return type; } @@ -51,22 +52,22 @@ public String getType() { * * See https://docs.oracle.com/en/java/javase/17/docs/specs/security/standard-names.html */ - public void setType(String value) { + public void setType(@Nullable String value) { this.type = value; } - public String getPassword() { + public @Nullable String getPassword() { return password; } /** * The password for reading/opening/verifying the key store. */ - public void setPassword(String value) { + public void setPassword(@Nullable String value) { this.password = value; } - public String getProvider() { + public @Nullable String getProvider() { return provider; } @@ -75,11 +76,11 @@ public String getProvider() { * * @see Security#getProviders() */ - public void setProvider(String value) { + public void setProvider(@Nullable String value) { this.provider = value; } - public String getResource() { + public @Nullable String getResource() { return resource; } @@ -92,14 +93,14 @@ public String getResource() { * (to load the resource using HTTP) ref:nameOfBean (to lookup an existing KeyStore instance from the registry, for * example for testing and development). */ - public void setResource(String value) { + public void setResource(@Nullable String value) { this.resource = value; } /** * To use an existing KeyStore instead of loading. You must also set password so this keystore can be used. */ - public void setKeyStore(KeyStore keyStore) { + public void setKeyStore(@Nullable KeyStore keyStore) { this.keyStore = keyStore; } diff --git a/core/camel-api/src/main/java/org/apache/camel/support/jsse/NamedGroupsParameters.java b/core/camel-api/src/main/java/org/apache/camel/support/jsse/NamedGroupsParameters.java index 760778618d72e..6808c81cf94af 100644 --- a/core/camel-api/src/main/java/org/apache/camel/support/jsse/NamedGroupsParameters.java +++ b/core/camel-api/src/main/java/org/apache/camel/support/jsse/NamedGroupsParameters.java @@ -19,13 +19,15 @@ import java.util.ArrayList; import java.util.List; +import org.jspecify.annotations.Nullable; + /** * Represents a list of TLS/SSL named groups (also known as elliptic curves or key exchange groups) for use in TLS * handshakes. Named groups control which key exchange algorithms are available during the TLS handshake, including * post-quantum hybrid groups such as {@code X25519MLKEM768}. */ public class NamedGroupsParameters { - private List namedGroup; + private @Nullable List namedGroup; /** * Returns a live reference to the list of named group names. diff --git a/core/camel-api/src/main/java/org/apache/camel/support/jsse/SSLContextParameters.java b/core/camel-api/src/main/java/org/apache/camel/support/jsse/SSLContextParameters.java index 8a86f15daace2..ffc05f4ae9be2 100644 --- a/core/camel-api/src/main/java/org/apache/camel/support/jsse/SSLContextParameters.java +++ b/core/camel-api/src/main/java/org/apache/camel/support/jsse/SSLContextParameters.java @@ -33,6 +33,7 @@ import javax.net.ssl.X509KeyManager; import org.apache.camel.CamelContext; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -61,19 +62,19 @@ public class SSLContextParameters extends BaseSSLContextParameters { * The optional key manager configuration for creating the {@link KeyManager}s used in constructing an * {@link SSLContext}. */ - private KeyManagersParameters keyManagers; + private @Nullable KeyManagersParameters keyManagers; /** * The optional trust manager configuration for creating the {@link TrustManager}s used in constructing an * {@link SSLContext}. */ - private TrustManagersParameters trustManagers; + private @Nullable TrustManagersParameters trustManagers; /** * The optional secure random configuration options to use for constructing the {@link SecureRandom} used in the * creation of an {@link SSLContext}. */ - private SecureRandomParameters secureRandom; + private @Nullable SecureRandomParameters secureRandom; /** * The optional configuration options to be applied purely to the client side settings of the {@link SSLContext}. @@ -81,7 +82,7 @@ public class SSLContextParameters extends BaseSSLContextParameters { * parameters apply to {@link SSLSocketFactory}s and {@link SSLEngine}s produced by the {@code SSLContext} produced * from this class as well as to the {@code SSLContext} itself. */ - private SSLContextClientParameters clientParameters; + private @Nullable SSLContextClientParameters clientParameters; /** * The optional configuration options to be applied purely to the server side settings of the {@link SSLContext}. @@ -89,12 +90,12 @@ public class SSLContextParameters extends BaseSSLContextParameters { * parameters apply to {@link SSLServerSocketFactory}s and {@link SSLEngine}s produced by the {@code SSLContext} * produced from this class as well as to the {@code SSLContext} itself. */ - private SSLContextServerParameters serverParameters; + private @Nullable SSLContextServerParameters serverParameters; /** * The optional provider identifier for the JSSE implementation to use when constructing an {@link SSLContext}. */ - private String provider; + private @Nullable String provider; /** * The optional protocol for the secure sockets created by the {@link SSLContext} represented by this instance's @@ -102,14 +103,14 @@ public class SSLContextParameters extends BaseSSLContextParameters { * * See https://docs.oracle.com/en/java/javase/17/docs/specs/security/standard-names.html */ - private String secureSocketProtocol; + private @Nullable String secureSocketProtocol; /** * An optional certificate alias to use. This is useful when the keystore has multiple certificates. */ - private String certAlias; + private @Nullable String certAlias; - public KeyManagersParameters getKeyManagers() { + public @Nullable KeyManagersParameters getKeyManagers() { return keyManagers; } @@ -119,11 +120,11 @@ public KeyManagersParameters getKeyManagers() { * * @param keyManagers the options or {@code null} to provide no {@code KeyManager}s */ - public void setKeyManagers(KeyManagersParameters keyManagers) { + public void setKeyManagers(@Nullable KeyManagersParameters keyManagers) { this.keyManagers = keyManagers; } - public TrustManagersParameters getTrustManagers() { + public @Nullable TrustManagersParameters getTrustManagers() { return trustManagers; } @@ -133,11 +134,11 @@ public TrustManagersParameters getTrustManagers() { * * @param trustManagers the options or {@code null} to provide no {@code TrustManager}s */ - public void setTrustManagers(TrustManagersParameters trustManagers) { + public void setTrustManagers(@Nullable TrustManagersParameters trustManagers) { this.trustManagers = trustManagers; } - public SecureRandomParameters getSecureRandom() { + public @Nullable SecureRandomParameters getSecureRandom() { return secureRandom; } @@ -147,11 +148,11 @@ public SecureRandomParameters getSecureRandom() { * * @param secureRandom the options or {@code null} to use the default */ - public void setSecureRandom(SecureRandomParameters secureRandom) { + public void setSecureRandom(@Nullable SecureRandomParameters secureRandom) { this.secureRandom = secureRandom; } - public SSLContextClientParameters getClientParameters() { + public @Nullable SSLContextClientParameters getClientParameters() { return clientParameters; } @@ -163,11 +164,11 @@ public SSLContextClientParameters getClientParameters() { * * @param clientParameters the optional additional client-side parameters */ - public void setClientParameters(SSLContextClientParameters clientParameters) { + public void setClientParameters(@Nullable SSLContextClientParameters clientParameters) { this.clientParameters = clientParameters; } - public SSLContextServerParameters getServerParameters() { + public @Nullable SSLContextServerParameters getServerParameters() { return serverParameters; } @@ -179,11 +180,11 @@ public SSLContextServerParameters getServerParameters() { * * @param serverParameters the optional additional client-side parameters */ - public void setServerParameters(SSLContextServerParameters serverParameters) { + public void setServerParameters(@Nullable SSLContextServerParameters serverParameters) { this.serverParameters = serverParameters; } - public String getProvider() { + public @Nullable String getProvider() { return provider; } @@ -196,7 +197,7 @@ public String getProvider() { * @see Security#getProviders(java.util.Map) * @see #setSecureSocketProtocol(String) */ - public void setProvider(String provider) { + public void setProvider(@Nullable String provider) { this.provider = provider; } @@ -215,11 +216,11 @@ public String getSecureSocketProtocol() { * * @param secureSocketProtocol the name of the protocol or {@code null} to use the default (TLS) */ - public void setSecureSocketProtocol(String secureSocketProtocol) { + public void setSecureSocketProtocol(@Nullable String secureSocketProtocol) { this.secureSocketProtocol = secureSocketProtocol; } - public String getCertAlias() { + public @Nullable String getCertAlias() { return certAlias; } @@ -228,7 +229,7 @@ public String getCertAlias() { * * @param certAlias an optional certificate alias to use */ - public void setCertAlias(String certAlias) { + public void setCertAlias(@Nullable String certAlias) { this.certAlias = certAlias; } diff --git a/core/camel-api/src/main/java/org/apache/camel/support/jsse/SSLContextServerParameters.java b/core/camel-api/src/main/java/org/apache/camel/support/jsse/SSLContextServerParameters.java index 7531b5e290712..785cfe7e4902a 100644 --- a/core/camel-api/src/main/java/org/apache/camel/support/jsse/SSLContextServerParameters.java +++ b/core/camel-api/src/main/java/org/apache/camel/support/jsse/SSLContextServerParameters.java @@ -27,6 +27,7 @@ import javax.net.ssl.SSLSocketFactory; import org.apache.camel.RuntimeCamelException; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,9 +35,9 @@ public class SSLContextServerParameters extends BaseSSLContextParameters { private static final Logger LOG = LoggerFactory.getLogger(SSLContextServerParameters.class); - protected String clientAuthentication; + protected @Nullable String clientAuthentication; - public String getClientAuthentication() { + public @Nullable String getClientAuthentication() { return clientAuthentication; } @@ -46,7 +47,7 @@ public String getClientAuthentication() { * * @param value the desired configuration options or {@code null} to use the defaults */ - public void setClientAuthentication(String value) { + public void setClientAuthentication(@Nullable String value) { this.clientAuthentication = value; } diff --git a/core/camel-api/src/main/java/org/apache/camel/support/jsse/SecureRandomParameters.java b/core/camel-api/src/main/java/org/apache/camel/support/jsse/SecureRandomParameters.java index 48c3fbfff64f9..9ab5bd5eb72e4 100644 --- a/core/camel-api/src/main/java/org/apache/camel/support/jsse/SecureRandomParameters.java +++ b/core/camel-api/src/main/java/org/apache/camel/support/jsse/SecureRandomParameters.java @@ -20,6 +20,7 @@ import java.security.SecureRandom; import java.security.Security; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,8 +28,8 @@ public class SecureRandomParameters extends JsseParameters { private static final Logger LOG = LoggerFactory.getLogger(SecureRandomParameters.class); - protected String algorithm; - protected String provider; + protected @Nullable String algorithm; + protected @Nullable String provider; /** * Returns a {@code SecureRandom} instance initialized using the configured algorithm and provider, if specified. @@ -55,7 +56,7 @@ public SecureRandom createSecureRandom() throws GeneralSecurityException { return secureRandom; } - public String getAlgorithm() { + public @Nullable String getAlgorithm() { return algorithm; } @@ -67,11 +68,11 @@ public String getAlgorithm() { * * @param value the algorithm identifier */ - public void setAlgorithm(String value) { + public void setAlgorithm(@Nullable String value) { this.algorithm = value; } - public String getProvider() { + public @Nullable String getProvider() { return provider; } @@ -84,7 +85,7 @@ public String getProvider() { * * @see Security#getProviders() */ - public void setProvider(String value) { + public void setProvider(@Nullable String value) { this.provider = value; } diff --git a/core/camel-api/src/main/java/org/apache/camel/support/jsse/SecureSocketProtocolsParameters.java b/core/camel-api/src/main/java/org/apache/camel/support/jsse/SecureSocketProtocolsParameters.java index 40b5da0a96238..3327479f61f71 100644 --- a/core/camel-api/src/main/java/org/apache/camel/support/jsse/SecureSocketProtocolsParameters.java +++ b/core/camel-api/src/main/java/org/apache/camel/support/jsse/SecureSocketProtocolsParameters.java @@ -19,11 +19,13 @@ import java.util.ArrayList; import java.util.List; +import org.jspecify.annotations.Nullable; + /** * Represents a list of TLS/SSL cipher suite names. */ public class SecureSocketProtocolsParameters { - private List secureSocketProtocol; + private @Nullable List secureSocketProtocol; /** * Returns a live reference to the list of secure socket protocol names. @@ -42,7 +44,7 @@ public List getSecureSocketProtocol() { * * @param secureSocketProtocol list of secure socket protocol names */ - public void setSecureSocketProtocol(List secureSocketProtocol) { + public void setSecureSocketProtocol(@Nullable List secureSocketProtocol) { this.secureSocketProtocol = secureSocketProtocol == null ? null : new ArrayList<>(secureSocketProtocol); } diff --git a/core/camel-api/src/main/java/org/apache/camel/support/jsse/SignatureSchemesParameters.java b/core/camel-api/src/main/java/org/apache/camel/support/jsse/SignatureSchemesParameters.java index bb13c65825b3e..9ced89a4f0b5f 100644 --- a/core/camel-api/src/main/java/org/apache/camel/support/jsse/SignatureSchemesParameters.java +++ b/core/camel-api/src/main/java/org/apache/camel/support/jsse/SignatureSchemesParameters.java @@ -19,12 +19,14 @@ import java.util.ArrayList; import java.util.List; +import org.jspecify.annotations.Nullable; + /** * Represents a list of TLS/SSL signature schemes for use in TLS handshakes. Signature schemes control which signature * algorithms are available during the TLS handshake, including post-quantum signature algorithms such as ML-DSA. */ public class SignatureSchemesParameters { - private List signatureScheme; + private @Nullable List signatureScheme; /** * Returns a live reference to the list of signature scheme names. diff --git a/core/camel-api/src/main/java/org/apache/camel/support/jsse/TrustManagersParameters.java b/core/camel-api/src/main/java/org/apache/camel/support/jsse/TrustManagersParameters.java index 43acae5ad05dc..e54cb7ce4ecce 100644 --- a/core/camel-api/src/main/java/org/apache/camel/support/jsse/TrustManagersParameters.java +++ b/core/camel-api/src/main/java/org/apache/camel/support/jsse/TrustManagersParameters.java @@ -24,6 +24,7 @@ import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,10 +32,10 @@ public class TrustManagersParameters extends JsseParameters { private static final Logger LOG = LoggerFactory.getLogger(TrustManagersParameters.class); - protected KeyStoreParameters keyStore; - protected String provider; - protected String algorithm; - protected TrustManager trustManager; + protected @Nullable KeyStoreParameters keyStore; + protected @Nullable String provider; + protected @Nullable String algorithm; + protected @Nullable TrustManager trustManager; /** * Creates {@link TrustManager}s based on this instance's configuration and the {@code KeyStore} produced by the @@ -85,7 +86,7 @@ public TrustManager[] createTrustManagers() throws GeneralSecurityException, IOE return trustManagers; } - public KeyStoreParameters getKeyStore() { + public @Nullable KeyStoreParameters getKeyStore() { return keyStore; } @@ -95,11 +96,11 @@ public KeyStoreParameters getKeyStore() { * * @param value the configuration to use */ - public void setKeyStore(KeyStoreParameters value) { + public void setKeyStore(@Nullable KeyStoreParameters value) { this.keyStore = value; } - public String getProvider() { + public @Nullable String getProvider() { return provider; } @@ -112,11 +113,11 @@ public String getProvider() { * * @see Security#getProviders() */ - public void setProvider(String value) { + public void setProvider(@Nullable String value) { this.provider = value; } - public String getAlgorithm() { + public @Nullable String getAlgorithm() { return algorithm; } @@ -129,11 +130,11 @@ public String getAlgorithm() { * @param value the desired algorithm or {@code null} to use default * @see TrustManagerFactory#getDefaultAlgorithm() */ - public void setAlgorithm(String value) { + public void setAlgorithm(@Nullable String value) { this.algorithm = value; } - public TrustManager getTrustManager() { + public @Nullable TrustManager getTrustManager() { return trustManager; } @@ -141,7 +142,7 @@ public TrustManager getTrustManager() { * To use an existing configured trust manager instead of using {@link TrustManagerFactory} to get the * {@link TrustManager}. */ - public void setTrustManager(TrustManager trustManager) { + public void setTrustManager(@Nullable TrustManager trustManager) { this.trustManager = trustManager; } diff --git a/core/camel-api/src/main/java/org/apache/camel/support/jsse/package-info.java b/core/camel-api/src/main/java/org/apache/camel/support/jsse/package-info.java new file mode 100644 index 0000000000000..c50c57b0bf11d --- /dev/null +++ b/core/camel-api/src/main/java/org/apache/camel/support/jsse/package-info.java @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +package org.apache.camel.support.jsse; + +import org.jspecify.annotations.NullMarked; diff --git a/core/camel-api/src/main/java/org/apache/camel/support/service/BaseService.java b/core/camel-api/src/main/java/org/apache/camel/support/service/BaseService.java index 9d391be7e509c..bfa4de1fac3ae 100644 --- a/core/camel-api/src/main/java/org/apache/camel/support/service/BaseService.java +++ b/core/camel-api/src/main/java/org/apache/camel/support/service/BaseService.java @@ -21,6 +21,7 @@ import org.apache.camel.RuntimeCamelException; import org.apache.camel.ServiceStatus; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -434,7 +435,7 @@ protected void doFail(Exception e) { /** * Implementations may return an object that will be closed when the lifecycle action is completed. */ - protected AutoCloseable doLifecycleChange() { + protected @Nullable AutoCloseable doLifecycleChange() { return null; } diff --git a/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceHelper.java b/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceHelper.java index 2c613f4a882c9..508a6a9b38ec7 100644 --- a/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceHelper.java +++ b/core/camel-api/src/main/java/org/apache/camel/support/service/ServiceHelper.java @@ -30,6 +30,7 @@ import org.apache.camel.StatefulService; import org.apache.camel.Suspendable; import org.apache.camel.SuspendableService; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,7 +52,7 @@ private ServiceHelper() { *

* Calling this method has no effect if {@code value} is {@code null}. */ - public static void buildService(Object value) { + public static void buildService(@Nullable Object value) { if (value instanceof Service service) { service.build(); } else if (value instanceof Iterable iterable) { @@ -67,7 +68,7 @@ public static void buildService(Object value) { * * @see #buildService(Object) */ - public static void buildService(Object... services) { + public static void buildService(@Nullable Object @Nullable... services) { if (services != null) { for (Object o : services) { buildService(o); @@ -80,7 +81,7 @@ public static void buildService(Object... services) { *

* Calling this method has no effect if {@code value} is {@code null}. */ - public static void initService(Object value) { + public static void initService(@Nullable Object value) { if (value instanceof Service service) { service.init(); } else if (value instanceof Iterable iterable) { @@ -96,7 +97,7 @@ public static void initService(Object value) { * * @see #initService(Object) */ - public static void initService(Object... services) { + public static void initService(@Nullable Object @Nullable... services) { if (services != null) { for (Object o : services) { initService(o); @@ -109,7 +110,7 @@ public static void initService(Object... services) { *

* Calling this method has no effect if {@code value} is {@code null}. */ - public static void startService(Object value) { + public static void startService(@Nullable Object value) { if (value instanceof Service service) { startService(service); } else if (value instanceof Iterable iterable) { @@ -122,7 +123,7 @@ public static void startService(Object value) { *

* Calling this method has no effect if {@code value} is {@code null}. */ - public static void startService(Service service) { + public static void startService(@Nullable Service service) { if (service != null) { service.start(); } @@ -133,7 +134,7 @@ public static void startService(Service service) { *

* Calling this method has no effect if {@code value} is {@code null}. */ - public static void startService(Iterable value) { + public static void startService(@Nullable Iterable value) { if (value != null) { for (Object o : value) { startService(o); @@ -147,7 +148,7 @@ public static void startService(Iterable value) { * * @see #startService(Object) */ - public static void startService(Object... services) { + public static void startService(@Nullable Object @Nullable... services) { if (services != null) { for (Object o : services) { startService(o); @@ -164,7 +165,7 @@ public static void startService(Object... services) { * * @see #stopService(Collection) */ - public static void stopService(Object... services) { + public static void stopService(@Nullable Object @Nullable... services) { if (services != null) { for (Object o : services) { stopService(o); @@ -180,7 +181,7 @@ public static void stopService(Object... services) { * @see Service#stop() * @see #stopService(Collection) */ - public static void stopService(Object value) { + public static void stopService(@Nullable Object value) { if (value instanceof Service service) { stopService(service); } else if (value instanceof Iterable iterable) { @@ -196,7 +197,7 @@ public static void stopService(Object value) { * @see Service#stop() * @see #stopService(Collection) */ - public static void stopService(Service service) { + public static void stopService(@Nullable Service service) { if (service != null) { service.stop(); } @@ -210,7 +211,7 @@ public static void stopService(Service service) { * @see Service#stop() * @see #stopService(Collection) */ - public static void stopService(Iterable value) { + public static void stopService(@Nullable Iterable value) { if (value != null) { for (Object o : value) { stopService(o); @@ -227,7 +228,7 @@ public static void stopService(Iterable value) { * * @see #stopService(Object) */ - public static void stopService(Collection services) { + public static void stopService(@Nullable Collection services) { if (services == null) { return; } @@ -258,7 +259,7 @@ public static void stopService(Collection services) { * * @see #stopAndShutdownServices(Collection) */ - public static void stopAndShutdownServices(Object... services) { + public static void stopAndShutdownServices(@Nullable Object @Nullable... services) { if (services == null) { return; } @@ -274,7 +275,7 @@ public static void stopAndShutdownServices(Object... services) { * @see #stopService(Object) * @see ShutdownableService#shutdown() */ - public static void stopAndShutdownService(Object value) { + public static void stopAndShutdownService(@Nullable Object value) { stopService(value); // then try to shutdown @@ -292,7 +293,7 @@ public static void stopAndShutdownService(Object value) { * @see #stopService(Object) * @see ShutdownableService#shutdown() */ - public static void stopAndShutdownService(ShutdownableService service) { + public static void stopAndShutdownService(@Nullable ShutdownableService service) { stopService(service); if (service != null) { @@ -311,7 +312,7 @@ public static void stopAndShutdownService(ShutdownableService service) { * @see #stopService(Object) * @see ShutdownableService#shutdown() */ - public static void stopAndShutdownServices(Collection services) { + public static void stopAndShutdownServices(@Nullable Collection services) { if (services == null) { return; } @@ -344,7 +345,7 @@ public static void stopAndShutdownServices(Collection services) { * * @see #resumeService(Object) */ - public static void resumeServices(Collection services) { + public static void resumeServices(@Nullable Collection services) { if (services == null) { return; } @@ -386,7 +387,7 @@ public static void resumeServices(Collection services) { * @throws Exception is thrown if error occurred * @see #startService(Object) */ - public static boolean resumeService(Object service) { + public static boolean resumeService(@Nullable Object service) { if (service instanceof Suspendable && service instanceof SuspendableService ss) { if (ss.isSuspended()) { LOG.debug("Resuming service {}", service); @@ -410,7 +411,7 @@ public static boolean resumeService(Object service) { * * @see #suspendService(Object) */ - public static void suspendServices(Collection services) { + public static void suspendServices(@Nullable Collection services) { if (services == null) { return; } @@ -452,7 +453,7 @@ public static void suspendServices(Collection services) { * @throws Exception is thrown if error occurred * @see #stopService(Object) */ - public static boolean suspendService(Object service) { + public static boolean suspendService(@Nullable Object service) { if (service instanceof Suspendable && service instanceof SuspendableService ss) { if (!ss.isSuspended()) { LOG.trace("Suspending service {}", service); @@ -474,7 +475,7 @@ public static boolean suspendService(Object service) { * @see StatefulService#isStopping() * @see StatefulService#isStopped() */ - public static boolean isStopped(Object value) { + public static boolean isStopped(@Nullable Object value) { if (value instanceof StatefulService statefulService) { return isStopped(statefulService); } @@ -489,7 +490,7 @@ public static boolean isStopped(Object value) { * @see StatefulService#isStopping() * @see StatefulService#isStopped() */ - public static boolean isStopped(StatefulService service) { + public static boolean isStopped(@Nullable StatefulService service) { if (service != null && (service.isStopping() || service.isStopped())) { return true; } @@ -504,7 +505,7 @@ public static boolean isStopped(StatefulService service) { * @see StatefulService#isStarting() * @see StatefulService#isStarted() */ - public static boolean isStarted(Object value) { + public static boolean isStarted(@Nullable Object value) { if (value instanceof StatefulService statefulService) { return isStarted(statefulService); } @@ -519,7 +520,7 @@ public static boolean isStarted(Object value) { * @see StatefulService#isStarting() * @see StatefulService#isStarted() */ - public static boolean isStarted(StatefulService service) { + public static boolean isStarted(@Nullable StatefulService service) { if (service != null && (service.isStarting() || service.isStarted())) { return true; } @@ -534,7 +535,7 @@ public static boolean isStarted(StatefulService service) { * @see StatefulService#isSuspending() * @see StatefulService#isSuspended() */ - public static boolean isSuspended(Object value) { + public static boolean isSuspended(@Nullable Object value) { if (value instanceof StatefulService statefulService) { return isSuspended(statefulService); } @@ -549,7 +550,7 @@ public static boolean isSuspended(Object value) { * @see StatefulService#isSuspending() * @see StatefulService#isSuspended() */ - public static boolean isSuspended(StatefulService service) { + public static boolean isSuspended(@Nullable StatefulService service) { if (service != null && (service.isSuspending() || service.isSuspended())) { return true; } diff --git a/core/camel-api/src/main/java/org/apache/camel/support/service/package-info.java b/core/camel-api/src/main/java/org/apache/camel/support/service/package-info.java new file mode 100644 index 0000000000000..f224f6612f484 --- /dev/null +++ b/core/camel-api/src/main/java/org/apache/camel/support/service/package-info.java @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +package org.apache.camel.support.service; + +import org.jspecify.annotations.NullMarked; diff --git a/core/camel-api/src/main/java/org/apache/camel/trait/message/package-info.java b/core/camel-api/src/main/java/org/apache/camel/trait/message/package-info.java new file mode 100644 index 0000000000000..7a7ee6784deb3 --- /dev/null +++ b/core/camel-api/src/main/java/org/apache/camel/trait/message/package-info.java @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +package org.apache.camel.trait.message; + +import org.jspecify.annotations.NullMarked; diff --git a/core/camel-api/src/main/java/org/apache/camel/vault/AwsVaultConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/vault/AwsVaultConfiguration.java index ce79dedb7b273..b36b3645e5d65 100644 --- a/core/camel-api/src/main/java/org/apache/camel/vault/AwsVaultConfiguration.java +++ b/core/camel-api/src/main/java/org/apache/camel/vault/AwsVaultConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.vault; import org.apache.camel.spi.Metadata; +import org.jspecify.annotations.Nullable; /** * Configuration for access to AWS Secret. @@ -24,62 +25,62 @@ public class AwsVaultConfiguration extends VaultConfiguration { @Metadata(secret = true) - private String accessKey; + private @Nullable String accessKey; @Metadata(secret = true) - private String secretKey; + private @Nullable String secretKey; @Metadata - private String region; + private @Nullable String region; @Metadata private boolean defaultCredentialsProvider; @Metadata private boolean profileCredentialsProvider; @Metadata - private String profileName; + private @Nullable String profileName; @Metadata private boolean refreshEnabled; @Metadata(defaultValue = "30000") private long refreshPeriod = 30000; @Metadata - private String secrets; + private @Nullable String secrets; @Metadata private boolean useSqsNotification; @Metadata - private String sqsQueueUrl; + private @Nullable String sqsQueueUrl; @Metadata private boolean overrideEndpoint; @Metadata - private String uriEndpointOverride; + private @Nullable String uriEndpointOverride; - public String getAccessKey() { + public @Nullable String getAccessKey() { return accessKey; } /** * The AWS access key */ - public void setAccessKey(String accessKey) { + public void setAccessKey(@Nullable String accessKey) { this.accessKey = accessKey; } - public String getSecretKey() { + public @Nullable String getSecretKey() { return secretKey; } /** * The AWS secret key */ - public void setSecretKey(String secretKey) { + public void setSecretKey(@Nullable String secretKey) { this.secretKey = secretKey; } - public String getRegion() { + public @Nullable String getRegion() { return region; } /** * The AWS region */ - public void setRegion(String region) { + public void setRegion(@Nullable String region) { this.region = region; } @@ -105,14 +106,14 @@ public void setProfileCredentialsProvider(boolean profileCredentialsProvider) { this.profileCredentialsProvider = profileCredentialsProvider; } - public String getProfileName() { + public @Nullable String getProfileName() { return profileName; } /** * Define the profile name to use if Profile Credentials Provider is selected */ - public void setProfileName(String profileName) { + public void setProfileName(@Nullable String profileName) { this.profileName = profileName; } @@ -138,14 +139,14 @@ public void setRefreshPeriod(long refreshPeriod) { this.refreshPeriod = refreshPeriod; } - public String getSecrets() { + public @Nullable String getSecrets() { return secrets; } /** * Specify the secret names (or pattern) to check for updates. Multiple secrets can be separated by comma. */ - public void setSecrets(String secrets) { + public void setSecrets(@Nullable String secrets) { this.secrets = secrets; } @@ -161,14 +162,14 @@ public void setUseSqsNotification(boolean useSqsNotification) { this.useSqsNotification = useSqsNotification; } - public String getSqsQueueUrl() { + public @Nullable String getSqsQueueUrl() { return sqsQueueUrl; } /** * In case of usage of SQS notification this field will specified the Queue URL to use */ - public void setSqsQueueUrl(String sqsQueueUrl) { + public void setSqsQueueUrl(@Nullable String sqsQueueUrl) { this.sqsQueueUrl = sqsQueueUrl; } @@ -184,14 +185,14 @@ public void setOverrideEndpoint(boolean overrideEndpoint) { this.overrideEndpoint = overrideEndpoint; } - public String getUriEndpointOverride() { + public @Nullable String getUriEndpointOverride() { return uriEndpointOverride; } /** * Set the overriding uri endpoint. This option needs to be used in combination with overrideEndpoint option */ - public void setUriEndpointOverride(String uriEndpointOverride) { + public void setUriEndpointOverride(@Nullable String uriEndpointOverride) { this.uriEndpointOverride = uriEndpointOverride; } } diff --git a/core/camel-api/src/main/java/org/apache/camel/vault/AzureVaultConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/vault/AzureVaultConfiguration.java index 64e708781549c..c4917c2c8cf5f 100644 --- a/core/camel-api/src/main/java/org/apache/camel/vault/AzureVaultConfiguration.java +++ b/core/camel-api/src/main/java/org/apache/camel/vault/AzureVaultConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.vault; import org.apache.camel.spi.Metadata; +import org.jspecify.annotations.Nullable; /** * Configuration for access to Azure Key Vault. @@ -24,13 +25,13 @@ public class AzureVaultConfiguration extends VaultConfiguration { @Metadata - private String vaultName; + private @Nullable String vaultName; @Metadata(secret = true) - private String clientId; + private @Nullable String clientId; @Metadata(secret = true) - private String clientSecret; + private @Nullable String clientSecret; @Metadata(secret = true) - private String tenantId; + private @Nullable String tenantId; @Metadata private boolean azureIdentityEnabled; @Metadata @@ -38,57 +39,57 @@ public class AzureVaultConfiguration extends VaultConfiguration { @Metadata(defaultValue = "30000") private long refreshPeriod = 30000; @Metadata - private String secrets; + private @Nullable String secrets; @Metadata(secret = true) - private String eventhubConnectionString; + private @Nullable String eventhubConnectionString; @Metadata(secret = true) - private String blobAccessKey; + private @Nullable String blobAccessKey; @Metadata - private String blobAccountName; + private @Nullable String blobAccountName; @Metadata - private String blobContainerName; + private @Nullable String blobContainerName; - public String getVaultName() { + public @Nullable String getVaultName() { return vaultName; } /** * The vault Name in Azure Key Vault */ - public void setVaultName(String vaultName) { + public void setVaultName(@Nullable String vaultName) { this.vaultName = vaultName; } - public String getClientId() { + public @Nullable String getClientId() { return clientId; } /** * The client Id for accessing Azure Key Vault */ - public void setClientId(String clientId) { + public void setClientId(@Nullable String clientId) { this.clientId = clientId; } - public String getClientSecret() { + public @Nullable String getClientSecret() { return clientSecret; } /** * The client Secret for accessing Azure Key Vault */ - public void setClientSecret(String clientSecret) { + public void setClientSecret(@Nullable String clientSecret) { this.clientSecret = clientSecret; } - public String getTenantId() { + public @Nullable String getTenantId() { return tenantId; } /** * The Tenant Id for accessing Azure Key Vault */ - public void setTenantId(String tenantId) { + public void setTenantId(@Nullable String tenantId) { this.tenantId = tenantId; } @@ -125,58 +126,58 @@ public void setRefreshPeriod(long refreshPeriod) { this.refreshPeriod = refreshPeriod; } - public String getSecrets() { + public @Nullable String getSecrets() { return secrets; } /** * Specify the secret names (or pattern) to check for updates. Multiple secrets can be separated by comma. */ - public void setSecrets(String secrets) { + public void setSecrets(@Nullable String secrets) { this.secrets = secrets; } - public String getEventhubConnectionString() { + public @Nullable String getEventhubConnectionString() { return eventhubConnectionString; } /** * The Eventhubs connection String for Key Vault Secret events notifications */ - public void setEventhubConnectionString(String eventhubConnectionString) { + public void setEventhubConnectionString(@Nullable String eventhubConnectionString) { this.eventhubConnectionString = eventhubConnectionString; } - public String getBlobAccessKey() { + public @Nullable String getBlobAccessKey() { return blobAccessKey; } /** * The Eventhubs Blob Access Key for CheckpointStore purpose */ - public void setBlobAccessKey(String blobAccessKey) { + public void setBlobAccessKey(@Nullable String blobAccessKey) { this.blobAccessKey = blobAccessKey; } - public String getBlobAccountName() { + public @Nullable String getBlobAccountName() { return blobAccountName; } /** * The Eventhubs Blob Account Name for CheckpointStore purpose */ - public void setBlobAccountName(String blobAccountName) { + public void setBlobAccountName(@Nullable String blobAccountName) { this.blobAccountName = blobAccountName; } - public String getBlobContainerName() { + public @Nullable String getBlobContainerName() { return blobContainerName; } /** * The Eventhubs Blob Container Name for CheckpointStore purpose */ - public void setBlobContainerName(String blobContainerName) { + public void setBlobContainerName(@Nullable String blobContainerName) { this.blobContainerName = blobContainerName; } } diff --git a/core/camel-api/src/main/java/org/apache/camel/vault/CyberArkVaultConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/vault/CyberArkVaultConfiguration.java index 1c67e9b346308..59b26c8285e4b 100644 --- a/core/camel-api/src/main/java/org/apache/camel/vault/CyberArkVaultConfiguration.java +++ b/core/camel-api/src/main/java/org/apache/camel/vault/CyberArkVaultConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.vault; import org.apache.camel.spi.Metadata; +import org.jspecify.annotations.Nullable; /** * Configuration for access to CyberArk Conjur Vault. @@ -24,87 +25,87 @@ public class CyberArkVaultConfiguration extends VaultConfiguration { @Metadata - private String url; + private @Nullable String url; @Metadata - private String account; + private @Nullable String account; @Metadata(secret = true) - private String username; + private @Nullable String username; @Metadata(secret = true) - private String password; + private @Nullable String password; @Metadata(secret = true) - private String apiKey; + private @Nullable String apiKey; @Metadata - private String authToken; + private @Nullable String authToken; @Metadata private boolean verifySsl = true; @Metadata - private String certificatePath; + private @Nullable String certificatePath; @Metadata - private String secrets; + private @Nullable String secrets; - public String getUrl() { + public @Nullable String getUrl() { return url; } /** * The CyberArk Conjur instance URL */ - public void setUrl(String url) { + public void setUrl(@Nullable String url) { this.url = url; } - public String getAccount() { + public @Nullable String getAccount() { return account; } /** * The CyberArk Conjur account name */ - public void setAccount(String account) { + public void setAccount(@Nullable String account) { this.account = account; } - public String getUsername() { + public @Nullable String getUsername() { return username; } /** * The username for authentication */ - public void setUsername(String username) { + public void setUsername(@Nullable String username) { this.username = username; } - public String getPassword() { + public @Nullable String getPassword() { return password; } /** * The password for authentication */ - public void setPassword(String password) { + public void setPassword(@Nullable String password) { this.password = password; } - public String getApiKey() { + public @Nullable String getApiKey() { return apiKey; } /** * The API key for authentication */ - public void setApiKey(String apiKey) { + public void setApiKey(@Nullable String apiKey) { this.apiKey = apiKey; } - public String getAuthToken() { + public @Nullable String getAuthToken() { return authToken; } /** * Pre-authenticated token to use */ - public void setAuthToken(String authToken) { + public void setAuthToken(@Nullable String authToken) { this.authToken = authToken; } @@ -119,25 +120,25 @@ public void setVerifySsl(boolean verifySsl) { this.verifySsl = verifySsl; } - public String getCertificatePath() { + public @Nullable String getCertificatePath() { return certificatePath; } /** * Path to the SSL certificate for verification */ - public void setCertificatePath(String certificatePath) { + public void setCertificatePath(@Nullable String certificatePath) { this.certificatePath = certificatePath; } - public String getSecrets() { + public @Nullable String getSecrets() { return secrets; } /** * Specify the secret names (or pattern) to check for updates. Multiple secrets can be separated by comma. */ - public void setSecrets(String secrets) { + public void setSecrets(@Nullable String secrets) { this.secrets = secrets; } } diff --git a/core/camel-api/src/main/java/org/apache/camel/vault/GcpVaultConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/vault/GcpVaultConfiguration.java index 67995c67434dd..4c0913f07c03b 100644 --- a/core/camel-api/src/main/java/org/apache/camel/vault/GcpVaultConfiguration.java +++ b/core/camel-api/src/main/java/org/apache/camel/vault/GcpVaultConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.vault; import org.apache.camel.spi.Metadata; +import org.jspecify.annotations.Nullable; /** * Configuration for access to GCP Secret Manager. @@ -24,39 +25,39 @@ public class GcpVaultConfiguration extends VaultConfiguration { @Metadata(secret = true) - private String serviceAccountKey; + private @Nullable String serviceAccountKey; @Metadata - private String projectId; + private @Nullable String projectId; @Metadata private boolean useDefaultInstance; @Metadata - private String subscriptionName; + private @Nullable String subscriptionName; @Metadata private boolean refreshEnabled; @Metadata(defaultValue = "30000") private long refreshPeriod = 30000; @Metadata - private String secrets; + private @Nullable String secrets; - public String getServiceAccountKey() { + public @Nullable String getServiceAccountKey() { return serviceAccountKey; } /** * The Service Account Key location */ - public void setServiceAccountKey(String serviceAccountKey) { + public void setServiceAccountKey(@Nullable String serviceAccountKey) { this.serviceAccountKey = serviceAccountKey; } - public String getProjectId() { + public @Nullable String getProjectId() { return projectId; } /** * The GCP Project ID */ - public void setProjectId(String projectId) { + public void setProjectId(@Nullable String projectId) { this.projectId = projectId; } @@ -71,14 +72,14 @@ public void setUseDefaultInstance(boolean useDefaultInstance) { this.useDefaultInstance = useDefaultInstance; } - public String getSubscriptionName() { + public @Nullable String getSubscriptionName() { return subscriptionName; } /** * Define the Google Pubsub subscription Name to be used when checking for updates */ - public void setSubscriptionName(String subscriptionName) { + public void setSubscriptionName(@Nullable String subscriptionName) { this.subscriptionName = subscriptionName; } @@ -104,14 +105,14 @@ public void setRefreshPeriod(long refreshPeriod) { this.refreshPeriod = refreshPeriod; } - public String getSecrets() { + public @Nullable String getSecrets() { return secrets; } /** * Specify the secret names (or pattern) to check for updates. Multiple secrets can be separated by comma. */ - public void setSecrets(String secrets) { + public void setSecrets(@Nullable String secrets) { this.secrets = secrets; } } diff --git a/core/camel-api/src/main/java/org/apache/camel/vault/HashicorpVaultConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/vault/HashicorpVaultConfiguration.java index 0d081e034a004..f42a337590fb9 100644 --- a/core/camel-api/src/main/java/org/apache/camel/vault/HashicorpVaultConfiguration.java +++ b/core/camel-api/src/main/java/org/apache/camel/vault/HashicorpVaultConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.vault; import org.apache.camel.spi.Metadata; +import org.jspecify.annotations.Nullable; /** * Configuration for access to Hashicorp Vault Secrets. @@ -24,65 +25,65 @@ public class HashicorpVaultConfiguration extends VaultConfiguration { @Metadata(secret = true) - private String token; + private @Nullable String token; @Metadata - private String host; + private @Nullable String host; @Metadata - private String port; + private @Nullable String port; @Metadata - private String scheme; + private @Nullable String scheme; @Metadata private boolean cloud; @Metadata - private String namespace; + private @Nullable String namespace; @Metadata private boolean refreshEnabled; @Metadata(defaultValue = "60000") private long refreshPeriod = 60000; @Metadata - private String secrets; + private @Nullable String secrets; - public String getToken() { + public @Nullable String getToken() { return token; } /** * Token to access hashicorp vault */ - public void setToken(String token) { + public void setToken(@Nullable String token) { this.token = token; } - public String getHost() { + public @Nullable String getHost() { return host; } /** * Host to access hashicorp vault */ - public void setHost(String host) { + public void setHost(@Nullable String host) { this.host = host; } - public String getPort() { + public @Nullable String getPort() { return port; } /** * Port to access hashicorp vault */ - public void setPort(String port) { + public void setPort(@Nullable String port) { this.port = port; } - public String getScheme() { + public @Nullable String getScheme() { return scheme; } /** * Scheme to access hashicorp vault */ - public void setScheme(String scheme) { + public void setScheme(@Nullable String scheme) { this.scheme = scheme; } @@ -97,14 +98,14 @@ public void setCloud(boolean cloud) { this.cloud = cloud; } - public String getNamespace() { + public @Nullable String getNamespace() { return namespace; } /** * If the Hashicorp Vault instance is deployed on Hashicorp Cloud, this field will determine the namespace */ - public void setNamespace(String namespace) { + public void setNamespace(@Nullable String namespace) { this.namespace = namespace; } @@ -130,14 +131,14 @@ public void setRefreshPeriod(long refreshPeriod) { this.refreshPeriod = refreshPeriod; } - public String getSecrets() { + public @Nullable String getSecrets() { return secrets; } /** * Specify the secret names (or pattern) to check for updates. Multiple secrets can be separated by comma. */ - public void setSecrets(String secrets) { + public void setSecrets(@Nullable String secrets) { this.secrets = secrets; } } diff --git a/core/camel-api/src/main/java/org/apache/camel/vault/IBMSecretsManagerVaultConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/vault/IBMSecretsManagerVaultConfiguration.java index 0a8cdcc30af5e..04231ea2821ae 100644 --- a/core/camel-api/src/main/java/org/apache/camel/vault/IBMSecretsManagerVaultConfiguration.java +++ b/core/camel-api/src/main/java/org/apache/camel/vault/IBMSecretsManagerVaultConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.vault; import org.apache.camel.spi.Metadata; +import org.jspecify.annotations.Nullable; /** * Configuration for access to IBM Secrets Manager Vault Secrets. @@ -24,45 +25,45 @@ public class IBMSecretsManagerVaultConfiguration extends VaultConfiguration { @Metadata(secret = true) - private String token; + private @Nullable String token; @Metadata - private String serviceUrl; + private @Nullable String serviceUrl; @Metadata private boolean refreshEnabled; @Metadata - private String secrets; + private @Nullable String secrets; @Metadata - private String eventStreamTopic; + private @Nullable String eventStreamTopic; @Metadata - private String eventStreamBootstrapServers; + private @Nullable String eventStreamBootstrapServers; @Metadata - private String eventStreamUsername; + private @Nullable String eventStreamUsername; @Metadata - private String eventStreamPassword; + private @Nullable String eventStreamPassword; @Metadata - private String eventStreamGroupId; + private @Nullable String eventStreamGroupId; @Metadata(defaultValue = "3000") private long eventStreamConsumerPollTimeout = 3000; - public String getToken() { + public @Nullable String getToken() { return token; } /** * Token to access IBM Secrets Manager vault */ - public void setToken(String token) { + public void setToken(@Nullable String token) { this.token = token; } - public String getServiceUrl() { + public @Nullable String getServiceUrl() { return serviceUrl; } /** * Service URL to access IBM Secrets Manager vault */ - public void setServiceUrl(String serviceUrl) { + public void setServiceUrl(@Nullable String serviceUrl) { this.serviceUrl = serviceUrl; } @@ -77,29 +78,29 @@ public void setRefreshEnabled(boolean refreshEnabled) { this.refreshEnabled = refreshEnabled; } - public String getSecrets() { + public @Nullable String getSecrets() { return secrets; } /** * Specify the secret names (or pattern) to check for updates. Multiple secrets can be separated by comma. */ - public void setSecrets(String secrets) { + public void setSecrets(@Nullable String secrets) { this.secrets = secrets; } - public String getEventStreamTopic() { + public @Nullable String getEventStreamTopic() { return eventStreamTopic; } /** * Specify the topic name for consuming notification on IBM Event Stream */ - public void setEventStreamTopic(String eventStreamTopic) { + public void setEventStreamTopic(@Nullable String eventStreamTopic) { this.eventStreamTopic = eventStreamTopic; } - public String getEventStreamBootstrapServers() { + public @Nullable String getEventStreamBootstrapServers() { return eventStreamBootstrapServers; } @@ -107,40 +108,40 @@ public String getEventStreamBootstrapServers() { * Specify the Bootstrap servers for consuming notification on IBM Event Stream. Multiple servers can be separated * by comma. */ - public void setEventStreamBootstrapServers(String eventStreamBootstrapServers) { + public void setEventStreamBootstrapServers(@Nullable String eventStreamBootstrapServers) { this.eventStreamBootstrapServers = eventStreamBootstrapServers; } - public String getEventStreamUsername() { + public @Nullable String getEventStreamUsername() { return eventStreamUsername; } /** * Specify the username to access IBM Event Stream */ - public void setEventStreamUsername(String eventStreamUsername) { + public void setEventStreamUsername(@Nullable String eventStreamUsername) { this.eventStreamUsername = eventStreamUsername; } - public String getEventStreamPassword() { + public @Nullable String getEventStreamPassword() { return eventStreamPassword; } /** * Specify the password to access IBM Event Stream */ - public void setEventStreamPassword(String eventStreamPassword) { + public void setEventStreamPassword(@Nullable String eventStreamPassword) { this.eventStreamPassword = eventStreamPassword; } - public String getEventStreamGroupId() { + public @Nullable String getEventStreamGroupId() { return eventStreamGroupId; } /** * Specify the Consumer Group ID to access IBM Event Stream */ - public void setEventStreamGroupId(String eventStreamGroupId) { + public void setEventStreamGroupId(@Nullable String eventStreamGroupId) { this.eventStreamGroupId = eventStreamGroupId; } diff --git a/core/camel-api/src/main/java/org/apache/camel/vault/KubernetesConfigMapVaultConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/vault/KubernetesConfigMapVaultConfiguration.java index fb89a7418f477..1981675eb1092 100644 --- a/core/camel-api/src/main/java/org/apache/camel/vault/KubernetesConfigMapVaultConfiguration.java +++ b/core/camel-api/src/main/java/org/apache/camel/vault/KubernetesConfigMapVaultConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.vault; import org.apache.camel.spi.Metadata; +import org.jspecify.annotations.Nullable; /** * Configuration for access to Kubernetes Confimaps @@ -26,7 +27,7 @@ public class KubernetesConfigMapVaultConfiguration extends VaultConfiguration { @Metadata private boolean refreshEnabled; @Metadata - private String configmaps; + private @Nullable String configmaps; public boolean isRefreshEnabled() { return refreshEnabled; @@ -39,14 +40,14 @@ public void setRefreshEnabled(boolean refreshEnabled) { this.refreshEnabled = refreshEnabled; } - public String getConfigmaps() { + public @Nullable String getConfigmaps() { return configmaps; } /** * Specify the configmap names (or pattern) to check for updates. Multiple configmaps can be separated by comma. */ - public void setConfigmaps(String configmaps) { + public void setConfigmaps(@Nullable String configmaps) { this.configmaps = configmaps; } } diff --git a/core/camel-api/src/main/java/org/apache/camel/vault/KubernetesVaultConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/vault/KubernetesVaultConfiguration.java index 2183f8d5769bd..dc98c9c62de85 100644 --- a/core/camel-api/src/main/java/org/apache/camel/vault/KubernetesVaultConfiguration.java +++ b/core/camel-api/src/main/java/org/apache/camel/vault/KubernetesVaultConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.vault; import org.apache.camel.spi.Metadata; +import org.jspecify.annotations.Nullable; /** * Configuration for access to Kubernetes Secrets @@ -26,7 +27,7 @@ public class KubernetesVaultConfiguration extends VaultConfiguration { @Metadata private boolean refreshEnabled; @Metadata - private String secrets; + private @Nullable String secrets; public boolean isRefreshEnabled() { return refreshEnabled; @@ -39,14 +40,14 @@ public void setRefreshEnabled(boolean refreshEnabled) { this.refreshEnabled = refreshEnabled; } - public String getSecrets() { + public @Nullable String getSecrets() { return secrets; } /** * Specify the secret names (or pattern) to check for updates. Multiple secrets can be separated by comma. */ - public void setSecrets(String secrets) { + public void setSecrets(@Nullable String secrets) { this.secrets = secrets; } } diff --git a/core/camel-api/src/main/java/org/apache/camel/vault/SpringCloudConfigConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/vault/SpringCloudConfigConfiguration.java index 770aa6dddb12f..e045eb414396a 100644 --- a/core/camel-api/src/main/java/org/apache/camel/vault/SpringCloudConfigConfiguration.java +++ b/core/camel-api/src/main/java/org/apache/camel/vault/SpringCloudConfigConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.vault; import org.apache.camel.spi.Metadata; +import org.jspecify.annotations.Nullable; /** * Configuration for Spring Cloud Config @@ -24,30 +25,30 @@ public class SpringCloudConfigConfiguration extends VaultConfiguration { @Metadata(secret = true) - private String password; + private @Nullable String password; @Metadata(secret = true, defaultValue = "user") private String username = "user"; @Metadata(secret = true) - private String token; + private @Nullable String token; @Metadata(defaultValue = "http://localhost:8888", description = "Comma separated list of Spring Config Server URIs") private String uris = "http://localhost:8888"; @Metadata - private String label; + private @Nullable String label; @Metadata - private String profile; + private @Nullable String profile; @Metadata private boolean refreshEnabled; @Metadata(defaultValue = "30000") private long refreshPeriod = 30000; - public String getPassword() { + public @Nullable String getPassword() { return password; } /** * Password for Spring Config Server */ - public void setPassword(String password) { + public void setPassword(@Nullable String password) { this.password = password; } @@ -95,36 +96,36 @@ public void setRefreshPeriod(long refreshPeriod) { this.refreshPeriod = refreshPeriod; } - public String getToken() { + public @Nullable String getToken() { return token; } /** * Authentication token for the Config Server */ - public void setToken(String token) { + public void setToken(@Nullable String token) { this.token = token; } - public String getLabel() { + public @Nullable String getLabel() { return label; } /** * Config Server label to use (e.g., git branch) */ - public void setLabel(String label) { + public void setLabel(@Nullable String label) { this.label = label; } - public String getProfile() { + public @Nullable String getProfile() { return profile; } /** * Configuration profile to use */ - public void setProfile(String profile) { + public void setProfile(@Nullable String profile) { this.profile = profile; } } diff --git a/core/camel-api/src/main/java/org/apache/camel/vault/VaultConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/vault/VaultConfiguration.java index 24c0dc4909648..abe14bc8ea761 100644 --- a/core/camel-api/src/main/java/org/apache/camel/vault/VaultConfiguration.java +++ b/core/camel-api/src/main/java/org/apache/camel/vault/VaultConfiguration.java @@ -16,20 +16,22 @@ */ package org.apache.camel.vault; +import org.jspecify.annotations.Nullable; + /** * Base configuration for access to Vaults. */ public class VaultConfiguration { - private AwsVaultConfiguration aws; - private GcpVaultConfiguration gcp; - private AzureVaultConfiguration azure; - private HashicorpVaultConfiguration hashicorp; - private KubernetesVaultConfiguration kubernetes; - private KubernetesConfigMapVaultConfiguration kubernetesConfigmaps; - private IBMSecretsManagerVaultConfiguration ibmSecretsManager; - private SpringCloudConfigConfiguration springConfig; - private CyberArkVaultConfiguration cyberark; + private @Nullable AwsVaultConfiguration aws; + private @Nullable GcpVaultConfiguration gcp; + private @Nullable AzureVaultConfiguration azure; + private @Nullable HashicorpVaultConfiguration hashicorp; + private @Nullable KubernetesVaultConfiguration kubernetes; + private @Nullable KubernetesConfigMapVaultConfiguration kubernetesConfigmaps; + private @Nullable IBMSecretsManagerVaultConfiguration ibmSecretsManager; + private @Nullable SpringCloudConfigConfiguration springConfig; + private @Nullable CyberArkVaultConfiguration cyberark; /** * AWS Vault Configuration @@ -118,75 +120,75 @@ public CyberArkVaultConfiguration cyberark() { return cyberark; } - public AwsVaultConfiguration getAwsVaultConfiguration() { + public @Nullable AwsVaultConfiguration getAwsVaultConfiguration() { return aws; } - public void setAwsVaultConfiguration(AwsVaultConfiguration aws) { + public void setAwsVaultConfiguration(@Nullable AwsVaultConfiguration aws) { this.aws = aws; } - public GcpVaultConfiguration getGcpVaultConfiguration() { + public @Nullable GcpVaultConfiguration getGcpVaultConfiguration() { return gcp; } - public void setGcpVaultConfiguration(GcpVaultConfiguration gcp) { + public void setGcpVaultConfiguration(@Nullable GcpVaultConfiguration gcp) { this.gcp = gcp; } - public AzureVaultConfiguration getAzureVaultConfiguration() { + public @Nullable AzureVaultConfiguration getAzureVaultConfiguration() { return azure; } - public void setAzureVaultConfiguration(AzureVaultConfiguration azure) { + public void setAzureVaultConfiguration(@Nullable AzureVaultConfiguration azure) { this.azure = azure; } - public HashicorpVaultConfiguration getHashicorpVaultConfiguration() { + public @Nullable HashicorpVaultConfiguration getHashicorpVaultConfiguration() { return hashicorp; } - public void setHashicorpVaultConfiguration(HashicorpVaultConfiguration hashicorp) { + public void setHashicorpVaultConfiguration(@Nullable HashicorpVaultConfiguration hashicorp) { this.hashicorp = hashicorp; } - public KubernetesVaultConfiguration getKubernetesVaultConfiguration() { + public @Nullable KubernetesVaultConfiguration getKubernetesVaultConfiguration() { return kubernetes; } - public void setKubernetesVaultConfiguration(KubernetesVaultConfiguration kubernetes) { + public void setKubernetesVaultConfiguration(@Nullable KubernetesVaultConfiguration kubernetes) { this.kubernetes = kubernetes; } - public KubernetesConfigMapVaultConfiguration getKubernetesConfigMapVaultConfiguration() { + public @Nullable KubernetesConfigMapVaultConfiguration getKubernetesConfigMapVaultConfiguration() { return kubernetesConfigmaps; } - public void setKubernetesConfigMapVaultConfiguration(KubernetesConfigMapVaultConfiguration kubernetesConfigmaps) { + public void setKubernetesConfigMapVaultConfiguration(@Nullable KubernetesConfigMapVaultConfiguration kubernetesConfigmaps) { this.kubernetesConfigmaps = kubernetesConfigmaps; } - public IBMSecretsManagerVaultConfiguration getIBMSecretsManagerVaultConfiguration() { + public @Nullable IBMSecretsManagerVaultConfiguration getIBMSecretsManagerVaultConfiguration() { return ibmSecretsManager; } - public void setIBMSecretsManagerVaultConfiguration(IBMSecretsManagerVaultConfiguration ibmSecretsManager) { + public void setIBMSecretsManagerVaultConfiguration(@Nullable IBMSecretsManagerVaultConfiguration ibmSecretsManager) { this.ibmSecretsManager = ibmSecretsManager; } - public SpringCloudConfigConfiguration getSpringCloudConfigConfiguration() { + public @Nullable SpringCloudConfigConfiguration getSpringCloudConfigConfiguration() { return springConfig; } - public void setSpringCloudConfigConfiguration(SpringCloudConfigConfiguration springCloudConfigConfiguration) { + public void setSpringCloudConfigConfiguration(@Nullable SpringCloudConfigConfiguration springCloudConfigConfiguration) { this.springConfig = springCloudConfigConfiguration; } - public CyberArkVaultConfiguration getCyberArkVaultConfiguration() { + public @Nullable CyberArkVaultConfiguration getCyberArkVaultConfiguration() { return cyberark; } - public void setCyberArkVaultConfiguration(CyberArkVaultConfiguration cyberark) { + public void setCyberArkVaultConfiguration(@Nullable CyberArkVaultConfiguration cyberark) { this.cyberark = cyberark; } } diff --git a/core/camel-api/src/main/java/org/apache/camel/vault/package-info.java b/core/camel-api/src/main/java/org/apache/camel/vault/package-info.java new file mode 100644 index 0000000000000..03908cb00e41e --- /dev/null +++ b/core/camel-api/src/main/java/org/apache/camel/vault/package-info.java @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NullMarked +package org.apache.camel.vault; + +import org.jspecify.annotations.NullMarked; diff --git a/parent/pom.xml b/parent/pom.xml index ba5820c3fa1d6..f4f29331606ad 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -351,6 +351,7 @@ 0.9.9 5.1.1 1.22.1 + 1.0.0 21.0.6 3.2.3 2.4 @@ -3253,6 +3254,13 @@ test-jar + + + org.jspecify + jspecify + ${jspecify-version} + + org.slf4j From 10aa993097dd43fa9545c15db456f968af8bff55 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 30 Mar 2026 07:53:58 +0200 Subject: [PATCH 2/3] CAMEL-22640: Thorough implementation-verified @Nullable audit Scan actual implementations (not just Javadoc) for return null, null field values, and caller null-checks. Adds missing @Nullable annotations and moves @NullMarked to package-level only. Key additions found by implementation scanning: - Exchange.getPattern() can be null (field uninitialized) - Message.getExchange() can be null (field starts null) - Route.getOnException/navigate() can return null - DelegateProcessor.getProcessor() can be null (LazyStartProducer) - Various transient exception fields nullable after deserialization - ConsumerTemplate.receiveBody() without timeout can return null - CamelContext.getComponent() overloads can return null - ExtendedCamelContext.getErrorHandlerFactory() can be null - Multiple SPI methods found nullable through impl analysis Co-Authored-By: Claude Opus 4.6 --- .../main/java/org/apache/camel/CamelContext.java | 9 ++++++--- .../java/org/apache/camel/ConsumerTemplate.java | 14 ++++++++------ .../java/org/apache/camel/DelegateProcessor.java | 5 ++++- .../apache/camel/ExpectedBodyTypeException.java | 10 ++++++---- .../camel/ExpressionEvaluationException.java | 16 ++++++++++------ .../org/apache/camel/ExtendedCamelContext.java | 1 + .../apache/camel/InvalidPayloadException.java | 6 ++++-- .../camel/InvalidPayloadRuntimeException.java | 6 ++++-- .../src/main/java/org/apache/camel/Message.java | 1 + .../src/main/java/org/apache/camel/Route.java | 2 ++ .../java/org/apache/camel/StaticExpression.java | 5 ++++- .../org/apache/camel/ValidationException.java | 6 ++++-- .../main/java/org/apache/camel/ValueHolder.java | 4 +++- .../main/java/org/apache/camel/WrappedFile.java | 4 ++++ .../org/apache/camel/spi/BacklogDebugger.java | 2 ++ .../org/apache/camel/spi/BrowsableEndpoint.java | 3 ++- .../java/org/apache/camel/spi/CamelLogger.java | 2 +- .../org/apache/camel/spi/CompileStrategy.java | 3 +++ .../java/org/apache/camel/spi/ConsumerCache.java | 1 + .../main/java/org/apache/camel/spi/Contract.java | 8 ++++---- .../main/java/org/apache/camel/spi/DataType.java | 12 ++++++------ .../camel/spi/EndpointServiceRegistry.java | 1 + .../org/apache/camel/spi/ErrorHandlerAware.java | 2 ++ .../org/apache/camel/spi/ErrorRegistryEntry.java | 1 + .../org/apache/camel/spi/ExceptionHandler.java | 5 +++-- .../org/apache/camel/spi/ExchangeFactory.java | 2 ++ .../org/apache/camel/spi/NamespaceAware.java | 3 +++ .../apache/camel/spi/OnCamelContextEvent.java | 5 ++--- .../org/apache/camel/spi/ScriptingLanguage.java | 2 +- .../camel/spi/SharedInternalProcessor.java | 7 +++++-- .../apache/camel/spi/StreamCachingStrategy.java | 2 ++ .../org/apache/camel/spi/TypeConvertible.java | 10 +++++++--- .../java/org/apache/camel/spi/UnitOfWork.java | 3 ++- .../support/jsse/BaseSSLContextParameters.java | 14 +++++++------- .../support/jsse/TrustManagersParameters.java | 2 +- 35 files changed, 119 insertions(+), 60 deletions(-) diff --git a/core/camel-api/src/main/java/org/apache/camel/CamelContext.java b/core/camel-api/src/main/java/org/apache/camel/CamelContext.java index 203b7480e9f37..9cfb6faada731 100644 --- a/core/camel-api/src/main/java/org/apache/camel/CamelContext.java +++ b/core/camel-api/src/main/java/org/apache/camel/CamelContext.java @@ -357,8 +357,9 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio * {@link #getComponent(String, boolean, boolean)}. * * @param componentName the name of the component - * @return the component + * @return the component, or null if not found and could not be auto created */ + @Nullable Component getComponent(String componentName); /** @@ -369,8 +370,9 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio * * @param name the name of the component * @param autoCreateComponents whether or not the component should be lazily created if it does not already exist - * @return the component + * @return the component, or null if not found */ + @Nullable Component getComponent(String name, boolean autoCreateComponents); /** @@ -379,8 +381,9 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio * @param name the name of the component * @param autoCreateComponents whether or not the component should be lazily created if it does not already exist * @param autoStart whether to auto start the component if {@link CamelContext} is already started. - * @return the component + * @return the component, or null if not found */ + @Nullable Component getComponent(String name, boolean autoCreateComponents, boolean autoStart); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/ConsumerTemplate.java b/core/camel-api/src/main/java/org/apache/camel/ConsumerTemplate.java index 1900c8610fcb2..3bfcfd6fe7c5c 100644 --- a/core/camel-api/src/main/java/org/apache/camel/ConsumerTemplate.java +++ b/core/camel-api/src/main/java/org/apache/camel/ConsumerTemplate.java @@ -156,16 +156,18 @@ public interface ConsumerTemplate extends Service { * Receives from the endpoint, waiting until there is a response * * @param endpointUri the endpoint to receive from - * @return the returned response body + * @return the returned response body, or null if no body */ + @Nullable Object receiveBody(String endpointUri); /** * Receives from the endpoint, waiting until there is a response * * @param endpoint the endpoint to receive from - * @return the returned response body + * @return the returned response body, or null if no body */ + @Nullable Object receiveBody(Endpoint endpoint); /** @@ -211,18 +213,18 @@ public interface ConsumerTemplate extends Service { * * @param endpointUri the endpoint to receive from * @param type the expected response type - * @return the returned response body + * @return the returned response body, or null if no body */ - T receiveBody(String endpointUri, Class type); + @Nullable T receiveBody(String endpointUri, Class type); /** * Receives from the endpoint, waiting until there is a response * * @param endpoint the endpoint to receive from * @param type the expected response type - * @return the returned response body + * @return the returned response body, or null if no body */ - T receiveBody(Endpoint endpoint, Class type); + @Nullable T receiveBody(Endpoint endpoint, Class type); /** * Receives from the endpoint, waiting until there is a response or the timeout occurs diff --git a/core/camel-api/src/main/java/org/apache/camel/DelegateProcessor.java b/core/camel-api/src/main/java/org/apache/camel/DelegateProcessor.java index e8da508fc21ab..574107e139c00 100644 --- a/core/camel-api/src/main/java/org/apache/camel/DelegateProcessor.java +++ b/core/camel-api/src/main/java/org/apache/camel/DelegateProcessor.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * Interface to be used for processors that delegate to the real processor */ @@ -24,7 +26,8 @@ public interface DelegateProcessor extends Processor { /** * Gets the delegated {@link Processor}. * - * @return the processor we delegate to + * @return the processor we delegate to, or null if the delegate has not been initialized yet */ + @Nullable Processor getProcessor(); } diff --git a/core/camel-api/src/main/java/org/apache/camel/ExpectedBodyTypeException.java b/core/camel-api/src/main/java/org/apache/camel/ExpectedBodyTypeException.java index ea5385db6f8e3..5646f186706a9 100644 --- a/core/camel-api/src/main/java/org/apache/camel/ExpectedBodyTypeException.java +++ b/core/camel-api/src/main/java/org/apache/camel/ExpectedBodyTypeException.java @@ -16,13 +16,15 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * Thrown if the body could not be converted to the required type */ public class ExpectedBodyTypeException extends RuntimeCamelException { - private final transient Exchange exchange; - private final transient Class expectedBodyType; + private final transient @Nullable Exchange exchange; + private final transient @Nullable Class expectedBodyType; public ExpectedBodyTypeException(Exchange exchange, Class expectedBodyType) { super("Could not extract IN message body as type: " + expectedBodyType + " body is: " @@ -31,11 +33,11 @@ public ExpectedBodyTypeException(Exchange exchange, Class expectedBodyType) { this.expectedBodyType = expectedBodyType; } - public Exchange getExchange() { + public @Nullable Exchange getExchange() { return exchange; } - public Class getExpectedBodyType() { + public @Nullable Class getExpectedBodyType() { return expectedBodyType; } } diff --git a/core/camel-api/src/main/java/org/apache/camel/ExpressionEvaluationException.java b/core/camel-api/src/main/java/org/apache/camel/ExpressionEvaluationException.java index 6854ae7f9ad04..a265882103c4a 100644 --- a/core/camel-api/src/main/java/org/apache/camel/ExpressionEvaluationException.java +++ b/core/camel-api/src/main/java/org/apache/camel/ExpressionEvaluationException.java @@ -16,31 +16,35 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * An exception thrown if evaluation of the expression failed. */ public class ExpressionEvaluationException extends RuntimeCamelException { - private final transient Expression expression; - private final transient Exchange exchange; + private final transient @Nullable Expression expression; + private final transient @Nullable Exchange exchange; - public ExpressionEvaluationException(Expression expression, Exchange exchange, Throwable cause) { + public ExpressionEvaluationException( + @Nullable Expression expression, Exchange exchange, @Nullable Throwable cause) { super(cause); this.expression = expression; this.exchange = exchange; } - public ExpressionEvaluationException(Expression expression, String message, Exchange exchange, Throwable cause) { + public ExpressionEvaluationException( + Expression expression, String message, Exchange exchange, @Nullable Throwable cause) { super(message, cause); this.expression = expression; this.exchange = exchange; } - public Expression getExpression() { + public @Nullable Expression getExpression() { return expression; } - public Exchange getExchange() { + public @Nullable Exchange getExchange() { return exchange; } } diff --git a/core/camel-api/src/main/java/org/apache/camel/ExtendedCamelContext.java b/core/camel-api/src/main/java/org/apache/camel/ExtendedCamelContext.java index 7c5ea9f55671b..55f831b2ea700 100644 --- a/core/camel-api/src/main/java/org/apache/camel/ExtendedCamelContext.java +++ b/core/camel-api/src/main/java/org/apache/camel/ExtendedCamelContext.java @@ -437,6 +437,7 @@ default T createProcessor(String processorId, Callable callable) throws E * * @return the builder */ + @Nullable ErrorHandlerFactory getErrorHandlerFactory(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/InvalidPayloadException.java b/core/camel-api/src/main/java/org/apache/camel/InvalidPayloadException.java index 127fc15313e58..020a7916bc395 100644 --- a/core/camel-api/src/main/java/org/apache/camel/InvalidPayloadException.java +++ b/core/camel-api/src/main/java/org/apache/camel/InvalidPayloadException.java @@ -16,12 +16,14 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * Is thrown if the payload from the exchange could not be retrieved because of being null, wrong class type etc. */ public class InvalidPayloadException extends CamelExchangeException { - private final transient Class type; + private final transient @Nullable Class type; public InvalidPayloadException(Exchange exchange, Class type) { this(exchange, type, exchange.getIn()); @@ -43,7 +45,7 @@ public InvalidPayloadException(Exchange exchange, Class type, Message message /** * The expected type of the body */ - public Class getType() { + public @Nullable Class getType() { return type; } } diff --git a/core/camel-api/src/main/java/org/apache/camel/InvalidPayloadRuntimeException.java b/core/camel-api/src/main/java/org/apache/camel/InvalidPayloadRuntimeException.java index fca39bb705954..de7a57a938d62 100644 --- a/core/camel-api/src/main/java/org/apache/camel/InvalidPayloadRuntimeException.java +++ b/core/camel-api/src/main/java/org/apache/camel/InvalidPayloadRuntimeException.java @@ -16,12 +16,14 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * Runtime version of the {@link InvalidPayloadException}. */ public class InvalidPayloadRuntimeException extends RuntimeExchangeException { - private final transient Class type; + private final transient @Nullable Class type; public InvalidPayloadRuntimeException(Exchange exchange, Class type) { this(exchange, type, exchange.getIn()); @@ -47,7 +49,7 @@ public InvalidPayloadRuntimeException(Exchange exchange, Class type, Message /** * The expected type of the body */ - public Class getType() { + public @Nullable Class getType() { return type; } } diff --git a/core/camel-api/src/main/java/org/apache/camel/Message.java b/core/camel-api/src/main/java/org/apache/camel/Message.java index 687e2fc4923bb..747915cd20779 100644 --- a/core/camel-api/src/main/java/org/apache/camel/Message.java +++ b/core/camel-api/src/main/java/org/apache/camel/Message.java @@ -91,6 +91,7 @@ public interface Message { * * @return the exchange */ + @Nullable Exchange getExchange(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/Route.java b/core/camel-api/src/main/java/org/apache/camel/Route.java index 9c404330993fd..d25f2c51152d2 100644 --- a/core/camel-api/src/main/java/org/apache/camel/Route.java +++ b/core/camel-api/src/main/java/org/apache/camel/Route.java @@ -243,6 +243,7 @@ public interface Route extends RuntimeConfiguration { * * @return a navigator for {@link Processor}. */ + @Nullable Navigate navigate(); /** @@ -413,6 +414,7 @@ public interface Route extends RuntimeConfiguration { Collection getOnExceptions(); // called at runtime + @Nullable Processor getOnException(String onExceptionId); // called at completion time diff --git a/core/camel-api/src/main/java/org/apache/camel/StaticExpression.java b/core/camel-api/src/main/java/org/apache/camel/StaticExpression.java index 5fd2a0f9298cd..6f9e824d21296 100644 --- a/core/camel-api/src/main/java/org/apache/camel/StaticExpression.java +++ b/core/camel-api/src/main/java/org/apache/camel/StaticExpression.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * Marked if the {@link Expression} or {@link Predicate} is based from a constant value (ie is static). */ @@ -24,11 +26,12 @@ public interface StaticExpression extends Expression { /** * Gets the constant value */ + @Nullable Object getValue(); /** * Sets the constant value */ - void setValue(Object value); + void setValue(@Nullable Object value); } diff --git a/core/camel-api/src/main/java/org/apache/camel/ValidationException.java b/core/camel-api/src/main/java/org/apache/camel/ValidationException.java index 7d90af3cde836..2494327a890c5 100644 --- a/core/camel-api/src/main/java/org/apache/camel/ValidationException.java +++ b/core/camel-api/src/main/java/org/apache/camel/ValidationException.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * The base class for any validation exception, such as * {@link org.apache.camel.support.processor.validation.SchemaValidationException} so that it is easy to treat all @@ -23,11 +25,11 @@ */ public class ValidationException extends CamelExchangeException { - public ValidationException(Exchange exchange, String message) { + public ValidationException(@Nullable Exchange exchange, String message) { super(message, exchange); } - public ValidationException(String message, Exchange exchange, Throwable cause) { + public ValidationException(String message, @Nullable Exchange exchange, Throwable cause) { super(message, exchange, cause); } } diff --git a/core/camel-api/src/main/java/org/apache/camel/ValueHolder.java b/core/camel-api/src/main/java/org/apache/camel/ValueHolder.java index 6cd429fdaff4a..36518e73cdc86 100644 --- a/core/camel-api/src/main/java/org/apache/camel/ValueHolder.java +++ b/core/camel-api/src/main/java/org/apache/camel/ValueHolder.java @@ -18,6 +18,8 @@ import java.util.Objects; +import org.jspecify.annotations.Nullable; + /** * Holder object for a given value. */ @@ -33,7 +35,7 @@ public V get() { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/camel-api/src/main/java/org/apache/camel/WrappedFile.java b/core/camel-api/src/main/java/org/apache/camel/WrappedFile.java index c2916fc85c946..71d418fb7d13b 100644 --- a/core/camel-api/src/main/java/org/apache/camel/WrappedFile.java +++ b/core/camel-api/src/main/java/org/apache/camel/WrappedFile.java @@ -16,6 +16,8 @@ */ package org.apache.camel; +import org.jspecify.annotations.Nullable; + /** * Wraps a file. */ @@ -26,6 +28,7 @@ public interface WrappedFile { * * @return the file. */ + @Nullable T getFile(); /** @@ -33,6 +36,7 @@ public interface WrappedFile { * * @return the content of the file. */ + @Nullable Object getBody(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/BacklogDebugger.java b/core/camel-api/src/main/java/org/apache/camel/spi/BacklogDebugger.java index f28b6fcdaf4b7..0caee48e19b11 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/BacklogDebugger.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/BacklogDebugger.java @@ -62,6 +62,7 @@ public interface BacklogDebugger extends StatefulService { * comma. Use special value _all_routes_ to add a breakpoint for the first node for every route, in other words this * makes it easy to debug from the beginning of every route without knowing the exact node ids. */ + @Nullable String getInitialBreakpoints(); /** @@ -436,6 +437,7 @@ void setExchangeVariableOnBreakpoint(String nodeId, String variableName, Object /** * Callback invoked before hitting a breakpoint */ + @Nullable StopWatch beforeProcess(Exchange exchange, Processor processor, NamedNode definition); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/BrowsableEndpoint.java b/core/camel-api/src/main/java/org/apache/camel/spi/BrowsableEndpoint.java index 0f82d4f4b0d58..a27e427faa194 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/BrowsableEndpoint.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/BrowsableEndpoint.java @@ -22,6 +22,7 @@ import org.apache.camel.Endpoint; import org.apache.camel.Exchange; +import org.jspecify.annotations.Nullable; /** * An optional interface an {@link Endpoint} may choose to implement which allows it to expose a way of browsing the @@ -80,7 +81,7 @@ default BrowseStatus getBrowseStatus(int limit) { * @param filter filter to filter among the messages to include. * @return the exchanges on this endpoint */ - default List getExchanges(int limit, Predicate filter) { + default List getExchanges(int limit, @Nullable Predicate filter) { List answer = getExchanges(); if (filter != null) { answer = (List) answer.stream().filter(filter).collect(Collectors.toList()); diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/CamelLogger.java b/core/camel-api/src/main/java/org/apache/camel/spi/CamelLogger.java index 3595dd5754bcf..a55e32dccad4e 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/CamelLogger.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/CamelLogger.java @@ -33,7 +33,7 @@ public class CamelLogger { private Logger log; private LoggingLevel level; - private Marker marker; + private @Nullable Marker marker; public CamelLogger() { this(LoggerFactory.getLogger(CamelLogger.class)); diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/CompileStrategy.java b/core/camel-api/src/main/java/org/apache/camel/spi/CompileStrategy.java index 31111f571f3e6..fe9445adfe296 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/CompileStrategy.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/CompileStrategy.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import org.jspecify.annotations.Nullable; + /** * Strategy for runtime compiled languages and DSLs. */ @@ -24,6 +26,7 @@ public interface CompileStrategy { /** * Work directory for compiler. Can be used to write compiled classes or other resources. */ + @Nullable String getWorkDir(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ConsumerCache.java b/core/camel-api/src/main/java/org/apache/camel/spi/ConsumerCache.java index a99c29ee2d406..d639bffc0ee34 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ConsumerCache.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ConsumerCache.java @@ -124,5 +124,6 @@ public interface ConsumerCache extends Service { /** * Gets the endpoint statistics */ + @Nullable EndpointUtilizationStatistics getEndpointUtilizationStatistics(); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/Contract.java b/core/camel-api/src/main/java/org/apache/camel/spi/Contract.java index 00664e0a8e62e..dde69279a428b 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/Contract.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/Contract.java @@ -25,11 +25,11 @@ */ public class Contract { - private DataType inputType; - private DataType outputType; + private @Nullable DataType inputType; + private @Nullable DataType outputType; private boolean validateInput; private boolean validateOutput; - private String contractString; + private @Nullable String contractString; public @Nullable DataType getInputType() { return inputType; @@ -114,7 +114,7 @@ public boolean isEmpty() { } @Override - public boolean equals(Object target) { + public boolean equals(@Nullable Object target) { if (!(target instanceof Contract)) { return false; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/DataType.java b/core/camel-api/src/main/java/org/apache/camel/spi/DataType.java index 537893173ba29..6a76f393bb079 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/DataType.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/DataType.java @@ -49,11 +49,11 @@ public class DataType { public static final DataType ANY = new DataType(ANY_TYPE_URN); private final String scheme; - private String name; + private @Nullable String name; private boolean isJavaType; - private String typeString; + private @Nullable String typeString; - public DataType(String urn) { + public DataType(@Nullable String urn) { if (urn != null) { String[] split = StringHelper.splitOnCharacter(urn, ":", 2); scheme = split[0]; @@ -97,16 +97,16 @@ public String toString() { return this.typeString; } - public static boolean isAnyType(DataType dataType) { + public static boolean isAnyType(@Nullable DataType dataType) { return dataType == null || DataType.ANY.equals(dataType); } - public static boolean isJavaType(DataType dataType) { + public static boolean isJavaType(@Nullable DataType dataType) { return dataType != null && dataType.isJavaType(); } @Override - public boolean equals(Object target) { + public boolean equals(@Nullable Object target) { if (target instanceof DataType targetDt) { String targetScheme = targetDt.getScheme(); String targetName = targetDt.getName(); diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/EndpointServiceRegistry.java b/core/camel-api/src/main/java/org/apache/camel/spi/EndpointServiceRegistry.java index 3b91c96b7261f..2a276b1e41b03 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/EndpointServiceRegistry.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/EndpointServiceRegistry.java @@ -94,6 +94,7 @@ interface EndpointService { /** * The route id where this service is used as route consumer, or used in the route by a send processor. */ + @Nullable String getRouteId(); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ErrorHandlerAware.java b/core/camel-api/src/main/java/org/apache/camel/spi/ErrorHandlerAware.java index 9d7f61e97e434..cab4955315eaf 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ErrorHandlerAware.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ErrorHandlerAware.java @@ -17,6 +17,7 @@ package org.apache.camel.spi; import org.apache.camel.Processor; +import org.jspecify.annotations.Nullable; /** * An interface for {@link Processor} aware of its {@link ErrorHandler} which are wrapped via the @@ -35,6 +36,7 @@ public interface ErrorHandlerAware { /** * Gets the error handler */ + @Nullable Processor getErrorHandler(); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ErrorRegistryEntry.java b/core/camel-api/src/main/java/org/apache/camel/spi/ErrorRegistryEntry.java index 076b6e0bc7ed6..a8bef47a992af 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ErrorRegistryEntry.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ErrorRegistryEntry.java @@ -61,6 +61,7 @@ public interface ErrorRegistryEntry { /** * The exception message */ + @Nullable String exceptionMessage(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ExceptionHandler.java b/core/camel-api/src/main/java/org/apache/camel/spi/ExceptionHandler.java index 14f90be07fd1e..06245220ab4d0 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ExceptionHandler.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ExceptionHandler.java @@ -17,6 +17,7 @@ package org.apache.camel.spi; import org.apache.camel.Exchange; +import org.jspecify.annotations.Nullable; /** * A Strategy pattern for handling exceptions; particularly in asynchronous processes such as consumers. @@ -39,7 +40,7 @@ public interface ExceptionHandler { * @param message additional message * @param exception the exception */ - void handleException(String message, Throwable exception); + void handleException(@Nullable String message, Throwable exception); /** * Handles the given exception @@ -48,5 +49,5 @@ public interface ExceptionHandler { * @param exchange exchange which cause the exception * @param exception the exception */ - void handleException(String message, Exchange exchange, Throwable exception); + void handleException(@Nullable String message, @Nullable Exchange exchange, Throwable exception); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ExchangeFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/ExchangeFactory.java index 3ecaf4c88415a..c7f6f902863b6 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ExchangeFactory.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ExchangeFactory.java @@ -20,6 +20,7 @@ import org.apache.camel.Endpoint; import org.apache.camel.Exchange; import org.apache.camel.NonManagedService; +import org.jspecify.annotations.Nullable; /** * Factory used by {@link Consumer} to create Camel {@link Exchange} holding the incoming message received by the @@ -47,6 +48,7 @@ public interface ExchangeFactory extends PooledObjectFactory, NonManag /** * The consumer using this factory. */ + @Nullable Consumer getConsumer(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/NamespaceAware.java b/core/camel-api/src/main/java/org/apache/camel/spi/NamespaceAware.java index a6602ffd3a962..ae2d463de3404 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/NamespaceAware.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/NamespaceAware.java @@ -18,6 +18,8 @@ import java.util.Map; +import org.jspecify.annotations.Nullable; + /** * Represents an object which is aware of the namespaces in which its used such as XPath and XQuery type expressions so * that the current namespace context can be injected @@ -34,5 +36,6 @@ public interface NamespaceAware { /** * Gets the XML Namespaces */ + @Nullable Map getNamespaces(); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/OnCamelContextEvent.java b/core/camel-api/src/main/java/org/apache/camel/spi/OnCamelContextEvent.java index 968cfc897e95b..67b667760c268 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/OnCamelContextEvent.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/OnCamelContextEvent.java @@ -16,10 +16,9 @@ */ package org.apache.camel.spi; -import org.apache.camel.CamelContext; - /** - * Marker interface used to make it easy to discover {@link CamelContext} related event handlers from the registry. + * Marker interface used to make it easy to discover {@link org.apache.camel.CamelContext} related event handlers from + * the registry. * * @see OnCamelContextInitializing * @see OnCamelContextInitialized diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ScriptingLanguage.java b/core/camel-api/src/main/java/org/apache/camel/spi/ScriptingLanguage.java index a645dee91c2e2..4cf2c1990fe1c 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/ScriptingLanguage.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/ScriptingLanguage.java @@ -34,5 +34,5 @@ public interface ScriptingLanguage { * @param resultType the expected result type * @return the result of the evaluation */ - T evaluate(String script, @Nullable Map bindings, Class resultType); + @Nullable T evaluate(String script, @Nullable Map bindings, Class resultType); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/SharedInternalProcessor.java b/core/camel-api/src/main/java/org/apache/camel/spi/SharedInternalProcessor.java index 29c4159f873d2..20fa438a84f89 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/SharedInternalProcessor.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/SharedInternalProcessor.java @@ -20,6 +20,7 @@ import org.apache.camel.AsyncProcessor; import org.apache.camel.Exchange; import org.apache.camel.Processor; +import org.jspecify.annotations.Nullable; /** * A Shared (thread safe) internal {@link Processor} that Camel routing engine used during routing for cross cutting @@ -50,11 +51,13 @@ default void process(Exchange exchange) throws Exception { /** * Asynchronous API */ - boolean process(Exchange exchange, AsyncCallback originalCallback, AsyncProcessor processor, Processor resultProcessor); + boolean process( + Exchange exchange, AsyncCallback originalCallback, AsyncProcessor processor, + @Nullable Processor resultProcessor); /** * Synchronous API */ - void process(Exchange exchange, AsyncProcessor processor, Processor resultProcessor); + void process(Exchange exchange, AsyncProcessor processor, @Nullable Processor resultProcessor); } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/StreamCachingStrategy.java b/core/camel-api/src/main/java/org/apache/camel/spi/StreamCachingStrategy.java index 85f13ac89baf1..798a70ac32389 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/StreamCachingStrategy.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/StreamCachingStrategy.java @@ -175,6 +175,7 @@ interface SpoolRule { */ void setSpoolDirectory(File path); + @Nullable File getSpoolDirectory(); void setSpoolDirectory(String path); @@ -205,6 +206,7 @@ interface SpoolRule { */ void setSpoolUsedHeapMemoryLimit(SpoolUsedHeapMemoryLimit bounds); + @Nullable SpoolUsedHeapMemoryLimit getSpoolUsedHeapMemoryLimit(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/TypeConvertible.java b/core/camel-api/src/main/java/org/apache/camel/spi/TypeConvertible.java index d179a63028093..a92659e31c5e7 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/TypeConvertible.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/TypeConvertible.java @@ -19,6 +19,8 @@ import java.util.Objects; +import org.jspecify.annotations.Nullable; + import static org.apache.camel.util.ObjectHelper.convertPrimitiveTypeToWrapperType; /** @@ -71,7 +73,7 @@ public boolean matches(TypeConvertible that) { * @param that the TypeConvertible being tested against this instance * @return true if there is a conversion match between the give TypeConvertible and this instance. */ - public boolean matchesPrimitive(TypeConvertible that) { + public boolean matchesPrimitive(@Nullable TypeConvertible that) { if (that != null && that.getTo() != null) { return match(this.from, this.to, that.from, convertPrimitiveTypeToWrapperType(that.to)); } @@ -88,7 +90,9 @@ public boolean matchesPrimitive(TypeConvertible that) { * @param thatTo The class instance that defines the source "to" type (that is: Class<F>.class) * @return true if there is a conversion match between the source types to the target types */ - private static boolean match(Class thisFrom, Class thisTo, Class thatFrom, Class thatTo) { + private static boolean match( + Class thisFrom, Class thisTo, @Nullable Class thatFrom, + @Nullable Class thatTo) { if (thatFrom == null || thatTo == null) { return false; } @@ -165,7 +169,7 @@ private static boolean directMatch(Class thisFrom, Class thisTo, Class } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (this == o) { return true; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/UnitOfWork.java b/core/camel-api/src/main/java/org/apache/camel/spi/UnitOfWork.java index a72898dc14ab4..6ecb73bd25d08 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/UnitOfWork.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/UnitOfWork.java @@ -137,8 +137,9 @@ public interface UnitOfWork { * {@link org.apache.camel.RuntimeConfiguration#isAllowUseOriginalMessage()} is enabled. If its disabled an * IllegalStateException is thrown. * - * @return the original IN {@link Message} + * @return the original IN {@link Message}, or {@code null} if the original message is not available */ + @Nullable Message getOriginalInMessage(); /** diff --git a/core/camel-api/src/main/java/org/apache/camel/support/jsse/BaseSSLContextParameters.java b/core/camel-api/src/main/java/org/apache/camel/support/jsse/BaseSSLContextParameters.java index 2f0651f3f27a6..fa090e7e042f3 100644 --- a/core/camel-api/src/main/java/org/apache/camel/support/jsse/BaseSSLContextParameters.java +++ b/core/camel-api/src/main/java/org/apache/camel/support/jsse/BaseSSLContextParameters.java @@ -142,7 +142,7 @@ private static void setNamedGroupsOnParams(SSLParameters params, String[] namedG } } - private static String[] getSignatureSchemesFromParams(SSLParameters params) { + private static String @Nullable [] getSignatureSchemesFromParams(SSLParameters params) { if (GET_SIGNATURE_SCHEMES == null) { return null; } @@ -1165,9 +1165,9 @@ protected boolean matchesOneOf(String value, List patterns) { * * @return the filtered named groups array, or {@code null} if no configuration is needed */ - private String[] resolveNamedGroups( - String[] currentNamedGroups, List enabledNamedGroups, - Patterns enabledNamedGroupsPatterns) { + private String @Nullable [] resolveNamedGroups( + String @Nullable [] currentNamedGroups, @Nullable List enabledNamedGroups, + @Nullable Patterns enabledNamedGroupsPatterns) { if (enabledNamedGroups == null && enabledNamedGroupsPatterns == null) { return null; @@ -1200,9 +1200,9 @@ private String[] resolveNamedGroups( * @return the filtered signature schemes array, or {@code null} if no configuration * is needed */ - private String[] resolveSignatureSchemes( - String[] currentSignatureSchemes, List enabledSignatureSchemes, - Patterns enabledSignatureSchemesPatterns) { + private String @Nullable [] resolveSignatureSchemes( + String @Nullable [] currentSignatureSchemes, @Nullable List enabledSignatureSchemes, + @Nullable Patterns enabledSignatureSchemesPatterns) { if (enabledSignatureSchemes == null && enabledSignatureSchemesPatterns == null) { return null; diff --git a/core/camel-api/src/main/java/org/apache/camel/support/jsse/TrustManagersParameters.java b/core/camel-api/src/main/java/org/apache/camel/support/jsse/TrustManagersParameters.java index e54cb7ce4ecce..37b2777c40ad4 100644 --- a/core/camel-api/src/main/java/org/apache/camel/support/jsse/TrustManagersParameters.java +++ b/core/camel-api/src/main/java/org/apache/camel/support/jsse/TrustManagersParameters.java @@ -50,7 +50,7 @@ public class TrustManagersParameters extends JsseParameters { * * @see KeyStoreParameters#createKeyStore() */ - public TrustManager[] createTrustManagers() throws GeneralSecurityException, IOException { + public @Nullable TrustManager[] createTrustManagers() throws GeneralSecurityException, IOException { if (trustManager != null) { // use existing trust manager return new TrustManager[] { trustManager }; From 5b89de37a8356c8e3c609f7ddf20116e47eb2738 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 30 Mar 2026 08:52:17 +0200 Subject: [PATCH 3/3] CAMEL-22640: Fix remaining @Nullable issues found by runtime enforcement - CamelExchangeException: accept @Nullable exchange (field already nullable) - CamelExecutionException: accept @Nullable exchange (called with null from ExchangeHelper) - ExchangeTimedOutException: accept @Nullable exchange (consistent with parent) - Transformer: setFrom/setTo accept @Nullable (fields already nullable, called with null from reifiers) Co-Authored-By: Claude Opus 4.6 --- .../apache/camel/CamelExchangeException.java | 13 +++++++++---- .../apache/camel/CamelExecutionException.java | 16 +++++++++++----- .../camel/ExchangeTimedOutException.java | 11 ++++++++--- .../java/org/apache/camel/spi/Transformer.java | 18 ++++++++++-------- 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/core/camel-api/src/main/java/org/apache/camel/CamelExchangeException.java b/core/camel-api/src/main/java/org/apache/camel/CamelExchangeException.java index 3801e0a70625c..cf0114b7a2881 100644 --- a/core/camel-api/src/main/java/org/apache/camel/CamelExchangeException.java +++ b/core/camel-api/src/main/java/org/apache/camel/CamelExchangeException.java @@ -17,6 +17,7 @@ package org.apache.camel; import java.io.Serial; +import java.util.Objects; import org.jspecify.annotations.Nullable; @@ -28,13 +29,17 @@ public class CamelExchangeException extends CamelException { // exchange is not guaranteed to be serializable so we set it as transient private final transient @Nullable Exchange exchange; - public CamelExchangeException(String message, Exchange exchange) { - super(CamelExchangeException.createExceptionMessage(message, exchange, null)); + public CamelExchangeException(String message, @Nullable Exchange exchange) { + super(CamelExchangeException.createExceptionMessage( + Objects.requireNonNull(message, "message"), exchange, null)); this.exchange = exchange; } - public CamelExchangeException(String message, Exchange exchange, Throwable cause) { - super(CamelExchangeException.createExceptionMessage(message, exchange, cause), cause); + public CamelExchangeException(String message, @Nullable Exchange exchange, Throwable cause) { + super(CamelExchangeException.createExceptionMessage( + Objects.requireNonNull(message, "message"), exchange, + Objects.requireNonNull(cause, "cause")), + cause); this.exchange = exchange; } diff --git a/core/camel-api/src/main/java/org/apache/camel/CamelExecutionException.java b/core/camel-api/src/main/java/org/apache/camel/CamelExecutionException.java index 8de9f9792762c..e18b0d833bd5f 100644 --- a/core/camel-api/src/main/java/org/apache/camel/CamelExecutionException.java +++ b/core/camel-api/src/main/java/org/apache/camel/CamelExecutionException.java @@ -16,6 +16,10 @@ */ package org.apache.camel; +import java.util.Objects; + +import org.jspecify.annotations.Nullable; + /** * Exception occurred during execution/processing of an {@link Exchange}. *

@@ -23,12 +27,13 @@ */ public class CamelExecutionException extends RuntimeExchangeException { - public CamelExecutionException(String message, Exchange exchange) { - super(message, exchange); + public CamelExecutionException(String message, @Nullable Exchange exchange) { + super(Objects.requireNonNull(message, "message"), exchange); } - public CamelExecutionException(String message, Exchange exchange, Throwable cause) { - super(message, exchange, cause); + public CamelExecutionException(String message, @Nullable Exchange exchange, Throwable cause) { + super(Objects.requireNonNull(message, "message"), exchange, + Objects.requireNonNull(cause, "cause")); } /** @@ -37,7 +42,8 @@ public CamelExecutionException(String message, Exchange exchange, Throwable caus * @param e the caused exception * @return the wrapper exception */ - public static CamelExecutionException wrapCamelExecutionException(Exchange exchange, Throwable e) { + public static CamelExecutionException wrapCamelExecutionException(@Nullable Exchange exchange, Throwable e) { + Objects.requireNonNull(e, "e"); if (e instanceof CamelExecutionException ce) { // don't double wrap return ce; diff --git a/core/camel-api/src/main/java/org/apache/camel/ExchangeTimedOutException.java b/core/camel-api/src/main/java/org/apache/camel/ExchangeTimedOutException.java index dbf76b0fee354..34ea1de40e51e 100644 --- a/core/camel-api/src/main/java/org/apache/camel/ExchangeTimedOutException.java +++ b/core/camel-api/src/main/java/org/apache/camel/ExchangeTimedOutException.java @@ -16,6 +16,10 @@ */ package org.apache.camel; +import java.util.Objects; + +import org.jspecify.annotations.Nullable; + /** * An exception thrown if an InOut exchange times out receiving the OUT message */ @@ -23,13 +27,14 @@ public class ExchangeTimedOutException extends CamelExchangeException { private final long timeout; - public ExchangeTimedOutException(Exchange exchange, long timeout) { + public ExchangeTimedOutException(@Nullable Exchange exchange, long timeout) { super("The OUT message was not received within: " + timeout + " millis", exchange); this.timeout = timeout; } - public ExchangeTimedOutException(Exchange exchange, long timeout, String message) { - super("The OUT message was not received within: " + timeout + " millis due " + message, exchange); + public ExchangeTimedOutException(@Nullable Exchange exchange, long timeout, String message) { + super("The OUT message was not received within: " + timeout + " millis due " + + Objects.requireNonNull(message, "message"), exchange); this.timeout = timeout; } diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/Transformer.java b/core/camel-api/src/main/java/org/apache/camel/spi/Transformer.java index 718cce4757a6d..000bd0784fbbe 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/Transformer.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/Transformer.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spi; +import java.util.Objects; + import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; import org.apache.camel.Message; @@ -56,7 +58,7 @@ public Transformer() { } public Transformer(String name) { - this.name = name; + this.name = Objects.requireNonNull(name, "name"); } /** @@ -93,7 +95,7 @@ public Transformer(String name) { * Set the name for this transformer. Usually a combination of scheme and name. */ public Transformer setName(String name) { - this.name = name; + this.name = Objects.requireNonNull(name, "name"); return this; } @@ -104,7 +106,7 @@ public Transformer setName(String name) { * @param scheme supported data type scheme * @param name transformer name */ - public Transformer setName(String scheme, String name) { + public Transformer setName(@Nullable String scheme, @Nullable String name) { if (ObjectHelper.isNotEmpty(scheme)) { if (ObjectHelper.isNotEmpty(name)) { this.name = scheme + ":" + name; @@ -120,16 +122,16 @@ public Transformer setName(String scheme, String name) { /** * Set 'from' data type. */ - public Transformer setFrom(String from) { - this.from = new DataType(from); + public Transformer setFrom(@Nullable String from) { + this.from = from != null ? new DataType(from) : null; return this; } /** * Set 'to' data type. */ - public Transformer setTo(String to) { - this.to = new DataType(to); + public Transformer setTo(@Nullable String to) { + this.to = to != null ? new DataType(to) : null; return this; } @@ -140,7 +142,7 @@ public Transformer setTo(String to) { @Override public void setCamelContext(CamelContext context) { - this.camelContext = context; + this.camelContext = Objects.requireNonNull(context, "context"); } @Override