You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2026/05/13 07:54:50 UTC
(camel) branch main updated: CAMEL-22640: Add JSpecify null safety annotations to camel-api
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 67f6a37d473c CAMEL-22640: Add JSpecify null safety annotations to camel-api
67f6a37d473c is described below
commit 67f6a37d473c9bb1285a66d94b66ca24ac199fe0
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Wed May 13 09:54:43 2026 +0200
CAMEL-22640: Add JSpecify null safety annotations to camel-api
- Add org.jspecify:jspecify as optional dependency to camel-api
- Mark all 16 packages in camel-api as @NullMarked via package-info.java
- Add ~1200 @Nullable annotations across the public API surface
- Add opt-in NullAway validation profile (-Pnullcheck, requires JDK 21+)
- Add note to 4.21 upgrade guide about the new jspecify dependency
---
core/camel-api/pom.xml | 6 +
.../org/apache/camel/ExchangeConstantProvider.java | 4 +-
.../java/org/apache/camel/AggregationStrategy.java | 9 +-
.../java/org/apache/camel/BinaryPredicate.java | 3 +
.../apache/camel/CamelAuthorizationException.java | 13 ++-
.../main/java/org/apache/camel/CamelContext.java | 66 ++++++++---
.../main/java/org/apache/camel/CamelException.java | 8 +-
.../org/apache/camel/CamelExchangeException.java | 22 ++--
.../org/apache/camel/CamelExecutionException.java | 16 ++-
.../org/apache/camel/CamelUnitOfWorkException.java | 6 +-
.../java/org/apache/camel/CatalogCamelContext.java | 8 ++
.../src/main/java/org/apache/camel/Channel.java | 6 +-
.../src/main/java/org/apache/camel/Component.java | 9 +-
.../main/java/org/apache/camel/ComponentAware.java | 5 +-
.../src/main/java/org/apache/camel/Consumer.java | 3 +-
.../java/org/apache/camel/ConsumerTemplate.java | 32 +++--
.../java/org/apache/camel/DelegateProcessor.java | 5 +-
.../org/apache/camel/DynamicPollingConsumer.java | 5 +
.../src/main/java/org/apache/camel/Exchange.java | 39 ++++---
.../java/org/apache/camel/ExchangeExtension.java | 23 ++--
.../java/org/apache/camel/ExchangePropertyKey.java | 3 +-
.../apache/camel/ExchangeTimedOutException.java | 11 +-
.../apache/camel/ExpectedBodyTypeException.java | 16 ++-
.../src/main/java/org/apache/camel/Expression.java | 4 +-
.../camel/ExpressionEvaluationException.java | 22 ++--
.../camel/ExpressionIllegalSyntaxException.java | 8 +-
.../org/apache/camel/ExtendedCamelContext.java | 36 +++---
.../camel/FailedToCreateConsumerException.java | 14 ++-
.../camel/FailedToCreateProducerException.java | 5 +-
.../apache/camel/FailedToCreateRouteException.java | 41 ++++---
.../FailedToCreateRouteFromTemplateException.java | 10 +-
.../camel/FailedToStartComponentException.java | 5 +-
.../apache/camel/FailedToStartRouteException.java | 23 ++--
.../org/apache/camel/FluentProducerTemplate.java | 15 ++-
.../org/apache/camel/InvalidPayloadException.java | 21 ++--
.../camel/InvalidPayloadRuntimeException.java | 21 ++--
.../org/apache/camel/InvalidPropertyException.java | 15 ++-
.../java/org/apache/camel/LineNumberAware.java | 7 +-
.../org/apache/camel/LoadPropertiesException.java | 4 +-
.../src/main/java/org/apache/camel/Message.java | 22 ++--
.../main/java/org/apache/camel/MessageHistory.java | 3 +
.../src/main/java/org/apache/camel/NamedNode.java | 11 +-
.../src/main/java/org/apache/camel/NamedRoute.java | 2 +
.../src/main/java/org/apache/camel/Navigate.java | 3 +
.../apache/camel/NoFactoryAvailableException.java | 5 +-
.../java/org/apache/camel/NoSuchBeanException.java | 25 ++--
.../org/apache/camel/NoSuchBeanTypeException.java | 6 +-
.../org/apache/camel/NoSuchEndpointException.java | 8 +-
.../org/apache/camel/NoSuchHeaderException.java | 23 ++--
.../camel/NoSuchHeaderOrPropertyException.java | 18 ++-
.../org/apache/camel/NoSuchLanguageException.java | 4 +-
.../org/apache/camel/NoSuchPropertyException.java | 19 ++-
.../org/apache/camel/NoSuchServiceException.java | 5 +-
.../org/apache/camel/NoSuchVariableException.java | 18 +--
.../camel/NoTypeConversionAvailableException.java | 25 ++--
.../java/org/apache/camel/PollingConsumer.java | 5 +
.../java/org/apache/camel/ProducerTemplate.java | 38 ++++--
.../org/apache/camel/PropertiesLookupListener.java | 4 +-
.../org/apache/camel/PropertyBindingException.java | 42 ++++---
.../apache/camel/ProxyInstantiationException.java | 5 +-
.../camel/ResolveEndpointFailedException.java | 20 ++--
.../apache/camel/RollbackExchangeException.java | 7 +-
.../src/main/java/org/apache/camel/Route.java | 21 +++-
.../src/main/java/org/apache/camel/RouteAware.java | 5 +-
.../org/apache/camel/RouteTemplateContext.java | 8 +-
.../org/apache/camel/RuntimeCamelException.java | 11 +-
.../org/apache/camel/RuntimeConfiguration.java | 6 +-
.../org/apache/camel/RuntimeExchangeException.java | 20 ++--
.../apache/camel/RuntimeExpressionException.java | 8 +-
.../apache/camel/RuntimeTransformException.java | 8 +-
.../apache/camel/SSLContextParametersAware.java | 8 +-
.../java/org/apache/camel/StaticExpression.java | 5 +-
.../main/java/org/apache/camel/StreamCache.java | 3 +
.../org/apache/camel/StreamCacheException.java | 8 +-
.../src/main/java/org/apache/camel/TimeoutMap.java | 6 +
.../org/apache/camel/TypeConversionException.java | 18 ++-
.../main/java/org/apache/camel/TypeConverter.java | 16 ++-
.../apache/camel/TypeConverterExistsException.java | 5 +-
.../apache/camel/TypeConverterLoaderException.java | 7 +-
.../java/org/apache/camel/ValidationException.java | 12 +-
.../main/java/org/apache/camel/ValueHolder.java | 6 +-
.../main/java/org/apache/camel/VariableAware.java | 3 +
.../camel/VetoCamelContextStartException.java | 10 +-
.../main/java/org/apache/camel/WrappedFile.java | 4 +
.../package-info.java} | 10 +-
.../ConfigurationPropertiesValidationResult.java | 20 ++--
.../camel/catalog/EndpointValidationResult.java | 30 +++--
.../apache/camel/catalog/JSonSchemaResolver.java | 12 ++
.../camel/catalog/LanguageValidationResult.java | 17 +--
.../camel/catalog/PropertiesValidationResult.java | 56 ++++++---
.../apache/camel/catalog/RuntimeCamelCatalog.java | 2 +
.../package-info.java} | 10 +-
.../java/org/apache/camel/clock/ContextClock.java | 11 +-
.../java/org/apache/camel/clock/EventClock.java | 5 +-
.../package-info.java} | 10 +-
.../package-info.java} | 10 +-
.../package-info.java} | 10 +-
.../extension/ComponentVerifierExtension.java | 11 +-
.../component/extension/MetaDataExtension.java | 7 +-
.../extension/package-info.java} | 10 +-
.../apache/camel/console/DevConsoleRegistry.java | 4 +-
.../apache/camel/console/DevConsoleResolver.java | 2 +
.../package-info.java} | 10 +-
.../org/apache/camel/health/HealthCheckHelper.java | 55 ++++++---
.../apache/camel/health/HealthCheckRegistry.java | 7 +-
.../apache/camel/health/HealthCheckResolver.java | 3 +
.../camel/health/HealthCheckResultBuilder.java | 33 +++---
.../package-info.java} | 10 +-
.../main/java/org/apache/camel/package-info.java | 2 +
.../org/apache/camel/resume/Deserializable.java | 8 +-
.../main/java/org/apache/camel/resume/Offset.java | 7 +-
.../java/org/apache/camel/resume/OffsetKey.java | 5 +-
.../java/org/apache/camel/resume/Resumable.java | 3 +
.../org/apache/camel/resume/ResumeStrategy.java | 7 +-
.../camel/resume/ResumeStrategyConfiguration.java | 15 ++-
.../java/org/apache/camel/resume/Serializable.java | 4 +-
.../org/apache/camel/resume/cache/ResumeCache.java | 4 +-
.../cache/package-info.java} | 10 +-
.../package-info.java} | 10 +-
.../apache/camel/spi/AggregationRepository.java | 3 +
.../camel/spi/AsyncProcessorAwaitManager.java | 3 +
.../java/org/apache/camel/spi/BacklogDebugger.java | 5 +
.../java/org/apache/camel/spi/BacklogTracer.java | 8 +-
.../camel/spi/BacklogTracerEventMessage.java | 13 +++
.../org/apache/camel/spi/BeanIntrospection.java | 24 ++--
.../org/apache/camel/spi/BeanProcessorFactory.java | 6 +-
.../java/org/apache/camel/spi/BeanRepository.java | 6 +-
.../main/java/org/apache/camel/spi/Breakpoint.java | 3 +-
.../org/apache/camel/spi/BrowsableEndpoint.java | 9 +-
.../org/apache/camel/spi/BulkTypeConverters.java | 40 +++++--
.../apache/camel/spi/CamelBeanPostProcessor.java | 5 +-
.../camel/spi/CamelBeanPostProcessorInjector.java | 6 +-
.../org/apache/camel/spi/CamelContextTracker.java | 7 +-
.../main/java/org/apache/camel/spi/CamelEvent.java | 2 +
.../camel/spi/CamelInternalProcessorAdvice.java | 4 +-
.../java/org/apache/camel/spi/CamelLogger.java | 54 +++++++--
.../org/apache/camel/spi/ClaimCheckRepository.java | 4 +
.../java/org/apache/camel/spi/ClassResolver.java | 11 +-
.../org/apache/camel/spi/CompilePostProcessor.java | 3 +-
.../java/org/apache/camel/spi/CompileStrategy.java | 3 +
.../org/apache/camel/spi/ComponentCustomizer.java | 6 +-
.../org/apache/camel/spi/ComponentResolver.java | 2 +
.../org/apache/camel/spi/ConfigurerResolver.java | 2 +
.../org/apache/camel/spi/ConfigurerStrategy.java | 2 +
.../java/org/apache/camel/spi/ConsumerCache.java | 5 +
.../org/apache/camel/spi/ContentTypeAware.java | 5 +-
.../main/java/org/apache/camel/spi/Contract.java | 19 ++-
.../org/apache/camel/spi/DataFormatCustomizer.java | 6 +-
.../org/apache/camel/spi/DataFormatResolver.java | 2 +
.../main/java/org/apache/camel/spi/DataType.java | 18 +--
.../java/org/apache/camel/spi/DataTypeAware.java | 3 +
.../apache/camel/spi/EndpointServiceLocation.java | 6 +-
.../apache/camel/spi/EndpointServiceRegistry.java | 6 +-
.../org/apache/camel/spi/ErrorHandlerAware.java | 2 +
.../org/apache/camel/spi/ErrorRegistryEntry.java | 8 +-
.../java/org/apache/camel/spi/EventFactory.java | 5 +-
.../org/apache/camel/spi/ExceptionHandler.java | 5 +-
.../java/org/apache/camel/spi/ExchangeFactory.java | 2 +
.../apache/camel/spi/ExecutorServiceManager.java | 3 +
.../camel/spi/ExpressionResultTypeAware.java | 3 +
.../org/apache/camel/spi/GroovyScriptCompiler.java | 3 +
.../main/java/org/apache/camel/spi/GroupAware.java | 4 +-
.../java/org/apache/camel/spi/HasCamelContext.java | 2 +
.../main/java/org/apache/camel/spi/HasGroup.java | 3 +
.../org/apache/camel/spi/HeaderFilterStrategy.java | 5 +-
.../camel/spi/HeaderFilterStrategyAware.java | 3 +
.../org/apache/camel/spi/HttpResponseAware.java | 5 +-
.../org/apache/camel/spi/InflightRepository.java | 10 +-
.../apache/camel/spi/InterceptEndpointFactory.java | 3 +-
.../apache/camel/spi/InterceptSendToEndpoint.java | 10 +-
.../org/apache/camel/spi/InterceptStrategy.java | 3 +-
.../org/apache/camel/spi/InternalProcessor.java | 3 +-
.../apache/camel/spi/InternalProcessorFactory.java | 4 +-
.../apache/camel/spi/InvokeOnHeaderStrategy.java | 2 +
.../org/apache/camel/spi/LanguageCustomizer.java | 3 +-
.../org/apache/camel/spi/LifecycleStrategy.java | 15 +--
.../apache/camel/spi/LocalBeanRepositoryAware.java | 5 +-
.../java/org/apache/camel/spi/ManagementAgent.java | 4 +-
.../camel/spi/ManagementInterceptStrategy.java | 6 +-
.../apache/camel/spi/ManagementMBeanAssembler.java | 2 +
.../apache/camel/spi/ManagementNameStrategy.java | 3 +
.../camel/spi/ManagementObjectNameStrategy.java | 4 +-
.../apache/camel/spi/ManagementObjectStrategy.java | 3 +-
.../camel/spi/ManagementStrategyFactory.java | 3 +-
.../apache/camel/spi/MessageHistoryFactory.java | 4 +-
.../spi/MockSendToEndpointStrategyFactory.java | 4 +-
.../java/org/apache/camel/spi/ModelDumpLine.java | 6 +-
.../java/org/apache/camel/spi/NamespaceAware.java | 3 +
.../org/apache/camel/spi/OAuthClientConfig.java | 28 +++--
.../org/apache/camel/spi/OnCamelContextEvent.java | 5 +-
.../OptimisticLockingAggregationRepository.java | 4 +-
.../org/apache/camel/spi/PeriodTaskScheduler.java | 4 +-
.../java/org/apache/camel/spi/PluginManager.java | 4 +-
.../org/apache/camel/spi/PollDynamicAware.java | 2 +
.../org/apache/camel/spi/PooledObjectFactory.java | 3 +
.../camel/spi/PredicateExceptionFactory.java | 4 +-
.../org/apache/camel/spi/ProcessorFactory.java | 4 +
.../java/org/apache/camel/spi/ProducerCache.java | 6 +-
.../org/apache/camel/spi/PropertiesComponent.java | 10 +-
.../apache/camel/spi/PropertiesResolvedValue.java | 5 +-
.../org/apache/camel/spi/PropertiesSource.java | 4 +-
.../apache/camel/spi/PropertyConfigurerAware.java | 3 +
.../apache/camel/spi/PropertyConfigurerGetter.java | 8 +-
.../spi/RecoverableAggregationRepository.java | 5 +-
.../main/java/org/apache/camel/spi/Registry.java | 11 +-
.../java/org/apache/camel/spi/ReloadStrategy.java | 2 +
.../main/java/org/apache/camel/spi/Resource.java | 4 +-
.../java/org/apache/camel/spi/ResourceAware.java | 3 +
.../org/apache/camel/spi/ResourceResolver.java | 2 +
.../RestBindingJacksonXmlDataFormatFactory.java | 4 +-
.../spi/RestBindingJaxbDataFormatFactory.java | 4 +-
.../camel/spi/RestClientRequestValidator.java | 2 +
.../camel/spi/RestClientResponseValidator.java | 2 +
.../org/apache/camel/spi/RestConfiguration.java | 129 +++++++++++----------
.../org/apache/camel/spi/RestConsumerFactory.java | 7 +-
.../org/apache/camel/spi/RestProducerFactory.java | 6 +-
.../java/org/apache/camel/spi/RestRegistry.java | 17 ++-
.../java/org/apache/camel/spi/RouteFactory.java | 5 +-
.../java/org/apache/camel/spi/RouteIdAware.java | 3 +
.../org/apache/camel/spi/RoutePolicyFactory.java | 2 +
.../java/org/apache/camel/spi/RoutesLoader.java | 16 ++-
.../org/apache/camel/spi/ScriptingLanguage.java | 4 +-
.../org/apache/camel/spi/SendDynamicAware.java | 4 +
.../apache/camel/spi/SharedInternalProcessor.java | 7 +-
.../java/org/apache/camel/spi/SimpleFunction.java | 4 +-
.../apache/camel/spi/SimpleFunctionRegistry.java | 2 +
.../camel/spi/SimpleLanguageFunctionFactory.java | 3 +
.../org/apache/camel/spi/StartupCondition.java | 5 +-
.../org/apache/camel/spi/StartupStepRecorder.java | 3 +
.../java/org/apache/camel/spi/StateRepository.java | 2 +
.../apache/camel/spi/StreamCachingStrategy.java | 7 ++
.../camel/spi/SupervisingRouteController.java | 10 +-
.../java/org/apache/camel/spi/Synchronization.java | 3 +-
.../org/apache/camel/spi/ThreadPoolProfile.java | 60 +++++-----
.../src/main/java/org/apache/camel/spi/Tracer.java | 4 +-
.../java/org/apache/camel/spi/Transformer.java | 35 +++---
.../java/org/apache/camel/spi/TransformerKey.java | 20 ++--
.../org/apache/camel/spi/TransformerRegistry.java | 2 +
.../org/apache/camel/spi/TransformerResolver.java | 2 +
.../apache/camel/spi/TypeConverterRegistry.java | 2 +
.../java/org/apache/camel/spi/TypeConvertible.java | 19 +--
.../main/java/org/apache/camel/spi/UnitOfWork.java | 8 +-
.../org/apache/camel/spi/UriFactoryResolver.java | 2 +
.../main/java/org/apache/camel/spi/Validator.java | 14 ++-
.../java/org/apache/camel/spi/ValidatorKey.java | 4 +-
.../org/apache/camel/spi/ValidatorRegistry.java | 2 +
.../org/apache/camel/spi/VariableRepository.java | 2 +
.../camel/spi/VariableRepositoryFactory.java | 3 +
.../spi/{GroupAware.java => package-info.java} | 15 +--
.../jsse/AliasedX509ExtendedKeyManager.java | 25 ++--
.../support/jsse/BaseSSLContextParameters.java | 128 +++++++++++---------
.../camel/support/jsse/CipherSuitesParameters.java | 8 +-
.../camel/support/jsse/FilterParameters.java | 11 +-
.../apache/camel/support/jsse/JsseParameters.java | 28 +++--
.../camel/support/jsse/KeyManagersParameters.java | 28 ++---
.../camel/support/jsse/KeyStoreParameters.java | 36 +++---
.../camel/support/jsse/NamedGroupsParameters.java | 9 +-
.../support/jsse/SSLContextClientParameters.java | 3 +
.../camel/support/jsse/SSLContextParameters.java | 64 +++++-----
.../support/jsse/SSLContextServerParameters.java | 21 ++--
.../camel/support/jsse/SecureRandomParameters.java | 13 ++-
.../jsse/SecureSocketProtocolsParameters.java | 6 +-
.../support/jsse/SignatureSchemesParameters.java | 9 +-
.../support/jsse/TrustManagersParameters.java | 27 ++---
.../jsse/package-info.java} | 10 +-
.../apache/camel/support/service/BaseService.java | 3 +-
.../camel/support/service/ServiceHelper.java | 61 +++++-----
.../service/package-info.java} | 10 +-
.../message/package-info.java} | 10 +-
.../apache/camel/vault/AwsVaultConfiguration.java | 43 +++----
.../camel/vault/AzureVaultConfiguration.java | 55 ++++-----
.../camel/vault/CyberArkVaultConfiguration.java | 49 ++++----
.../apache/camel/vault/GcpVaultConfiguration.java | 25 ++--
.../camel/vault/HashicorpVaultConfiguration.java | 37 +++---
.../vault/IBMSecretsManagerVaultConfiguration.java | 49 ++++----
.../KubernetesConfigMapVaultConfiguration.java | 7 +-
.../camel/vault/KubernetesVaultConfiguration.java | 7 +-
.../vault/SpringCloudConfigConfiguration.java | 25 ++--
.../org/apache/camel/vault/VaultConfiguration.java | 56 ++++-----
.../package-info.java} | 10 +-
.../ROOT/pages/camel-4x-upgrade-guide-4_21.adoc | 6 +
parent/pom.xml | 60 ++++++++++
.../main/resources/velocity/constant-provider.vm | 4 +-
283 files changed, 2268 insertions(+), 1210 deletions(-)
diff --git a/core/camel-api/pom.xml b/core/camel-api/pom.xml
index e7c91e7fde7b..45b8ff47d411 100644
--- a/core/camel-api/pom.xml
+++ b/core/camel-api/pom.xml
@@ -39,6 +39,12 @@
<dependencies>
+ <dependency>
+ <groupId>org.jspecify</groupId>
+ <artifactId>jspecify</artifactId>
+ <optional>true</optional>
+ </dependency>
+
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-util</artifactId>
diff --git a/core/camel-api/src/generated/java/org/apache/camel/ExchangeConstantProvider.java b/core/camel-api/src/generated/java/org/apache/camel/ExchangeConstantProvider.java
index da304199b08b..b9f4b37dd355 100644
--- a/core/camel-api/src/generated/java/org/apache/camel/ExchangeConstantProvider.java
+++ b/core/camel-api/src/generated/java/org/apache/camel/ExchangeConstantProvider.java
@@ -5,6 +5,8 @@ import javax.annotation.processing.Generated;
import java.util.HashMap;
import java.util.Map;
+import org.jspecify.annotations.Nullable;
+
/**
* Generated by camel build tools - do NOT edit this file!
*/
@@ -166,7 +168,7 @@ public class ExchangeConstantProvider {
MAP = map;
}
- public static String lookup(String key) {
+ public static @Nullable String lookup(String key) {
return MAP.get(key);
}
}
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 2109aa7df7bb..fd040410bb00 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 @@ public interface AggregationStrategy {
* @return <tt>true</tt> to complete current group and start a new group, or <tt>false</tt> 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 2626fbb25423..604904d01bc8 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.
* <p/>
@@ -55,6 +57,7 @@ public interface BinaryPredicate extends Predicate {
* @param exchange the message exchange
* @return <tt>null</tt> 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 4afeac7acc24..7e71b18f42aa 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,25 +16,30 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+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);
+ super(Objects.requireNonNull(message, "message"), Objects.requireNonNull(exchange, "exchange"));
policyId = exchange.getIn().getHeader(Exchange.AUTHENTICATION_FAILURE_POLICY_ID, String.class);
}
public CamelAuthorizationException(String message, Exchange exchange, Throwable cause) {
- super(message, exchange, cause);
+ super(Objects.requireNonNull(message, "message"), Objects.requireNonNull(exchange, "exchange"),
+ Objects.requireNonNull(cause, "cause"));
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 7f8ebdc2ac0e..8f38569407e7 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.Validator;
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(Predicate<Service> filter);
/**
@@ -283,7 +287,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* @param type the class type
* @return the service instance or <tt>null</tt> if not already added.
*/
- <T> T hasService(Class<T> type);
+ <T> @Nullable T hasService(Class<T> 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 <tt>null</tt> if not registered
*/
+ @Nullable
Component hasComponent(String componentName);
/**
@@ -352,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 <tt>null</tt> if not found and could not be auto created
*/
+ @Nullable
Component getComponent(String componentName);
/**
@@ -364,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 <tt>null</tt> if not found
*/
+ @Nullable
Component getComponent(String name, boolean autoCreateComponents);
/**
@@ -374,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 <tt>null</tt> if not found
*/
+ @Nullable
Component getComponent(String name, boolean autoCreateComponents, boolean autoStart);
/**
@@ -402,6 +410,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 +467,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* @param uri the URI of the endpoint
* @return the registered endpoint or <tt>null</tt> if not registered
*/
+ @Nullable
Endpoint hasEndpoint(String uri);
/**
@@ -468,6 +478,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* @return the old endpoint that was previously registered or <tt>null</tt> 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 +574,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* @param id id of the route
* @return the route or <tt>null</tt> if not found
*/
+ @Nullable
Route getRoute(String id);
/**
@@ -571,6 +583,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* @param id id of the processor
* @return the processor or <tt>null</tt> if not found
*/
+ @Nullable
Processor getProcessor(String id);
/**
@@ -581,7 +594,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* @return the processor or <tt>null</tt> if not found
* @throws java.lang.ClassCastException is thrown if the type is not correct type
*/
- <T extends Processor> T getProcessor(String id, Class<T> type);
+ <T extends Processor> @Nullable T getProcessor(String id, Class<T> type);
/**
* Adds a collection of routes to this CamelContext using the given builder to build them.
@@ -654,7 +667,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<String, Object> parameters) throws Exception;
+ String addRouteFromTemplate(@Nullable String routeId, String routeTemplateId, Map<String, Object> parameters)
+ throws Exception;
/**
* Adds a new route from a given route template.
@@ -671,7 +685,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<String, Object> parameters)
throws Exception;
@@ -690,7 +704,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* @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<String, Object> parameters)
throws Exception;
@@ -709,7 +723,8 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
*/
@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 +742,8 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* @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 +760,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
*/
@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<String, Object> parameters)
throws Exception;
@@ -763,7 +779,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* @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<String, Object> parameters)
throws Exception;
@@ -810,6 +826,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
*
* @return the configuration, or <tt>null</tt> if none has been configured.
*/
+ @Nullable
RestConfiguration getRestConfiguration();
/**
@@ -824,6 +841,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
*
* @return the configuration, or <tt>null</tt> if none has been configured.
*/
+ @Nullable
VaultConfiguration getVaultConfiguration();
/**
@@ -880,7 +898,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* @param type the registry type such as org.apache.camel.impl.JndiRegistry
* @return the registry, or <tt>null</tt> if the given type was not found as a registry implementation
*/
- <T> T getRegistry(Class<T> type);
+ <T> @Nullable T getRegistry(Class<T> type);
/**
* Returns the injector used to instantiate objects by type
@@ -937,6 +955,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* repository. If no repo-id is provided, then global repository will be used.
* @return the variable, or <tt>null</tt> if not found.
*/
+ @Nullable
Object getVariable(String name);
/**
@@ -947,7 +966,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* @param type the type to convert the variable to
* @return the variable, or <tt>null</tt> if not found.
*/
- <T> T getVariable(String name, Class<T> type);
+ <T> @Nullable T getVariable(String name, Class<T> type);
/**
* Sets a variable
@@ -1091,6 +1110,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* @param name the data format name or a reference to it in the {@link Registry}
* @return the resolved data format, or <tt>null</tt> if not found
*/
+ @Nullable
DataFormat resolveDataFormat(String name);
/**
@@ -1099,6 +1119,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* @param name the data format name or a reference to a data format factory in the {@link Registry}
* @return the created data format, or <tt>null</tt> if not found
*/
+ @Nullable
DataFormat createDataFormat(String name);
/**
@@ -1114,6 +1135,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* @param name the transformer name, usually a combination of some scheme and name.
* @return the resolved transformer, or <tt>null</tt> if not found
*/
+ @Nullable
Transformer resolveTransformer(String name);
/**
@@ -1123,6 +1145,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* @param to to data type
* @return the resolved transformer, or <tt>null</tt> if not found
*/
+ @Nullable
Transformer resolveTransformer(DataType from, DataType to);
/**
@@ -1138,6 +1161,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* @param type the data type
* @return the resolved validator, or <tt>null</tt> if not found
*/
+ @Nullable
Validator resolveValidator(DataType type);
/**
@@ -1181,6 +1205,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
*
* @return the string value of the global option
*/
+ @Nullable
String getGlobalOption(String key);
/**
@@ -1440,7 +1465,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* 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.
@@ -1450,6 +1475,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* 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();
/**
@@ -1550,6 +1576,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* </ul>
*/
@Deprecated(since = "4.19.0")
+ @Nullable
String getMDCLoggingKeysPattern();
/**
@@ -1570,7 +1597,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* @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.
@@ -1623,6 +1650,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
*
* @return <tt>xml</tt>, <tt>yaml</tt>, or <tt>json</tt> if dumping is enabled
*/
+ @Nullable
String getDumpRoutes();
/**
@@ -1639,7 +1667,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
* @param format xml, yaml or json (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.
@@ -1688,6 +1716,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
/**
* Gets the {@link org.apache.camel.spi.RuntimeEndpointRegistry} to use, or <tt>null</tt> if none is in use.
*/
+ @Nullable
RuntimeEndpointRegistry getRuntimeEndpointRegistry();
/**
@@ -1703,6 +1732,7 @@ public interface CamelContext extends CamelContextLifecycle, RuntimeConfiguratio
/**
* 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 d4031cc99294..b4a608801f11 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 57e150da03aa..cf0114b7a288 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,9 @@
package org.apache.camel;
import java.io.Serial;
+import java.util.Objects;
+
+import org.jspecify.annotations.Nullable;
/**
* An exception caused by a specific message {@link Exchange}
@@ -24,22 +27,26 @@ import java.io.Serial;
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));
+ 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;
}
/**
* Returns the exchange which caused the exception
*/
- public Exchange getExchange() {
+ public @Nullable Exchange getExchange() {
return exchange;
}
@@ -53,7 +60,8 @@ public class CamelExchangeException extends CamelException {
* @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/CamelExecutionException.java b/core/camel-api/src/main/java/org/apache/camel/CamelExecutionException.java
index 8de9f9792762..e18b0d833bd5 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}.
* <p/>
@@ -23,12 +27,13 @@ package org.apache.camel;
*/
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 class CamelExecutionException extends RuntimeExchangeException {
* @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/CamelUnitOfWorkException.java b/core/camel-api/src/main/java/org/apache/camel/CamelUnitOfWorkException.java
index c93d6a3d2d4e..0e79c3c5ae3f 100644
--- a/core/camel-api/src/main/java/org/apache/camel/CamelUnitOfWorkException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/CamelUnitOfWorkException.java
@@ -17,6 +17,7 @@
package org.apache.camel;
import java.util.List;
+import java.util.Objects;
/**
* A {@link org.apache.camel.spi.UnitOfWork} failed with a number of caused exceptions.
@@ -30,8 +31,9 @@ public class CamelUnitOfWorkException extends CamelExchangeException {
public CamelUnitOfWorkException(Exchange exchange, List<Exception> causes) {
// just provide the first exception as cause, as it will be logged in the stacktraces
- super("Unit of work failed on exchange with " + causes.size()
- + " caused exceptions. First exception provided as cause to this exception.", exchange, causes.get(0));
+ super("Unit of work failed on exchange with " + Objects.requireNonNull(causes, "causes").size()
+ + " caused exceptions. First exception provided as cause to this exception.",
+ Objects.requireNonNull(exchange, "exchange"), causes.get(0));
this.causes = causes;
}
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 84063e4c6afa..2a71e3fd9b71 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 java.io.IOException;
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 <tt>null</tt> if the component is <b>not</b> 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 <tt>null</tt> 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 <tt>null</tt> 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 <tt>null</tt> 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 <tt>null</tt> 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 <tt>null</tt> 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 <tt>null</tt> 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 9778df21139c..19018fb37161 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 java.util.List;
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<Processor> {
void initChannel(
Route route,
NamedNode definition,
- NamedNode childDefinition,
+ @Nullable NamedNode childDefinition,
List<InterceptStrategy> interceptors,
Processor nextProcessor,
- NamedRoute routeDefinition,
+ @Nullable NamedRoute routeDefinition,
boolean first)
throws Exception;
@@ -54,6 +55,7 @@ public interface Channel extends AsyncProcessor, Navigate<Processor> {
*
* @return the error handler, or <tt>null</tt> 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 e4a01005e944..84313832e616 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 java.util.Optional;
import org.apache.camel.component.extension.ComponentExtension;
import org.apache.camel.spi.PropertyConfigurer;
+import org.jspecify.annotations.Nullable;
/**
* A <a href="http://camel.apache.org/component.html">component</a> 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<String, Object> parameters) throws Exception;
/**
@@ -70,7 +73,7 @@ public interface Component extends CamelContextAware, Service {
*
* @return the configurer, or <tt>null</tt> if the component does not support using property configurer.
*/
- default PropertyConfigurer getComponentPropertyConfigurer() {
+ default @Nullable PropertyConfigurer getComponentPropertyConfigurer() {
return null;
}
@@ -79,7 +82,7 @@ public interface Component extends CamelContextAware, Service {
*
* @return the configurer, or <tt>null</tt> if the endpoint does not support using property configurer.
*/
- default PropertyConfigurer getEndpointPropertyConfigurer() {
+ default @Nullable PropertyConfigurer getEndpointPropertyConfigurer() {
return null;
}
@@ -116,7 +119,7 @@ public interface Component extends CamelContextAware, Service {
/**
* 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 1fbe8a7c220e..b26952df5cee 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 extends Component> T getComponent(Class<T> type) {
+ default <T extends Component> @Nullable T getComponent(Class<T> 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 b1a6ba611a71..b6b29a164219 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 08e29fb4f6e9..3bfcfd6fe7c5 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}. <br/>
@@ -112,6 +114,7 @@ public interface ConsumerTemplate extends Service {
* @return the returned exchange, or <tt>null</tt> 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 <tt>null</tt> 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 <tt>null</tt> if no response
*/
+ @Nullable
Exchange receiveNoWait(String endpointUri);
/**
@@ -144,22 +149,25 @@ public interface ConsumerTemplate extends Service {
* @param endpoint the endpoint to receive from
* @return the returned exchange, or <tt>null</tt> if no response
*/
+ @Nullable
Exchange receiveNoWait(Endpoint endpoint);
/**
* 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 <tt>null</tt> 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 <tt>null</tt> if no body
*/
+ @Nullable
Object receiveBody(Endpoint endpoint);
/**
@@ -169,6 +177,7 @@ public interface ConsumerTemplate extends Service {
* @param timeout timeout in millis to wait for a response
* @return the returned response body, or <tt>null</tt> if no response
*/
+ @Nullable
Object receiveBody(String endpointUri, long timeout);
/**
@@ -178,6 +187,7 @@ public interface ConsumerTemplate extends Service {
* @param timeout timeout in millis to wait for a response
* @return the returned response body, or <tt>null</tt> if no response
*/
+ @Nullable
Object receiveBody(Endpoint endpoint, long timeout);
/**
@@ -186,6 +196,7 @@ public interface ConsumerTemplate extends Service {
* @param endpointUri the endpoint to receive from
* @return the returned response body, or <tt>null</tt> if no response
*/
+ @Nullable
Object receiveBodyNoWait(String endpointUri);
/**
@@ -194,6 +205,7 @@ public interface ConsumerTemplate extends Service {
* @param endpoint the endpoint to receive from
* @return the returned response body, or <tt>null</tt> if no response
*/
+ @Nullable
Object receiveBodyNoWait(Endpoint endpoint);
/**
@@ -201,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 <tt>null</tt> if no body
*/
- <T> T receiveBody(String endpointUri, Class<T> type);
+ <T> @Nullable T receiveBody(String endpointUri, Class<T> 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 <tt>null</tt> if no body
*/
- <T> T receiveBody(Endpoint endpoint, Class<T> type);
+ <T> @Nullable T receiveBody(Endpoint endpoint, Class<T> type);
/**
* Receives from the endpoint, waiting until there is a response or the timeout occurs
@@ -222,7 +234,7 @@ public interface ConsumerTemplate extends Service {
* @param type the expected response type
* @return the returned response body, or <tt>null</tt> if no response
*/
- <T> T receiveBody(String endpointUri, long timeout, Class<T> type);
+ <T> @Nullable T receiveBody(String endpointUri, long timeout, Class<T> type);
/**
* Receives from the endpoint, waiting until there is a response or the timeout occurs
@@ -232,7 +244,7 @@ public interface ConsumerTemplate extends Service {
* @param type the expected response type
* @return the returned response body, or <tt>null</tt> if no response
*/
- <T> T receiveBody(Endpoint endpoint, long timeout, Class<T> type);
+ <T> @Nullable T receiveBody(Endpoint endpoint, long timeout, Class<T> type);
/**
* Receives from the endpoint, not waiting for a response if non exists.
@@ -241,7 +253,7 @@ public interface ConsumerTemplate extends Service {
* @param type the expected response type
* @return the returned response body, or <tt>null</tt> if no response
*/
- <T> T receiveBodyNoWait(String endpointUri, Class<T> type);
+ <T> @Nullable T receiveBodyNoWait(String endpointUri, Class<T> type);
/**
* Receives from the endpoint, not waiting for a response if non exists.
@@ -250,7 +262,7 @@ public interface ConsumerTemplate extends Service {
* @param type the expected response type
* @return the returned response body, or <tt>null</tt> if no response
*/
- <T> T receiveBodyNoWait(Endpoint endpoint, Class<T> type);
+ <T> @Nullable T receiveBodyNoWait(Endpoint endpoint, Class<T> type);
/**
* If you have used any of the <tt>receive</tt> methods which returns a {@link Exchange} type then you need to
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 e8da508fc21a..574107e139c0 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 <tt>null</tt> if the delegate has not been initialized yet
*/
+ @Nullable
Processor getProcessor();
}
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 c939c6073756..bc661cbc8bde 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 <tt>null</tt>
*/
+ @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 <tt>null</tt> 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 55ec9532b582..43f47bcc5731 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.clock.Clock;
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 <tt>null</tt> 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 <tt>null</tt> if there is no property for the given name or
* <tt>null</tt> if it cannot be converted to the given type
*/
- <T> T getProperty(ExchangePropertyKey key, Class<T> type);
+ <T> @Nullable T getProperty(ExchangePropertyKey key, Class<T> 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 <tt>defaultValue</tt> if there is no property for the
* given name or <tt>null</tt> if it cannot be converted to the given type
*/
- <T> T getProperty(ExchangePropertyKey key, Object defaultValue, Class<T> type);
+ <T> @Nullable T getProperty(ExchangePropertyKey key, Object defaultValue, Class<T> 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 <tt>null</tt> 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 <tt>null</tt> if there is no property for the given name or
* <tt>null</tt> if it cannot be converted to the given type
*/
- <T> T getProperty(String name, Class<T> type);
+ <T> @Nullable T getProperty(String name, Class<T> 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 <tt>defaultValue</tt> if there is no property for the
* given name or <tt>null</tt> if it cannot be converted to the given type
*/
- <T> T getProperty(String name, Object defaultValue, Class<T> type);
+ <T> @Nullable T getProperty(String name, Object defaultValue, Class<T> 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 <tt>null</tt> 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 <tt>null</tt> if there is no variable for the given name or
* <tt>null</tt> if it cannot be converted to the given type
*/
- <T> T getVariable(String name, Class<T> type);
+ <T> @Nullable T getVariable(String name, Class<T> 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 <tt>defaultValue</tt> if there is no variable for the
* given name or <tt>null</tt> if it cannot be converted to the given type
*/
- <T> T getVariable(String name, Object defaultValue, Class<T> type);
+ <T> @Nullable T getVariable(String name, Object defaultValue, Class<T> 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 <tt>null</tt> 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 <tt>null</tt> if not possible to covert to given type
*/
- <T> T getMessage(Class<T> type);
+ <T> @Nullable T getMessage(Class<T> 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 <tt>null</tt> if not possible to covert to given type
*/
- <T> T getIn(Class<T> type);
+ <T> @Nullable T getIn(Class<T> 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> T getOut(Class<T> type);
+ <T> @Nullable T getOut(Class<T> 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 <tt>null</tt> if no caused exception matched)
*/
- <T> T getException(Class<T> type);
+ <T> @Nullable T getException(Class<T> 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()
* </pre>
*/
+ @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 <tt>fromRouteId<tt> 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 fa889c8a94ef..d0eef24268f0 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 java.util.Map;
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> T getInOrNull(Class<T> type);
+ <T> @Nullable T getInOrNull(Class<T> 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.
@@ -188,34 +191,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.
@@ -274,7 +280,7 @@ public interface ExchangeExtension {
*
* @see SafeCopyProperty
*/
- <T> T getSafeCopyProperty(String key, Class<T> type);
+ <T> @Nullable T getSafeCopyProperty(String key, Class<T> type);
/**
* To set a property that must be copied specially (thread safe with deep cloning).
@@ -308,6 +314,7 @@ public interface ExchangeExtension {
* <p>
* This is only used when pooled exchange is enabled for optimization and reducing object allocations.
*/
+ @Nullable
AsyncCallback getDefaultConsumerCallback();
/**
@@ -315,7 +322,7 @@ public interface ExchangeExtension {
* <p>
* 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 491a48f3a2d0..3710e67f5714 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 enum ExchangePropertyKey {
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/ExchangeTimedOutException.java b/core/camel-api/src/main/java/org/apache/camel/ExchangeTimedOutException.java
index dbf76b0fee35..34ea1de40e51 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/ExpectedBodyTypeException.java b/core/camel-api/src/main/java/org/apache/camel/ExpectedBodyTypeException.java
index ea5385db6f8e..99f03ca33acb 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,26 +16,30 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+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: "
- + exchange.getIn().getBody());
+ super("Could not extract IN message body as type: " + Objects.requireNonNull(expectedBodyType, "expectedBodyType")
+ + " body is: " + Objects.requireNonNull(exchange, "exchange").getIn().getBody());
this.exchange = exchange;
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/Expression.java b/core/camel-api/src/main/java/org/apache/camel/Expression.java
index 3a34cfeef019..072439160338 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 <a href="http://camel.apache.org/expression.html">expression</a> 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> T evaluate(Exchange exchange, Class<T> type);
+ <T> @Nullable T evaluate(Exchange exchange, Class<T> type);
/**
* Initialize the expression with the given camel context
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 6854ae7f9ad0..fc94214ca15b 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,39 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+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, @Nullable Exchange exchange,
+ @Nullable Throwable cause) {
super(cause);
this.expression = expression;
this.exchange = exchange;
}
- public ExpressionEvaluationException(Expression expression, String message, Exchange exchange, Throwable cause) {
- super(message, cause);
+ public ExpressionEvaluationException(
+ @Nullable Expression expression, String message, @Nullable Exchange exchange,
+ @Nullable Throwable cause) {
+ super(Objects.requireNonNull(message, "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/ExpressionIllegalSyntaxException.java b/core/camel-api/src/main/java/org/apache/camel/ExpressionIllegalSyntaxException.java
index 6102eda6c8de..2b9ab975d3e3 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,10 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+import org.jspecify.annotations.Nullable;
+
/**
* An exception thrown if the expression contains illegal syntax.
*/
@@ -27,8 +31,8 @@ public class ExpressionIllegalSyntaxException extends RuntimeCamelException {
this(expression, null);
}
- public ExpressionIllegalSyntaxException(String expression, Throwable cause) {
- super("Illegal syntax: " + expression, cause);
+ public ExpressionIllegalSyntaxException(String expression, @Nullable Throwable cause) {
+ super("Illegal syntax: " + Objects.requireNonNull(expression, "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 6d288d3f881a..685ad2006ca4 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.Registry;
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 @@ public interface ExtendedCamelContext {
*/
void setManagementMBeanAssembler(ManagementMBeanAssembler managementMBeanAssembler);
- default Registry getRegistry() {
+ default @Nullable Registry getRegistry() {
return null;
}
@@ -175,7 +176,7 @@ public interface ExtendedCamelContext {
* 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 @@ public interface ExtendedCamelContext {
* @return the route id currently being created/started, or <tt>null</tt> if not.
* @see #createRoute(String)
*/
+ @Nullable
String getCreateRoute();
/**
@@ -233,7 +235,7 @@ public interface ExtendedCamelContext {
* {@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 @@ public interface ExtendedCamelContext {
* @return the current id of the processor being created
* @see #createProcessor(String)
*/
+ @Nullable
String getCreateProcessor();
/**
@@ -336,6 +339,7 @@ public interface ExtendedCamelContext {
* @param uri the URI of the endpoint
* @return the registered endpoint or <tt>null</tt> if not registered
*/
+ @Nullable
Endpoint hasEndpoint(NormalizedEndpointUri uri);
/**
@@ -433,6 +437,7 @@ public interface ExtendedCamelContext {
*
* @return the builder
*/
+ @Nullable
ErrorHandlerFactory getErrorHandlerFactory();
/**
@@ -509,11 +514,12 @@ public interface ExtendedCamelContext {
*
* @param options optional parameters to configure {@link org.apache.camel.spi.ManagementAgent}.
*/
- void setupManagement(Map<String, Object> options);
+ void setupManagement(@Nullable Map<String, Object> options);
/**
* Gets a list of {@link LogListener} (can be null if empty).
*/
+ @Nullable
Set<LogListener> getLogListeners();
/**
@@ -577,13 +583,14 @@ public interface ExtendedCamelContext {
/**
* Gets the {@link EndpointUriFactory} for the given component name.
*/
+ @Nullable
EndpointUriFactory getEndpointUriFactory(String scheme);
/**
* Gets the {@link RuntimeCamelCatalog} if available on the classpath.
*/
@Deprecated(since = "4.0.0")
- default RuntimeCamelCatalog getRuntimeCamelCatalog() {
+ default @Nullable RuntimeCamelCatalog getRuntimeCamelCatalog() {
return getContextPlugin(RuntimeCamelCatalog.class);
}
@@ -615,6 +622,7 @@ public interface ExtendedCamelContext {
/**
* Used during unit-testing where it is possible to specify a set of routes to exclude from discovery
*/
+ @Nullable
String getTestExcludeRoutes();
/**
@@ -638,6 +646,7 @@ public interface ExtendedCamelContext {
*
* @return the base package name (can be null if not configured)
*/
+ @Nullable
String getBasePackageScan();
/**
@@ -647,7 +656,7 @@ public interface ExtendedCamelContext {
*
* @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 +664,7 @@ public interface ExtendedCamelContext {
*
* @see org.apache.camel.util.SensitiveUtils
*/
+ @Nullable
String getAdditionalSensitiveKeywords();
/**
@@ -663,7 +673,7 @@ public interface ExtendedCamelContext {
*
* @see org.apache.camel.util.SensitiveUtils
*/
- void setAdditionalSensitiveKeywords(String additionalSensitiveKeywords);
+ void setAdditionalSensitiveKeywords(@Nullable String additionalSensitiveKeywords);
/**
* Gets the {@link AutoMockInterceptStrategy} strategies.
@@ -682,7 +692,7 @@ public interface ExtendedCamelContext {
* @param type the type of the extension
* @return the extension, or <tt>null</tt> if no extension has been installed.
*/
- <T> T getContextPlugin(Class<T> type);
+ <T> @Nullable T getContextPlugin(Class<T> type);
/**
* Whether a plugin of the given type is already in use
diff --git a/core/camel-api/src/main/java/org/apache/camel/FailedToCreateConsumerException.java b/core/camel-api/src/main/java/org/apache/camel/FailedToCreateConsumerException.java
index f73a80c88e57..5729c29ff4db 100644
--- a/core/camel-api/src/main/java/org/apache/camel/FailedToCreateConsumerException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/FailedToCreateConsumerException.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
import static org.apache.camel.util.URISupport.sanitizeUri;
/**
@@ -26,22 +28,26 @@ public class FailedToCreateConsumerException extends RuntimeCamelException {
private final String uri;
public FailedToCreateConsumerException(String endpointURI, Throwable cause) {
- super("Failed to create Consumer for endpoint for: " + sanitizeUri(endpointURI) + ". Reason: " + cause, cause);
+ super("Failed to create Consumer for endpoint for: " + sanitizeUri(Objects.requireNonNull(endpointURI, "endpointURI"))
+ + ". Reason: " + Objects.requireNonNull(cause, "cause"), cause);
this.uri = sanitizeUri(endpointURI);
}
public FailedToCreateConsumerException(Endpoint endpoint, Throwable cause) {
- super("Failed to create Consumer for endpoint: " + endpoint + ". Reason: " + cause, cause);
+ super("Failed to create Consumer for endpoint: " + Objects.requireNonNull(endpoint, "endpoint") + ". Reason: "
+ + Objects.requireNonNull(cause, "cause"), cause);
this.uri = sanitizeUri(endpoint.getEndpointUri());
}
public FailedToCreateConsumerException(Endpoint endpoint, String message, Throwable cause) {
- super("Failed to create Consumer for endpoint: " + endpoint + ". Reason: " + message, cause);
+ super("Failed to create Consumer for endpoint: " + Objects.requireNonNull(endpoint, "endpoint") + ". Reason: "
+ + Objects.requireNonNull(message, "message"), Objects.requireNonNull(cause, "cause"));
this.uri = sanitizeUri(endpoint.getEndpointUri());
}
public FailedToCreateConsumerException(Endpoint endpoint, String message) {
- super("Failed to create Consumer for endpoint: " + endpoint + ". Reason: " + message);
+ super("Failed to create Consumer for endpoint: " + Objects.requireNonNull(endpoint, "endpoint") + ". Reason: "
+ + Objects.requireNonNull(message, "message"));
this.uri = sanitizeUri(endpoint.getEndpointUri());
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/FailedToCreateProducerException.java b/core/camel-api/src/main/java/org/apache/camel/FailedToCreateProducerException.java
index 6261b77edd6e..75fea0d24e4c 100644
--- a/core/camel-api/src/main/java/org/apache/camel/FailedToCreateProducerException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/FailedToCreateProducerException.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
import static org.apache.camel.util.URISupport.sanitizeUri;
/**
@@ -26,7 +28,8 @@ public class FailedToCreateProducerException extends RuntimeCamelException {
private final String uri;
public FailedToCreateProducerException(Endpoint endpoint, Throwable cause) {
- super("Failed to create Producer for endpoint: " + endpoint + ". Reason: " + cause, cause);
+ super("Failed to create Producer for endpoint: " + Objects.requireNonNull(endpoint, "endpoint") + ". Reason: "
+ + Objects.requireNonNull(cause, "cause"), cause);
this.uri = sanitizeUri(endpoint.getEndpointUri());
}
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 8c02ef9dcc09..4466edb7b792 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
@@ -16,58 +16,69 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
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);
+ super("Failed to create route because: " + Objects.requireNonNull(cause, "cause"));
this.routeId = null;
this.location = null;
}
- public FailedToCreateRouteException(String routeId, String location, String route, String cause) {
- super("Failed to create route: " + routeId + (location != null ? " (source: " + location + ")" : "") + ": "
- + getRouteMessage(route) + " because: " + cause);
+ public FailedToCreateRouteException(String routeId, @Nullable String location, String route, String cause) {
+ super("Failed to create route: " + Objects.requireNonNull(routeId, "routeId")
+ + (location != null ? " (source: " + location + ")" : "") + ": "
+ + getRouteMessage(Objects.requireNonNull(route, "route")) + " because: "
+ + Objects.requireNonNull(cause, "cause"));
this.routeId = routeId;
this.location = location;
}
- public FailedToCreateRouteException(String routeId, String location, String route, Throwable cause) {
- super("Failed to create route: " + routeId + (location != null ? " (source: " + location + ")" : "") + ": "
- + getRouteMessage(route) + " because: " + getExceptionMessage(cause),
+ public FailedToCreateRouteException(String routeId, @Nullable String location, String route, Throwable cause) {
+ super("Failed to create route: " + Objects.requireNonNull(routeId, "routeId")
+ + (location != null ? " (source: " + location + ")" : "") + ": "
+ + getRouteMessage(Objects.requireNonNull(route, "route")) + " because: "
+ + getExceptionMessage(Objects.requireNonNull(cause, "cause")),
cause);
this.routeId = routeId;
this.location = location;
}
- public FailedToCreateRouteException(String routeId, 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);
+ public FailedToCreateRouteException(String routeId, @Nullable String location, String route, String at, Throwable cause) {
+ super("Failed to create route: " + Objects.requireNonNull(routeId, "routeId")
+ + (location != null ? " (source: " + location + ")" : "") + " at: >>> "
+ + Objects.requireNonNull(at, "at")
+ + " <<< in route: " + getRouteMessage(Objects.requireNonNull(route, "route"))
+ + " because: " + getExceptionMessage(Objects.requireNonNull(cause, "cause")), cause);
this.routeId = routeId;
this.location = location;
}
- public String getRouteId() {
+ public @Nullable String getRouteId() {
return routeId;
}
- public String getLocation() {
+ public @Nullable String getLocation() {
return location;
}
protected static String getExceptionMessage(Throwable cause) {
+ Objects.requireNonNull(cause, "cause");
return cause.getMessage() != null ? cause.getMessage() : cause.getClass().getSimpleName();
}
protected static String getRouteMessage(String route) {
+ Objects.requireNonNull(route, "route");
// cut the route after 60 chars, so it won't be too big in the message
// users just need to be able to identify the route, so they know where to look
if (route.length() > 60) {
diff --git a/core/camel-api/src/main/java/org/apache/camel/FailedToCreateRouteFromTemplateException.java b/core/camel-api/src/main/java/org/apache/camel/FailedToCreateRouteFromTemplateException.java
index a95712acb593..8363b899da9b 100644
--- a/core/camel-api/src/main/java/org/apache/camel/FailedToCreateRouteFromTemplateException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/FailedToCreateRouteFromTemplateException.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
/**
* Exception when failing to create a {@link Route} from a RouteTemplateDefinition.
*/
@@ -24,13 +26,17 @@ public class FailedToCreateRouteFromTemplateException extends RuntimeCamelExcept
private final String routeId;
public FailedToCreateRouteFromTemplateException(String routeId, String templateId, String message) {
- super("Failed to create route " + routeId + " from template " + templateId + " because of " + message);
+ super("Failed to create route " + Objects.requireNonNull(routeId, "routeId") + " from template "
+ + Objects.requireNonNull(templateId, "templateId") + " because of "
+ + Objects.requireNonNull(message, "message"));
this.routeId = routeId;
this.templateId = templateId;
}
public FailedToCreateRouteFromTemplateException(String routeId, String templateId, String message, Throwable cause) {
- super("Failed to create route " + routeId + " from template " + templateId + " because of " + message, cause);
+ super("Failed to create route " + Objects.requireNonNull(routeId, "routeId") + " from template "
+ + Objects.requireNonNull(templateId, "templateId") + " because of "
+ + Objects.requireNonNull(message, "message"), Objects.requireNonNull(cause, "cause"));
this.routeId = routeId;
this.templateId = templateId;
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/FailedToStartComponentException.java b/core/camel-api/src/main/java/org/apache/camel/FailedToStartComponentException.java
index a8aad24a39f0..fc0f32d5f9ef 100644
--- a/core/camel-api/src/main/java/org/apache/camel/FailedToStartComponentException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/FailedToStartComponentException.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
/**
* Exception when failing to start a {@link Component}.
*/
@@ -24,7 +26,8 @@ public class FailedToStartComponentException extends RuntimeCamelException {
private final String componentName;
public FailedToStartComponentException(String componentName, String message, Throwable cause) {
- super("Failed to start component " + componentName + " because of " + message, cause);
+ super("Failed to start component " + Objects.requireNonNull(componentName, "componentName") + " because of "
+ + Objects.requireNonNull(message, "message"), Objects.requireNonNull(cause, "cause"));
this.componentName = componentName;
}
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 cf6a1976dedf..a4ce999487e2 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,30 +16,37 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+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);
+ super("Failed to start route: " + Objects.requireNonNull(routeId, "routeId") + " because: "
+ + Objects.requireNonNull(message, "message"));
this.routeId = routeId;
this.location = null;
}
public FailedToStartRouteException(String routeId, String message, Throwable cause) {
- super("Failed to start route: " + routeId + " because: " + message, cause);
+ super("Failed to start route: " + Objects.requireNonNull(routeId, "routeId") + " because: "
+ + Objects.requireNonNull(message, "message"), Objects.requireNonNull(cause, "cause"));
this.routeId = routeId;
this.location = null;
}
- public FailedToStartRouteException(String routeId, String location, String message, Throwable cause) {
- super("Failed to start route: " + routeId + (location != null ? " (source: " + location + ")" : "") + " because: "
- + message,
- cause);
+ public FailedToStartRouteException(String routeId, @Nullable String location, String message, Throwable cause) {
+ super("Failed to start route: " + Objects.requireNonNull(routeId, "routeId")
+ + (location != null ? " (source: " + location + ")" : "") + " because: "
+ + Objects.requireNonNull(message, "message"),
+ Objects.requireNonNull(cause, "cause"));
this.routeId = routeId;
this.location = location;
}
@@ -48,7 +55,7 @@ public class FailedToStartRouteException extends RuntimeCamelException {
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 cf0197e0897b..f44893115f81 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
@@ -22,6 +22,7 @@ import java.util.function.Consumer;
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}
@@ -129,6 +130,7 @@ public interface FluentProducerTemplate extends Service {
*
* @return the default endpoint instance
*/
+ @Nullable
Endpoint getDefaultEndpoint();
/**
@@ -190,7 +192,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
@@ -211,7 +213,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
@@ -232,7 +234,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
@@ -242,7 +244,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
@@ -253,7 +255,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.
@@ -403,6 +405,7 @@ public interface FluentProducerTemplate extends Service {
* @return the result
* @throws CamelExecutionException is thrown if error occurred
*/
+ @Nullable
Object request() throws CamelExecutionException;
/**
@@ -412,7 +415,7 @@ public interface FluentProducerTemplate extends Service {
* @return the result
* @throws CamelExecutionException is thrown if error occurred
*/
- <T> T request(Class<T> type) throws CamelExecutionException;
+ <T> @Nullable T request(Class<T> type) throws CamelExecutionException;
/**
* Sends asynchronously to the given endpoint (InOut).
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 127fc15313e5..88dd87c7c6a0 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,34 +16,41 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+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());
}
public InvalidPayloadException(Exchange exchange, Class<?> type, Message message) {
- super("No body available of type: " + type.getCanonicalName()
- + NoSuchPropertyException.valueDescription(message.getBody()) + " on: " + message, exchange);
+ super("No body available of type: " + Objects.requireNonNull(type, "type").getCanonicalName()
+ + NoSuchPropertyException.valueDescription(Objects.requireNonNull(message, "message").getBody())
+ + " on: " + message, Objects.requireNonNull(exchange, "exchange"));
this.type = type;
}
public InvalidPayloadException(Exchange exchange, Class<?> type, Message message, Throwable cause) {
- super("No body available of type: " + type.getCanonicalName()
- + NoSuchPropertyException.valueDescription(message.getBody()) + " on: " + message
- + ". Caused by: " + cause.getMessage(), exchange, cause);
+ super("No body available of type: " + Objects.requireNonNull(type, "type").getCanonicalName()
+ + NoSuchPropertyException.valueDescription(Objects.requireNonNull(message, "message").getBody())
+ + " on: " + message
+ + ". Caused by: " + Objects.requireNonNull(cause, "cause").getMessage(),
+ Objects.requireNonNull(exchange, "exchange"), cause);
this.type = type;
}
/**
* 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 fca39bb70595..e8d98614bd30 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,16 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+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());
@@ -32,22 +36,25 @@ public class InvalidPayloadRuntimeException extends RuntimeExchangeException {
}
public InvalidPayloadRuntimeException(Exchange exchange, Class<?> type, Message message) {
- super("No body available of type: " + type.getName()
- + NoSuchPropertyException.valueDescription(message.getBody()) + " on: " + message, exchange);
+ super("No body available of type: " + Objects.requireNonNull(type, "type").getName()
+ + NoSuchPropertyException.valueDescription(Objects.requireNonNull(message, "message").getBody())
+ + " on: " + message, Objects.requireNonNull(exchange, "exchange"));
this.type = type;
}
public InvalidPayloadRuntimeException(Exchange exchange, Class<?> type, Message message, Throwable cause) {
- super("No body available of type: " + type.getName()
- + NoSuchPropertyException.valueDescription(message.getBody()) + " on: " + message
- + ". Caused by: " + cause.getMessage(), exchange, cause);
+ super("No body available of type: " + Objects.requireNonNull(type, "type").getName()
+ + NoSuchPropertyException.valueDescription(Objects.requireNonNull(message, "message").getBody())
+ + " on: " + message
+ + ". Caused by: " + Objects.requireNonNull(cause, "cause").getMessage(),
+ Objects.requireNonNull(exchange, "exchange"), cause);
this.type = type;
}
/**
* 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/InvalidPropertyException.java b/core/camel-api/src/main/java/org/apache/camel/InvalidPropertyException.java
index 490f81618b2a..20055b2fc214 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,20 +16,25 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+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);
}
- public InvalidPropertyException(Object owner, String propertyName, Class<?> type) {
- super("No '" + propertyName + "' property available on type: " + type.getName() + " in: " + owner);
+ public InvalidPropertyException(@Nullable Object owner, String propertyName, Class<?> type) {
+ super("No '" + Objects.requireNonNull(propertyName, "propertyName") + "' property available on type: "
+ + Objects.requireNonNull(type, "type").getName() + " in: " + owner);
this.owner = owner;
this.propertyName = propertyName;
}
@@ -38,7 +43,7 @@ public class InvalidPropertyException extends RuntimeCamelException {
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 e917848ea09f..b227b7b2d894 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> T trySetLineNumberAware(T object, LineNumberAware source) {
+ static <T> 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/LoadPropertiesException.java b/core/camel-api/src/main/java/org/apache/camel/LoadPropertiesException.java
index 33c2c2c0017b..b86a084f6ad3 100644
--- a/core/camel-api/src/main/java/org/apache/camel/LoadPropertiesException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/LoadPropertiesException.java
@@ -17,6 +17,7 @@
package org.apache.camel;
import java.net.URL;
+import java.util.Objects;
/**
* Represents a failure to open a Properties file at a given URL
@@ -26,7 +27,8 @@ public class LoadPropertiesException extends CamelException {
private final URL url;
public LoadPropertiesException(URL url, Exception cause) {
- super("Failed to load URL: " + url + ". Reason: " + cause, cause);
+ super("Failed to load URL: " + Objects.requireNonNull(url, "url") + ". Reason: "
+ + Objects.requireNonNull(cause, "cause"), cause);
this.url = url;
}
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 9bdd1bb1e753..747915cd2077 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 java.util.function.Supplier;
import org.apache.camel.spi.HeadersMapFactory;
import org.apache.camel.trait.message.MessageTrait;
+import org.jspecify.annotations.Nullable;
/**
* Implements the <a href="http://camel.apache.org/message.html">Message</a> pattern and represents an inbound or
@@ -90,6 +91,7 @@ public interface Message {
*
* @return the exchange
*/
+ @Nullable
Exchange getExchange();
/**
@@ -98,6 +100,7 @@ public interface Message {
* @param name name of header
* @return the value of the given header or <tt>null</tt> if there is no header for the given name
*/
+ @Nullable
Object getHeader(String name);
/**
@@ -129,7 +132,7 @@ public interface Message {
* given name
* @throws TypeConversionException is thrown if error during type conversion
*/
- <T> T getHeader(String name, Class<T> type);
+ <T> @Nullable T getHeader(String name, Class<T> type);
/**
* Returns a header associated with this message by name and specifying the type required
@@ -140,7 +143,7 @@ public interface Message {
* @return the value of the given header or <tt>defaultValue</tt> if there is no header for the given
* name or <tt>null</tt> if it cannot be converted to the given type
*/
- <T> T getHeader(String name, Object defaultValue, Class<T> type);
+ <T> @Nullable T getHeader(String name, Object defaultValue, Class<T> type);
/**
* Returns a header associated with this message by name and specifying the type required
@@ -152,7 +155,7 @@ public interface Message {
* <tt>defaultValueSupplier</tt> if there is no header for the given name or
* <tt>null</tt> if it cannot be converted to the given type
*/
- <T> T getHeader(String name, Supplier<Object> defaultValueSupplier, Class<T> type);
+ <T> @Nullable T getHeader(String name, Supplier<Object> defaultValueSupplier, Class<T> type);
/**
* Sets a header on the message
@@ -160,7 +163,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 +171,7 @@ public interface Message {
* @param name name of the header
* @return the old value of the header
*/
+ @Nullable
Object removeHeader(String name);
/**
@@ -232,6 +236,7 @@ public interface Message {
*
* @return the body, can be <tt>null</tt>
*/
+ @Nullable
Object getBody();
/**
@@ -264,7 +269,7 @@ public interface Message {
* @see org.apache.camel.support.ExchangeHelper#getBodyAndResetStreamCache(Exchange,
* Class)
*/
- <T> T getBody(Class<T> type);
+ <T> @Nullable T getBody(Class<T> type);
/**
* Returns the mandatory body as the specified type
@@ -290,7 +295,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 +303,7 @@ public interface Message {
* @param body the body
* @param type the type of the body
*/
- <T> void setBody(Object body, Class<T> type);
+ <T> void setBody(@Nullable Object body, Class<T> type);
/**
* Creates a copy of this message so that it can be used and possibly modified further in another exchange.
@@ -334,7 +339,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 +355,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 b576d59d30dd..46a4fd60a431 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 @@ public interface MessageHistory {
/**
* 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 2d3cc4bd801b..455c500a66dd 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
@@ -19,6 +19,8 @@ package org.apache.camel;
import java.util.Collections;
import java.util.List;
+import org.jspecify.annotations.Nullable;
+
/**
* Represents a node in the {@link org.apache.camel.model routes} which is identified by an id.
*/
@@ -32,6 +34,7 @@ public interface NamedNode extends LineNumberAware {
/**
* Gets the node prefix id.
*/
+ @Nullable
String getNodePrefixId();
/**
@@ -50,11 +53,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 @@ public interface NamedNode extends LineNumberAware {
return level;
}
- default String getParentId() {
+ default @Nullable String getParentId() {
NamedNode node = this;
if (node.getParent() != null) {
return node.getParent().getId();
@@ -103,14 +108,14 @@ public interface NamedNode extends LineNumberAware {
/**
* 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 017123bab68a..af456158f5b7 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
@@ -17,6 +17,7 @@
package org.apache.camel;
import org.apache.camel.spi.Resource;
+import org.jspecify.annotations.Nullable;
/**
* Represents a node in the {@link org.apache.camel.model routes} which is identified as a route.
@@ -36,6 +37,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 8d77f020704d..1ca04654ac1c 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 @@ package org.apache.camel;
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 <tt>T</tt> that can contain <tt>0..n</tt> nodes.
@@ -32,6 +34,7 @@ public interface Navigate<T> {
*
* @return next group or <tt>null</tt> if no more outputs
*/
+ @Nullable
List<T> next();
/**
diff --git a/core/camel-api/src/main/java/org/apache/camel/NoFactoryAvailableException.java b/core/camel-api/src/main/java/org/apache/camel/NoFactoryAvailableException.java
index ec42b21f11f0..a002b0749b4f 100644
--- a/core/camel-api/src/main/java/org/apache/camel/NoFactoryAvailableException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/NoFactoryAvailableException.java
@@ -17,6 +17,7 @@
package org.apache.camel;
import java.io.IOException;
+import java.util.Objects;
/**
* Thrown if no factory resource is available for the given URI
@@ -26,13 +27,13 @@ public class NoFactoryAvailableException extends IOException {
private final String uri;
public NoFactoryAvailableException(String uri) {
- super("Cannot find factory class for resource: " + uri);
+ super("Cannot find factory class for resource: " + Objects.requireNonNull(uri, "uri"));
this.uri = uri;
}
public NoFactoryAvailableException(String uri, Throwable cause) {
this(uri);
- initCause(cause);
+ initCause(Objects.requireNonNull(cause, "cause"));
}
public String getUri() {
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 42bc3053d8df..df06a1e50476 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,41 +16,48 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+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);
+ super("No bean could be found in the registry for: " + Objects.requireNonNull(name, "name"));
this.name = name;
}
public NoSuchBeanException(String name, int size) {
super(size > 0
- ? "Found " + size + " beans for: " + name + " in the registry, only 1 bean excepted."
+ ? "Found " + size + " beans for: " + Objects.requireNonNull(name, "name")
+ + " in the registry, only 1 bean excepted."
: "No bean could be found in the registry for: " + name);
this.name = name;
}
- public NoSuchBeanException(String name, String type) {
- super("No bean could be found in the registry" + (name != null ? " for: " + name : "") + " of type: " + type);
+ public NoSuchBeanException(@Nullable String name, String type) {
+ super("No bean could be found in the registry" + (name != null ? " for: " + name : "") + " of type: "
+ + Objects.requireNonNull(type, "type"));
this.name = name;
}
public NoSuchBeanException(String name, Throwable cause) {
- super("No bean could be found in the registry for: " + name + ". Cause: " + cause.getMessage(), cause);
+ super("No bean could be found in the registry for: " + Objects.requireNonNull(name, "name") + ". Cause: "
+ + Objects.requireNonNull(cause, "cause").getMessage(), cause);
this.name = name;
}
public NoSuchBeanException(String name, String message, Throwable cause) {
- super(message, cause);
- this.name = name;
+ super(Objects.requireNonNull(message, "message"), Objects.requireNonNull(cause, "cause"));
+ this.name = Objects.requireNonNull(name, "name");
}
- public String getName() {
+ public @Nullable String getName() {
return name;
}
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/NoSuchBeanTypeException.java b/core/camel-api/src/main/java/org/apache/camel/NoSuchBeanTypeException.java
index cc791e982129..b810495f9399 100644
--- a/core/camel-api/src/main/java/org/apache/camel/NoSuchBeanTypeException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/NoSuchBeanTypeException.java
@@ -16,17 +16,19 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
/**
* A runtime exception if a given bean type could not be found in the {@link org.apache.camel.spi.Registry}
*/
public class NoSuchBeanTypeException extends NoSuchBeanException {
public NoSuchBeanTypeException(Class<?> type) {
- super(type.getName());
+ super(Objects.requireNonNull(type, "type").getName());
}
public NoSuchBeanTypeException(Class<?> type, int size) {
- super(type.getName(), size);
+ super(Objects.requireNonNull(type, "type").getName(), size);
}
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/NoSuchEndpointException.java b/core/camel-api/src/main/java/org/apache/camel/NoSuchEndpointException.java
index ca82a92ddf75..07672e9440c2 100644
--- a/core/camel-api/src/main/java/org/apache/camel/NoSuchEndpointException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/NoSuchEndpointException.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
import static org.apache.camel.util.URISupport.sanitizeUri;
/**
@@ -27,14 +29,14 @@ public class NoSuchEndpointException extends RuntimeCamelException {
private final String uri;
public NoSuchEndpointException(String uri) {
- super("No endpoint could be found for: " + sanitizeUri(uri)
+ super("No endpoint could be found for: " + sanitizeUri(Objects.requireNonNull(uri, "uri"))
+ ", please check your classpath contains the needed Camel component jar.");
this.uri = sanitizeUri(uri);
}
public NoSuchEndpointException(String uri, String resolveMethod) {
- super("No endpoint could be found for: " + sanitizeUri(uri)
- + ", please " + resolveMethod);
+ super("No endpoint could be found for: " + sanitizeUri(Objects.requireNonNull(uri, "uri"))
+ + ", please " + Objects.requireNonNull(resolveMethod, "resolveMethod"));
this.uri = sanitizeUri(uri);
}
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 b3bdfd5d8a05..a10335113893 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,10 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+import org.jspecify.annotations.Nullable;
+
/**
* An exception caused when a mandatory header is not available on a message {@link Exchange}
*
@@ -24,17 +28,18 @@ package org.apache.camel;
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);
- this.headerName = headerName;
+ super(Objects.requireNonNull(message, "message"), Objects.requireNonNull(exchange, "exchange"));
+ this.headerName = Objects.requireNonNull(headerName, "headerName");
this.type = null;
}
- public NoSuchHeaderException(Exchange exchange, String headerName, Class<?> type) {
- super("No '" + headerName + "' header available" + (type != null ? " of type: " + type.getName() : "")
- + reason(exchange, headerName), exchange);
+ public NoSuchHeaderException(Exchange exchange, String headerName, @Nullable Class<?> type) {
+ super("No '" + Objects.requireNonNull(headerName, "headerName") + "' header available"
+ + (type != null ? " of type: " + type.getName() : "")
+ + reason(Objects.requireNonNull(exchange, "exchange"), headerName), exchange);
this.headerName = headerName;
this.type = type;
}
@@ -43,16 +48,18 @@ public class NoSuchHeaderException extends CamelExchangeException {
return headerName;
}
- public Class<?> getType() {
+ public @Nullable Class<?> getType() {
return type;
}
protected static String reason(Exchange exchange, String headerName) {
+ Objects.requireNonNull(exchange, "exchange");
+ Objects.requireNonNull(headerName, "headerName");
Object value = exchange.getMessage().getHeader(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 54798a82dd90..6b6c22fe8d59 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,10 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+import org.jspecify.annotations.Nullable;
+
public class NoSuchHeaderOrPropertyException extends CamelExchangeException {
private final String headerName;
@@ -25,10 +29,10 @@ public class NoSuchHeaderOrPropertyException extends CamelExchangeException {
public NoSuchHeaderOrPropertyException(Exchange exchange, String headerName, String propertyName, Class<?> type) {
super(String.format(
"No '%s' header or '%s' property available of type: %s (header: %s, property: %s)",
- headerName,
- propertyName,
- type.getName(),
- header(exchange, headerName),
+ Objects.requireNonNull(headerName, "headerName"),
+ Objects.requireNonNull(propertyName, "propertyName"),
+ Objects.requireNonNull(type, "type").getName(),
+ header(Objects.requireNonNull(exchange, "exchange"), headerName),
property(exchange, headerName)),
exchange);
@@ -50,16 +54,20 @@ public class NoSuchHeaderOrPropertyException extends CamelExchangeException {
}
protected static String header(Exchange exchange, String headerName) {
+ Objects.requireNonNull(exchange, "exchange");
+ Objects.requireNonNull(headerName, "headerName");
Object value = exchange.getMessage().getHeader(headerName);
return valueDescription(value);
}
protected static String property(Exchange exchange, String propertyName) {
+ Objects.requireNonNull(exchange, "exchange");
+ Objects.requireNonNull(propertyName, "propertyName");
Object value = exchange.getProperty(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/NoSuchLanguageException.java b/core/camel-api/src/main/java/org/apache/camel/NoSuchLanguageException.java
index 9762feeac19c..791f8647856a 100644
--- a/core/camel-api/src/main/java/org/apache/camel/NoSuchLanguageException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/NoSuchLanguageException.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
/**
* A runtime exception thrown if an attempt is made to resolve an unknown language definition.
*
@@ -26,7 +28,7 @@ public class NoSuchLanguageException extends RuntimeCamelException {
private final String language;
public NoSuchLanguageException(String language) {
- super("No language could be found for: " + language);
+ super("No language could be found for: " + Objects.requireNonNull(language, "language"));
this.language = language;
}
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 30a242ed51b5..2c43a3383926 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,10 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+import org.jspecify.annotations.Nullable;
+
/**
* An exception caused when a mandatory property is not available on a message {@link Exchange}
*
@@ -24,15 +28,16 @@ package org.apache.camel;
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) {
- super("No '" + propertyName + "' exchange property available" + (type != null ? " of type: " + type.getName() : "")
- + reason(exchange, propertyName), exchange);
+ public NoSuchPropertyException(Exchange exchange, String propertyName, @Nullable Class<?> type) {
+ super("No '" + Objects.requireNonNull(propertyName, "propertyName") + "' exchange property available"
+ + (type != null ? " of type: " + type.getName() : "")
+ + reason(Objects.requireNonNull(exchange, "exchange"), propertyName), exchange);
this.propertyName = propertyName;
this.type = type;
}
@@ -41,16 +46,18 @@ public class NoSuchPropertyException extends CamelExchangeException {
return propertyName;
}
- public Class<?> getType() {
+ public @Nullable Class<?> getType() {
return type;
}
protected static String reason(Exchange exchange, String propertyName) {
+ Objects.requireNonNull(exchange, "exchange");
+ Objects.requireNonNull(propertyName, "propertyName");
Object value = exchange.getProperty(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/NoSuchServiceException.java b/core/camel-api/src/main/java/org/apache/camel/NoSuchServiceException.java
index 9d6cd80a4d95..31155569e7f2 100644
--- a/core/camel-api/src/main/java/org/apache/camel/NoSuchServiceException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/NoSuchServiceException.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
/**
* A runtime exception if a given service could not be found in the classpath
*/
@@ -25,7 +27,8 @@ public class NoSuchServiceException extends RuntimeCamelException {
private final String jar;
public NoSuchServiceException(String name, String jar) {
- super("No " + name + " service could be found in the classpath. Add " + jar + " to classpath.");
+ super("No " + Objects.requireNonNull(name, "name") + " service could be found in the classpath. Add "
+ + Objects.requireNonNull(jar, "jar") + " to classpath.");
this.name = name;
this.jar = jar;
}
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 25dc319d8b44..5ec38ff4cbb3 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,18 +16,22 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+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(
- "No '%s' variable available", variableName),
- exchange);
+ "No '%s' variable available", Objects.requireNonNull(variableName, "variableName")),
+ Objects.requireNonNull(exchange, "exchange"));
this.variableName = variableName;
this.type = null;
}
@@ -35,9 +39,9 @@ public class NoSuchVariableException extends CamelExchangeException {
public NoSuchVariableException(Exchange exchange, String variableName, Class<?> type) {
super(String.format(
"No '%s' variable available of type: %s",
- variableName,
- type.getName()),
- exchange);
+ Objects.requireNonNull(variableName, "variableName"),
+ Objects.requireNonNull(type, "type").getName()),
+ Objects.requireNonNull(exchange, "exchange"));
this.variableName = variableName;
this.type = type;
}
@@ -46,7 +50,7 @@ public class NoSuchVariableException extends CamelExchangeException {
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 824d4e26fd17..46af2a9f72a1 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,22 +16,26 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+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) {
- super(createMessage(value, type));
+ public NoTypeConversionAvailableException(@Nullable Object value, Class<?> type) {
+ super(createMessage(value, Objects.requireNonNull(type, "type")));
this.value = value;
this.type = type;
}
- public NoTypeConversionAvailableException(Object value, Class<?> type, Throwable cause) {
- super(createMessage(value, type, cause), cause);
+ public NoTypeConversionAvailableException(@Nullable Object value, Class<?> type, Throwable cause) {
+ super(createMessage(value, Objects.requireNonNull(type, "type"), Objects.requireNonNull(cause, "cause")), cause);
this.value = value;
this.type = type;
}
@@ -39,7 +43,7 @@ public class NoTypeConversionAvailableException extends CamelException {
/**
* Returns the value which could not be converted
*/
- public Object getValue() {
+ public @Nullable Object getValue() {
return value;
}
@@ -53,7 +57,7 @@ public class NoTypeConversionAvailableException extends CamelException {
/**
* Returns the required <tt>from</tt> type. Returns <tt>null</tt> if the provided value was null.
*/
- public Class<?> getFromType() {
+ public @Nullable Class<?> getFromType() {
if (value != null) {
return value.getClass();
} else {
@@ -64,7 +68,8 @@ public class NoTypeConversionAvailableException extends CamelException {
/**
* 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) {
+ Objects.requireNonNull(type, "type");
return "No type converter available to convert from type: "
+ (value != null ? value.getClass().getCanonicalName() : null)
+ " to the required type: " + type.getCanonicalName();
@@ -73,7 +78,9 @@ public class NoTypeConversionAvailableException extends CamelException {
/**
* 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) {
+ Objects.requireNonNull(type, "type");
+ Objects.requireNonNull(cause, "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 5964f1e61115..92589494f820 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 <a href="http://camel.apache.org/polling-consumer.html">Polling Consumer</a> 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 <tt>null</tt>
*/
+ @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 <tt>null</tt> 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 22c5e761800f..ffec2a1c9621 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.Future;
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}.
* <br/>
@@ -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 <tt>null</tt>
* @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 <tt>null</tt>
* @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 <tt>null</tt>
* @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 @@ public interface ProducerTemplate extends Service {
* @return the result if {@link ExchangePattern} is OUT capable, otherwise <tt>null</tt>
* @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 @@ public interface ProducerTemplate extends Service {
* @return the result if {@link ExchangePattern} is OUT capable, otherwise <tt>null</tt>
* @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 @@ public interface ProducerTemplate extends Service {
* @return the result if {@link ExchangePattern} is OUT capable, otherwise <tt>null</tt>
* @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 @@ public interface ProducerTemplate extends Service {
* @return the result if {@link ExchangePattern} is OUT capable, otherwise <tt>null</tt>
* @throws CamelExecutionException if the processing of the exchange failed
*/
+ @Nullable
Object sendBodyAndHeaders(
String endpointUri, ExchangePattern pattern, Object body,
Map<String, Object> headers)
@@ -604,6 +614,7 @@ public interface ProducerTemplate extends Service {
* @return the result if {@link ExchangePattern} is OUT capable, otherwise <tt>null</tt>
* @throws CamelExecutionException if the processing of the exchange failed
*/
+ @Nullable
Object sendBodyAndHeaders(
Endpoint endpoint, ExchangePattern pattern, Object body,
Map<String, Object> headers)
@@ -652,6 +663,7 @@ public interface ProducerTemplate extends Service {
* @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 @@ public interface ProducerTemplate extends Service {
* @return the result (see class javadoc)
* @throws CamelExecutionException if the processing of the exchange failed
*/
- <T> T requestBody(Object body, Class<T> type) throws CamelExecutionException;
+ <T> @Nullable T requestBody(Object body, Class<T> type) throws CamelExecutionException;
/**
* Send the body to an endpoint returning any result output body. Uses an {@link ExchangePattern#InOut} message
@@ -682,6 +694,7 @@ public interface ProducerTemplate extends Service {
* @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 @@ public interface ProducerTemplate extends Service {
* @return the result (see class javadoc)
* @throws CamelExecutionException if the processing of the exchange failed
*/
- <T> T requestBody(Endpoint endpoint, Object body, Class<T> type) throws CamelExecutionException;
+ <T> @Nullable T requestBody(Endpoint endpoint, Object body, Class<T> type) throws CamelExecutionException;
/**
* Send the body to an endpoint returning any result output body. Uses an {@link ExchangePattern#InOut} message
@@ -713,6 +726,7 @@ public interface ProducerTemplate extends Service {
* @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 @@ public interface ProducerTemplate extends Service {
* @return the result (see class javadoc)
* @throws CamelExecutionException if the processing of the exchange failed
*/
- <T> T requestBody(String endpointUri, Object body, Class<T> type) throws CamelExecutionException;
+ <T> @Nullable T requestBody(String endpointUri, Object body, Class<T> type) throws CamelExecutionException;
/**
* Sends the body to the default endpoint and returns the result content Uses an {@link ExchangePattern#InOut}
@@ -745,6 +759,7 @@ public interface ProducerTemplate extends Service {
* @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 @@ public interface ProducerTemplate extends Service {
* @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 @@ public interface ProducerTemplate extends Service {
* @return the result (see class javadoc)
* @throws CamelExecutionException if the processing of the exchange failed
*/
- <T> T requestBodyAndHeader(Endpoint endpoint, Object body, String header, Object headerValue, Class<T> type)
+ <T> @Nullable T requestBodyAndHeader(Endpoint endpoint, Object body, String header, Object headerValue, Class<T> type)
throws CamelExecutionException;
/**
@@ -799,6 +815,7 @@ public interface ProducerTemplate extends Service {
* @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 @@ public interface ProducerTemplate extends Service {
* @return the result (see class javadoc)
* @throws CamelExecutionException if the processing of the exchange failed
*/
- <T> T requestBodyAndHeader(String endpointUri, Object body, String header, Object headerValue, Class<T> type)
+ <T> @Nullable T requestBodyAndHeader(String endpointUri, Object body, String header, Object headerValue, Class<T> type)
throws CamelExecutionException;
/**
@@ -835,6 +852,7 @@ public interface ProducerTemplate extends Service {
* @return the result (see class javadoc)
* @throws CamelExecutionException if the processing of the exchange failed
*/
+ @Nullable
Object requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) throws CamelExecutionException;
/**
@@ -852,7 +870,7 @@ public interface ProducerTemplate extends Service {
* @return the result (see class javadoc)
* @throws CamelExecutionException if the processing of the exchange failed
*/
- <T> T requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers, Class<T> type)
+ <T> @Nullable T requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers, Class<T> type)
throws CamelExecutionException;
/**
@@ -869,6 +887,7 @@ public interface ProducerTemplate extends Service {
* @return the result (see class javadoc)
* @throws CamelExecutionException if the processing of the exchange failed
*/
+ @Nullable
Object requestBodyAndHeaders(Endpoint endpoint, Object body, Map<String, Object> headers) throws CamelExecutionException;
/**
@@ -884,6 +903,7 @@ public interface ProducerTemplate extends Service {
* @return the result (see class javadoc)
* @throws CamelExecutionException if the processing of the exchange failed
*/
+ @Nullable
Object requestBodyAndHeaders(Object body, Map<String, Object> headers) throws CamelExecutionException;
/**
@@ -901,7 +921,7 @@ public interface ProducerTemplate extends Service {
* @return the result (see class javadoc)
* @throws CamelExecutionException if the processing of the exchange failed
*/
- <T> T requestBodyAndHeaders(Endpoint endpoint, Object body, Map<String, Object> headers, Class<T> type)
+ <T> @Nullable T requestBodyAndHeaders(Endpoint endpoint, Object body, Map<String, Object> headers, Class<T> type)
throws CamelExecutionException;
// Asynchronous methods
@@ -1119,7 +1139,7 @@ public interface ProducerTemplate extends Service {
* @return the result (see class javadoc)
* @throws CamelExecutionException if the processing of the exchange failed
*/
- <T> T extractFutureBody(Future<?> future, Class<T> type) throws CamelExecutionException;
+ <T> @Nullable T extractFutureBody(Future<?> future, Class<T> 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 @@ public interface ProducerTemplate extends Service {
* @throws java.util.concurrent.TimeoutException if the wait timed out
* @throws CamelExecutionException if the processing of the exchange failed
*/
- <T> T extractFutureBody(Future<?> future, long timeout, TimeUnit unit, Class<T> type)
+ <T> @Nullable T extractFutureBody(Future<?> future, long timeout, TimeUnit unit, Class<T> 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 1c9c4c158af1..4c2dcfcd4ef6 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 ce6020e82497..2a1875a3b5c2 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,28 +16,32 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+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) {
- this.target = target;
+ public PropertyBindingException(Object target, @Nullable String propertyName, @Nullable Object value) {
+ this.target = Objects.requireNonNull(target, "target");
this.propertyName = propertyName;
this.value = value;
this.optionPrefix = null;
this.optionKey = null;
}
- public PropertyBindingException(Object target, String propertyName, Object value, Throwable e) {
- initCause(e);
- this.target = target;
+ public PropertyBindingException(Object target, @Nullable String propertyName, @Nullable Object value, Throwable e) {
+ initCause(Objects.requireNonNull(e, "e"));
+ this.target = Objects.requireNonNull(target, "target");
this.propertyName = propertyName;
this.value = value;
this.optionPrefix = null;
@@ -45,18 +49,18 @@ public class PropertyBindingException extends RuntimeCamelException {
}
public PropertyBindingException(Object target, Throwable e) {
- initCause(e);
- this.target = target;
+ initCause(Objects.requireNonNull(e, "e"));
+ this.target = Objects.requireNonNull(target, "target");
this.propertyName = null;
this.value = null;
this.optionPrefix = null;
this.optionKey = null;
}
- public PropertyBindingException(Object target, String propertyName, Object value, String optionPrefix, String optionKey,
- Throwable e) {
- initCause(e);
- this.target = target;
+ public PropertyBindingException(Object target, @Nullable String propertyName, @Nullable Object value,
+ @Nullable String optionPrefix, @Nullable String optionKey, Throwable e) {
+ initCause(Objects.requireNonNull(e, "e"));
+ this.target = Objects.requireNonNull(target, "target");
this.propertyName = propertyName;
this.value = value;
this.optionPrefix = optionPrefix;
@@ -82,19 +86,19 @@ public class PropertyBindingException extends RuntimeCamelException {
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/ProxyInstantiationException.java b/core/camel-api/src/main/java/org/apache/camel/ProxyInstantiationException.java
index 26858cee47c8..c96e230682d1 100644
--- a/core/camel-api/src/main/java/org/apache/camel/ProxyInstantiationException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ProxyInstantiationException.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
/**
* Exception indicating a failure while trying to create a proxy of a given type and on a given endpoint
*/
@@ -25,7 +27,8 @@ public class ProxyInstantiationException extends RuntimeCamelException {
private final Endpoint endpoint;
public ProxyInstantiationException(Class<?> type, Endpoint endpoint, Throwable cause) {
- super("Could not instantiate proxy of type " + type.getName() + " on endpoint " + endpoint, cause);
+ super("Could not instantiate proxy of type " + Objects.requireNonNull(type, "type").getName() + " on endpoint "
+ + Objects.requireNonNull(endpoint, "endpoint"), Objects.requireNonNull(cause, "cause"));
this.type = type;
this.endpoint = endpoint;
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java b/core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java
index a03678fcb952..a5df127cb543 100644
--- a/core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ResolveEndpointFailedException.java
@@ -16,6 +16,10 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+import org.jspecify.annotations.Nullable;
+
import static org.apache.camel.util.URISupport.sanitizeUri;
/**
@@ -23,24 +27,26 @@ import static org.apache.camel.util.URISupport.sanitizeUri;
*/
public class ResolveEndpointFailedException extends RuntimeCamelException {
- private final String uri;
+ private final @Nullable String uri;
- public ResolveEndpointFailedException(String uri, Throwable cause) {
- super("Failed to resolve endpoint: " + sanitizeUri(uri) + " due to: " + cause.getMessage(), cause);
+ public ResolveEndpointFailedException(@Nullable String uri, Throwable cause) {
+ super("Failed to resolve endpoint: " + sanitizeUri(uri) + " due to: "
+ + Objects.requireNonNull(cause, "cause").getMessage(), cause);
this.uri = sanitizeUri(uri);
}
- public ResolveEndpointFailedException(String uri, String message) {
- super("Failed to resolve endpoint: " + sanitizeUri(uri) + " due to: " + message);
+ public ResolveEndpointFailedException(@Nullable String uri, String message) {
+ super("Failed to resolve endpoint: " + sanitizeUri(uri) + " due to: "
+ + Objects.requireNonNull(message, "message"));
this.uri = sanitizeUri(uri);
}
- public ResolveEndpointFailedException(String uri) {
+ public ResolveEndpointFailedException(@Nullable String uri) {
super("Failed to resolve endpoint: " + sanitizeUri(uri));
this.uri = sanitizeUri(uri);
}
- public String getUri() {
+ public @Nullable String getUri() {
return uri;
}
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/RollbackExchangeException.java b/core/camel-api/src/main/java/org/apache/camel/RollbackExchangeException.java
index e4b7feb46f82..abb24b240d15 100644
--- a/core/camel-api/src/main/java/org/apache/camel/RollbackExchangeException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/RollbackExchangeException.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
/**
* Exception used for forcing an Exchange to be rolled back.
*/
@@ -30,10 +32,11 @@ public class RollbackExchangeException extends CamelExchangeException {
}
public RollbackExchangeException(String message, Exchange exchange) {
- super(message, exchange);
+ super(Objects.requireNonNull(message, "message"), Objects.requireNonNull(exchange, "exchange"));
}
public RollbackExchangeException(String message, Exchange exchange, Throwable cause) {
- super(message, exchange, cause);
+ super(Objects.requireNonNull(message, "message"), Objects.requireNonNull(exchange, "exchange"),
+ Objects.requireNonNull(cause, "cause"));
}
}
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 dfc1c7eaace4..d25f2c51152d 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.Resource;
import org.apache.camel.spi.RouteController;
import org.apache.camel.spi.RouteError;
import org.apache.camel.spi.RoutePolicy;
+import org.jspecify.annotations.Nullable;
/**
* A <a href="http://camel.apache.org/routes.html">Route</a> 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 <tt>null</tt> if no description has been configured.
*/
+ @Nullable
String getDescription();
/**
@@ -157,6 +161,7 @@ public interface Route extends RuntimeConfiguration {
*
* @return the note, or <tt>null</tt> if no note has been configured.
*/
+ @Nullable
String getNote();
/**
@@ -167,6 +172,7 @@ public interface Route extends RuntimeConfiguration {
*
* @return the configuration, or <tt>null</tt> 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();
/**
@@ -234,6 +243,7 @@ public interface Route extends RuntimeConfiguration {
*
* @return a navigator for {@link Processor}.
*/
+ @Nullable
Navigate<Processor> navigate();
/**
@@ -258,6 +268,7 @@ public interface Route extends RuntimeConfiguration {
*
* @return the error or <tt>null</tt> if no error
*/
+ @Nullable
RouteError getLastError();
/**
@@ -269,17 +280,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 +333,13 @@ public interface Route extends RuntimeConfiguration {
/**
* Gets the route description
*/
+ @Nullable
String getRouteDescription();
/**
* Gets the route note
*/
+ @Nullable
String getRouteNote();
/**
@@ -335,6 +349,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 +388,7 @@ public interface Route extends RuntimeConfiguration {
*
* @return the managed intercept strategy, or <tt>null</tt> if not managed
*/
+ @Nullable
ManagementInterceptStrategy getManagementInterceptStrategy();
/**
@@ -398,6 +414,7 @@ public interface Route extends RuntimeConfiguration {
Collection<Processor> 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/RouteAware.java b/core/camel-api/src/main/java/org/apache/camel/RouteAware.java
index 1aa7b5b5f65c..953c1793dd0f 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 <tt>null</tt> 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 75d3c46ac28b..ab87cc331acb 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 java.util.function.Supplier;
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 @@ public interface RouteTemplateContext extends HasCamelContext {
* @param name name of property
* @return the property value or <tt>null</tt> if no property exists
*/
+ @Nullable
Object getProperty(String name);
/**
@@ -117,6 +119,7 @@ public interface RouteTemplateContext extends HasCamelContext {
* @param name name of property
* @return the property value or <tt>null</tt> if no property exists
*/
+ @Nullable
Object getEnvironmentVariable(String name);
/**
@@ -127,7 +130,7 @@ public interface RouteTemplateContext extends HasCamelContext {
* @return the property value or <tt>null</tt> if no property exists
* @throws TypeConversionException is thrown if error during type conversion
*/
- <T> T getProperty(String name, Class<?> type);
+ <T> @Nullable T getProperty(String name, Class<?> type);
/**
* Sets a parameter
@@ -173,11 +176,12 @@ public interface RouteTemplateContext extends HasCamelContext {
*
* @param configurer the configurer with callback to invoke with the given route template context
*/
- void setConfigurer(Consumer<RouteTemplateContext> configurer);
+ void setConfigurer(@Nullable Consumer<RouteTemplateContext> configurer);
/**
* Gets the custom configurer.
*/
+ @Nullable
Consumer<RouteTemplateContext> 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 8a467f975b3b..643051d33753 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
@@ -17,6 +17,9 @@
package org.apache.camel;
import java.io.Serial;
+import java.util.Objects;
+
+import org.jspecify.annotations.Nullable;
/**
* Base class for all Camel unchecked exceptions.
@@ -27,15 +30,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);
}
@@ -46,6 +49,7 @@ public class RuntimeCamelException extends RuntimeException {
* @return the wrapper exception
*/
public static RuntimeCamelException wrapRuntimeCamelException(Throwable e) {
+ Objects.requireNonNull(e, "e");
if (e instanceof RuntimeCamelException re) {
// don't double wrap
return re;
@@ -61,6 +65,7 @@ public class RuntimeCamelException extends RuntimeException {
* @return the wrapper exception
*/
public static RuntimeException wrapRuntimeException(Throwable e) {
+ Objects.requireNonNull(e, "e");
if (e instanceof RuntimeException re) {
// don't double wrap
return re;
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 bf504cb30c04..4aef5cda746b 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 <tt>null</tt> 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 567cdc024da6..d7ef40c951d3 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,19 +16,24 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+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));
+ public RuntimeExchangeException(String message, @Nullable Exchange exchange) {
+ super(createMessage(Objects.requireNonNull(message, "message"), exchange));
this.exchange = exchange;
}
- public RuntimeExchangeException(String message, Exchange exchange, Throwable cause) {
- super(createMessage(message, exchange), cause);
+ public RuntimeExchangeException(String message, @Nullable Exchange exchange, Throwable cause) {
+ super(createMessage(Objects.requireNonNull(message, "message"), exchange),
+ Objects.requireNonNull(cause, "cause"));
this.exchange = exchange;
}
@@ -37,11 +42,12 @@ public class RuntimeExchangeException extends RuntimeCamelException {
* <p/>
* Can be <tt>null</tt>
*/
- 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) {
+ Objects.requireNonNull(message, "message");
if (exchange != null) {
return message + " on the exchange: " + exchange;
} else {
diff --git a/core/camel-api/src/main/java/org/apache/camel/RuntimeExpressionException.java b/core/camel-api/src/main/java/org/apache/camel/RuntimeExpressionException.java
index 5e3b5246e78f..50955ba52a10 100644
--- a/core/camel-api/src/main/java/org/apache/camel/RuntimeExpressionException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/RuntimeExpressionException.java
@@ -16,20 +16,22 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
/**
* Thrown if an expression evaluation fails
*/
public class RuntimeExpressionException extends RuntimeCamelException {
public RuntimeExpressionException(String message) {
- super(message);
+ super(Objects.requireNonNull(message, "message"));
}
public RuntimeExpressionException(String message, Throwable cause) {
- super(message, cause);
+ super(Objects.requireNonNull(message, "message"), Objects.requireNonNull(cause, "cause"));
}
public RuntimeExpressionException(Throwable cause) {
- super(cause);
+ super(Objects.requireNonNull(cause, "cause"));
}
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/RuntimeTransformException.java b/core/camel-api/src/main/java/org/apache/camel/RuntimeTransformException.java
index 2138d9272a99..0bfb9ad40bc8 100644
--- a/core/camel-api/src/main/java/org/apache/camel/RuntimeTransformException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/RuntimeTransformException.java
@@ -16,20 +16,22 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
/**
* Thrown if a message transformation fails
*/
public class RuntimeTransformException extends RuntimeCamelException {
public RuntimeTransformException(String message) {
- super(message);
+ super(Objects.requireNonNull(message, "message"));
}
public RuntimeTransformException(String message, Throwable cause) {
- super(message, cause);
+ super(Objects.requireNonNull(message, "message"), Objects.requireNonNull(cause, "cause"));
}
public RuntimeTransformException(Throwable cause) {
- super(cause);
+ super(Objects.requireNonNull(cause, "cause"));
}
}
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 bd5dfce4b6b6..597510a52ebe 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,9 +27,10 @@ public interface SSLContextParametersAware extends CamelContextAware {
/**
* Returns the global {@link SSLContextParameters} if enabled on the implementing object, null otherwise.
*/
- default SSLContextParameters retrieveGlobalSslContextParameters() {
- if (isUseGlobalSslContextParameters()) {
- return getCamelContext().getSSLContextParameters();
+ default @Nullable SSLContextParameters retrieveGlobalSslContextParameters() {
+ CamelContext ctx = getCamelContext();
+ if (ctx != null && isUseGlobalSslContextParameters()) {
+ return ctx.getSSLContextParameters();
}
return null;
}
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 5fd2a0f9298c..6f9e824d2129 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/StreamCache.java b/core/camel-api/src/main/java/org/apache/camel/StreamCache.java
index 4dc522379941..289cd120cf7a 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 @@ package org.apache.camel;
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.
* <p/>
@@ -64,6 +66,7 @@ public interface StreamCache {
* @return a copy, or <tt>null</tt> 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 6fa8fd3ab806..24b183bde90e 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,13 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+import org.jspecify.annotations.Nullable;
+
public class StreamCacheException extends TypeConversionException {
- public StreamCacheException(Object value, Throwable cause) {
- super(value, StreamCache.class, cause);
+ public StreamCacheException(@Nullable Object value, Throwable cause) {
+ super(value, StreamCache.class, Objects.requireNonNull(cause, "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 aa187829fc2f..726b4c3e2a49 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<K, V> extends Service {
* @param key the key of the value to search for
* @return the value for the given key or <tt>null</tt> if it is not present (or has timed out)
*/
+ @Nullable
V get(K key);
/**
@@ -45,6 +48,7 @@ public interface TimeoutMap<K, V> extends Service {
* @return the previous value associated with <tt>key</tt>, or <tt>null</tt> if there was no mapping
* for <tt>key</tt>.
*/
+ @Nullable
V put(K key, V value, long timeoutMillis);
/**
@@ -57,6 +61,7 @@ public interface TimeoutMap<K, V> extends Service {
* @return the value associated with <tt>key</tt>, or <tt>null</tt> if there was no mapping for
* <tt>key</tt>.
*/
+ @Nullable
V putIfAbsent(K key, V value, long timeoutMillis);
/**
@@ -65,6 +70,7 @@ public interface TimeoutMap<K, V> extends Service {
* @param key key for the object to remove
* @return the value for the given key or <tt>null</tt> 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 5096e4e11746..a21781d9f3d7 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,16 +16,20 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+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) {
- super(createMessage(value, type, cause), cause);
+ public TypeConversionException(@Nullable Object value, Class<?> type, Throwable cause) {
+ super(createMessage(value, Objects.requireNonNull(type, "type"), Objects.requireNonNull(cause, "cause")), cause);
this.value = value;
this.type = type;
}
@@ -33,7 +37,7 @@ public class TypeConversionException extends RuntimeCamelException {
/**
* Returns the value which could not be converted
*/
- public Object getValue() {
+ public @Nullable Object getValue() {
return value;
}
@@ -47,7 +51,7 @@ public class TypeConversionException extends RuntimeCamelException {
/**
* Returns the required <tt>from</tt> type. Returns <tt>null</tt> if the provided value was null.
*/
- public Class<?> getFromType() {
+ public @Nullable Class<?> getFromType() {
if (value != null) {
return value.getClass();
} else {
@@ -58,7 +62,9 @@ public class TypeConversionException extends RuntimeCamelException {
/**
* 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) {
+ Objects.requireNonNull(type, "type");
+ Objects.requireNonNull(cause, "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 f959082528d7..a41ce99bfa44 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 <a href="http://camel.apache.org/type-converter.html">to different
* types</a> 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 <tt>null</tt> if not possible to convert
* @throws TypeConversionException is thrown if error during type conversion
*/
- <T> T convertTo(Class<T> type, Object value) throws TypeConversionException;
+ <T> @Nullable T convertTo(Class<T> 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 <tt>null</tt> if not possible to convert
* @throws TypeConversionException is thrown if error during type conversion
*/
- <T> T convertTo(Class<T> type, Exchange exchange, Object value) throws TypeConversionException;
+ <T> @Nullable T convertTo(Class<T> 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> T mandatoryConvertTo(Class<T> type, Object value) throws TypeConversionException, NoTypeConversionAvailableException;
+ <T> T mandatoryConvertTo(Class<T> 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> T mandatoryConvertTo(Class<T> type, Exchange exchange, Object value)
+ <T> T mandatoryConvertTo(Class<T> type, @Nullable Exchange exchange, @Nullable Object value)
throws TypeConversionException, NoTypeConversionAvailableException;
/**
@@ -89,7 +93,7 @@ public interface TypeConverter {
* @param value the value to be converted
* @return the converted value, or <tt>null</tt> if not possible to convert
*/
- <T> T tryConvertTo(Class<T> type, Object value);
+ <T> @Nullable T tryConvertTo(Class<T> type, @Nullable Object value);
/**
* Tries to convert the value to the specified type in the context of an exchange, returning <tt>null</tt> if not
@@ -105,5 +109,5 @@ public interface TypeConverter {
* @param value the value to be converted
* @return the converted value, or <tt>null</tt> if not possible to convert
*/
- <T> T tryConvertTo(Class<T> type, Exchange exchange, Object value);
+ <T> @Nullable T tryConvertTo(Class<T> type, @Nullable Exchange exchange, @Nullable Object value);
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/TypeConverterExistsException.java b/core/camel-api/src/main/java/org/apache/camel/TypeConverterExistsException.java
index fcad9393f2b6..2b2d2dc79848 100644
--- a/core/camel-api/src/main/java/org/apache/camel/TypeConverterExistsException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/TypeConverterExistsException.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
/**
* Exception when failing to add type converters due there is already an existing type converter.
*/
@@ -25,7 +27,8 @@ public class TypeConverterExistsException extends RuntimeCamelException {
private final transient Class<?> fromType;
public TypeConverterExistsException(Class<?> toType, Class<?> fromType) {
- super("Failed to add type converter because a type converter exists. " + fromType + " -> " + toType);
+ super("Failed to add type converter because a type converter exists. "
+ + Objects.requireNonNull(fromType, "fromType") + " -> " + Objects.requireNonNull(toType, "toType"));
this.toType = toType;
this.fromType = fromType;
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/TypeConverterLoaderException.java b/core/camel-api/src/main/java/org/apache/camel/TypeConverterLoaderException.java
index f755bdedd1f1..875be63e2740 100644
--- a/core/camel-api/src/main/java/org/apache/camel/TypeConverterLoaderException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/TypeConverterLoaderException.java
@@ -16,16 +16,19 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
/**
* Exception when failing to load type converters.
*/
public class TypeConverterLoaderException extends RuntimeCamelException {
public TypeConverterLoaderException(String message) {
- super("Failed to load type converters because of: " + message);
+ super("Failed to load type converters because of: " + Objects.requireNonNull(message, "message"));
}
public TypeConverterLoaderException(String message, Throwable cause) {
- super("Failed to load type converters because of: " + message, cause);
+ super("Failed to load type converters because of: " + Objects.requireNonNull(message, "message"),
+ Objects.requireNonNull(cause, "cause"));
}
}
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 7d90af3cde83..37b466e7149c 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,10 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
+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 +27,11 @@ package org.apache.camel;
*/
public class ValidationException extends CamelExchangeException {
- public ValidationException(Exchange exchange, String message) {
- super(message, exchange);
+ public ValidationException(@Nullable Exchange exchange, String message) {
+ super(Objects.requireNonNull(message, "message"), exchange);
}
- public ValidationException(String message, Exchange exchange, Throwable cause) {
- super(message, exchange, cause);
+ public ValidationException(String message, @Nullable Exchange exchange, Throwable cause) {
+ super(Objects.requireNonNull(message, "message"), exchange, Objects.requireNonNull(cause, "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 6cd429fdaff4..a447d1e76a94 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 @@ package org.apache.camel;
import java.util.Objects;
+import org.jspecify.annotations.Nullable;
+
/**
* Holder object for a given value.
*/
@@ -25,7 +27,7 @@ public class ValueHolder<V> {
private final V value;
public ValueHolder(V val) {
- value = val;
+ value = Objects.requireNonNull(val, "val");
}
public V get() {
@@ -33,7 +35,7 @@ public class ValueHolder<V> {
}
@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/VariableAware.java b/core/camel-api/src/main/java/org/apache/camel/VariableAware.java
index 4fd26d8ea2ed..dddbae261e31 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 <tt>null</tt> 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/VetoCamelContextStartException.java b/core/camel-api/src/main/java/org/apache/camel/VetoCamelContextStartException.java
index 260cb973bfa2..3ec117f95974 100644
--- a/core/camel-api/src/main/java/org/apache/camel/VetoCamelContextStartException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/VetoCamelContextStartException.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel;
+import java.util.Objects;
+
/**
* An exception to veto starting {@link CamelContext}.
* <p/>
@@ -34,8 +36,8 @@ public class VetoCamelContextStartException extends Exception {
}
public VetoCamelContextStartException(String message, CamelContext context, boolean rethrowException) {
- super(message);
- this.context = context;
+ super(Objects.requireNonNull(message, "message"));
+ this.context = Objects.requireNonNull(context, "context");
this.rethrowException = rethrowException;
}
@@ -44,8 +46,8 @@ public class VetoCamelContextStartException extends Exception {
}
public VetoCamelContextStartException(String message, Throwable cause, CamelContext context, boolean rethrowException) {
- super(message, cause);
- this.context = context;
+ super(Objects.requireNonNull(message, "message"), Objects.requireNonNull(cause, "cause"));
+ this.context = Objects.requireNonNull(context, "context");
this.rethrowException = rethrowException;
}
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 c2916fc85c94..71d418fb7d13 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<T> {
*
* @return the file.
*/
+ @Nullable
T getFile();
/**
@@ -33,6 +36,7 @@ public interface WrappedFile<T> {
*
* @return the content of the file.
*/
+ @Nullable
Object getBody();
/**
diff --git a/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java b/core/camel-api/src/main/java/org/apache/camel/ai/package-info.java
similarity index 78%
copy from core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
copy to core/camel-api/src/main/java/org/apache/camel/ai/package-info.java
index 6fa8fd3ab806..db56553e1a36 100644
--- a/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ai/package-info.java
@@ -14,11 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel;
+@NullMarked
+package org.apache.camel.ai;
-public class StreamCacheException extends TypeConversionException {
-
- public StreamCacheException(Object value, Throwable cause) {
- super(value, StreamCache.class, cause);
- }
-}
+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 920c7b009d2a..7b04f4e1ad5d 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.Arrays;
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 class ConfigurationPropertiesValidationResult extends PropertiesValidatio
* @param includeHeader whether to include a header
* @return the summary, or <tt>null</tt> 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 class ConfigurationPropertiesValidationResult extends PropertiesValidatio
* @param includeWarnings whether to include warnings as an error or not
* @return the summary, or <tt>null</tt> 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
@@ -132,7 +134,7 @@ public class ConfigurationPropertiesValidationResult extends PropertiesValidatio
if (invalidEnum != null) {
for (Map.Entry<String, String> entry : invalidEnum.entrySet()) {
String name = entry.getKey();
- String[] choices = invalidEnumChoices.get(name);
+ String[] choices = invalidEnumChoices != null ? invalidEnumChoices.get(name) : null;
String defaultValue = defaultValues != null ? defaultValues.get(entry.getKey()) : null;
String str = Arrays.asList(choices).toString();
String msg = "Invalid enum value: " + entry.getValue() + ". Possible values: " + str;
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 512e669c34d3..543b5f628c1b 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
@@ -21,28 +21,31 @@ import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
+import java.util.Objects;
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<String> lenient;
- private Set<String> notConsumerOnly;
- private Set<String> notProducerOnly;
+ private @Nullable Set<String> lenient;
+ private @Nullable Set<String> notConsumerOnly;
+ private @Nullable Set<String> 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;
}
@@ -56,6 +59,7 @@ public class EndpointValidationResult extends PropertiesValidationResult impleme
}
public void addLenient(String name) {
+ Objects.requireNonNull(name, "name");
if (lenient == null) {
lenient = new LinkedHashSet<>();
}
@@ -63,6 +67,7 @@ public class EndpointValidationResult extends PropertiesValidationResult impleme
}
public void addNotConsumerOnly(String name) {
+ Objects.requireNonNull(name, "name");
if (notConsumerOnly == null) {
notConsumerOnly = new LinkedHashSet<>();
}
@@ -73,6 +78,7 @@ public class EndpointValidationResult extends PropertiesValidationResult impleme
}
public void addNotProducerOnly(String name) {
+ Objects.requireNonNull(name, "name");
if (notProducerOnly == null) {
notProducerOnly = new LinkedHashSet<>();
}
@@ -82,15 +88,15 @@ public class EndpointValidationResult extends PropertiesValidationResult impleme
}
}
- public Set<String> getNotConsumerOnly() {
+ public @Nullable Set<String> getNotConsumerOnly() {
return notConsumerOnly;
}
- public Set<String> getNotProducerOnly() {
+ public @Nullable Set<String> getNotProducerOnly() {
return notProducerOnly;
}
- public Set<String> getLenient() {
+ public @Nullable Set<String> getLenient() {
return lenient;
}
@@ -100,7 +106,7 @@ public class EndpointValidationResult extends PropertiesValidationResult impleme
* @param includeHeader whether to include a header
* @return the summary, or <tt>null</tt> if no validation errors
*/
- public String summaryErrorMessage(boolean includeHeader) {
+ public @Nullable String summaryErrorMessage(boolean includeHeader) {
return summaryErrorMessage(includeHeader, true, false);
}
@@ -112,7 +118,7 @@ public class EndpointValidationResult extends PropertiesValidationResult impleme
* @param includeWarnings whether to include warnings as an error or not
* @return the summary, or <tt>null</tt> 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
@@ -174,7 +180,7 @@ public class EndpointValidationResult extends PropertiesValidationResult impleme
if (invalidEnum != null) {
for (Map.Entry<String, String> entry : invalidEnum.entrySet()) {
String name = entry.getKey();
- String[] choices = invalidEnumChoices.get(name);
+ String[] choices = invalidEnumChoices != null ? invalidEnumChoices.get(name) : null;
String defaultValue = defaultValues != null ? defaultValues.get(entry.getKey()) : null;
String str = Arrays.asList(choices).toString();
String msg = "Invalid enum value: " + entry.getValue() + ". Possible values: " + str;
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 7b8c99f4c57b..47244433d1b1 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 dd48a75cb656..55b4cb886b7f 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
@@ -17,18 +17,21 @@
package org.apache.camel.catalog;
import java.io.Serializable;
+import java.util.Objects;
+
+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) {
- this.text = text;
+ this.text = Objects.requireNonNull(text, "text");
}
public String getText() {
@@ -39,19 +42,19 @@ public class LanguageValidationResult implements Serializable {
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 f6cb8698cdb7..d7e8a1fa72a4 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.List;
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<String> unknown;
+ @Nullable
Map<String, String[]> unknownSuggestions;
+ @Nullable
Set<String> required;
+ @Nullable
Set<String> deprecated;
+ @Nullable
Map<String, String> invalidEnum;
+ @Nullable
Map<String, String[]> invalidEnumChoices;
+ @Nullable
Map<String, String[]> invalidEnumSuggestions;
+ @Nullable
Map<String, String> invalidMap;
+ @Nullable
Map<String, String> invalidArray;
+ @Nullable
Map<String, String> invalidReference;
+ @Nullable
Map<String, String> invalidBoolean;
+ @Nullable
Map<String, String> invalidInteger;
+ @Nullable
Map<String, String> invalidNumber;
+ @Nullable
Map<String, String> invalidDuration;
+ @Nullable
Map<String, String> defaultValues;
public boolean hasErrors() {
@@ -221,43 +241,43 @@ abstract class PropertiesValidationResult implements Serializable {
defaultValues.put(name, value);
}
- public String getSyntaxError() {
+ public @Nullable String getSyntaxError() {
return syntaxError;
}
- public String getIncapable() {
+ public @Nullable String getIncapable() {
return incapable;
}
- public Set<String> getUnknown() {
+ public @Nullable Set<String> getUnknown() {
return unknown;
}
- public Map<String, String[]> getUnknownSuggestions() {
+ public @Nullable Map<String, String[]> getUnknownSuggestions() {
return unknownSuggestions;
}
- public String getUnknownComponent() {
+ public @Nullable String getUnknownComponent() {
return unknownComponent;
}
- public Set<String> getRequired() {
+ public @Nullable Set<String> getRequired() {
return required;
}
- public Set<String> getDeprecated() {
+ public @Nullable Set<String> getDeprecated() {
return deprecated;
}
- public Map<String, String> getInvalidEnum() {
+ public @Nullable Map<String, String> getInvalidEnum() {
return invalidEnum;
}
- public Map<String, String[]> getInvalidEnumChoices() {
+ public @Nullable Map<String, String[]> getInvalidEnumChoices() {
return invalidEnumChoices;
}
- public Map<String, String[]> getInvalidEnumSuggestions() {
+ public @Nullable Map<String, String[]> getInvalidEnumSuggestions() {
return invalidEnumSuggestions;
}
@@ -272,35 +292,35 @@ abstract class PropertiesValidationResult implements Serializable {
return Collections.emptyList();
}
- public Map<String, String> getInvalidReference() {
+ public @Nullable Map<String, String> getInvalidReference() {
return invalidReference;
}
- public Map<String, String> getInvalidMap() {
+ public @Nullable Map<String, String> getInvalidMap() {
return invalidMap;
}
- public Map<String, String> getInvalidArray() {
+ public @Nullable Map<String, String> getInvalidArray() {
return invalidArray;
}
- public Map<String, String> getInvalidBoolean() {
+ public @Nullable Map<String, String> getInvalidBoolean() {
return invalidBoolean;
}
- public Map<String, String> getInvalidInteger() {
+ public @Nullable Map<String, String> getInvalidInteger() {
return invalidInteger;
}
- public Map<String, String> getInvalidNumber() {
+ public @Nullable Map<String, String> getInvalidNumber() {
return invalidNumber;
}
- public Map<String, String> getInvalidDuration() {
+ public @Nullable Map<String, String> getInvalidDuration() {
return invalidDuration;
}
- public Map<String, String> getDefaultValues() {
+ public @Nullable Map<String, String> 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 dec884fc7d16..3876ab31dbab 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.CamelContextAware;
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/StreamCacheException.java b/core/camel-api/src/main/java/org/apache/camel/catalog/package-info.java
similarity index 78%
copy from core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
copy to core/camel-api/src/main/java/org/apache/camel/catalog/package-info.java
index 6fa8fd3ab806..5126e2c32af9 100644
--- a/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/catalog/package-info.java
@@ -14,11 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel;
+@NullMarked
+package org.apache.camel.catalog;
-public class StreamCacheException extends TypeConversionException {
-
- public StreamCacheException(Object value, Throwable cause) {
- super(value, StreamCache.class, cause);
- }
-}
+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 6ce9dc918165..dc6db7c58c96 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
@@ -19,8 +19,10 @@ package org.apache.camel.clock;
import java.util.Date;
import java.util.EnumMap;
+import java.util.Objects;
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})
@@ -39,12 +41,14 @@ public final class ContextClock implements EventClock<ContextEvents> {
}
@Override
- public void add(ContextEvents event, Clock clock) {
+ public void add(ContextEvents event, @Nullable Clock clock) {
+ Objects.requireNonNull(event, "event");
events.put(event, clock);
}
@Override
- public Clock get(ContextEvents event) {
+ public @Nullable Clock get(ContextEvents event) {
+ Objects.requireNonNull(event, "event");
return events.get(event);
}
@@ -56,6 +60,7 @@ public final class ContextClock implements EventClock<ContextEvents> {
* @return The elapsed time or the default value if the event is not being tracked
*/
public long elapsed(ContextEvents event, long defaultValue) {
+ Objects.requireNonNull(event, "event");
Clock clock = events.get(event);
if (clock == null) {
return defaultValue;
@@ -73,6 +78,8 @@ public final class ContextClock implements EventClock<ContextEvents> {
* being tracked
*/
public Date asDate(ContextEvents event, Date defaultValue) {
+ Objects.requireNonNull(event, "event");
+ Objects.requireNonNull(defaultValue, "defaultValue");
Clock clock = events.get(event);
if (clock == null) {
return defaultValue;
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 181369042297..079a7b961670 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
*
@@ -30,7 +32,7 @@ public interface EventClock<T extends Enum<T>> extends Clock {
* @param event the event to track
* @param clock the clock associated with the event
*/
- void add(T event, Clock clock);
+ void add(T event, @Nullable Clock clock);
/**
* Get the clock for the event
@@ -38,5 +40,6 @@ public interface EventClock<T extends Enum<T>> 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/StreamCacheException.java b/core/camel-api/src/main/java/org/apache/camel/clock/package-info.java
similarity index 78%
copy from core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
copy to core/camel-api/src/main/java/org/apache/camel/clock/package-info.java
index 6fa8fd3ab806..39b7aea3c869 100644
--- a/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/clock/package-info.java
@@ -14,11 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel;
+@NullMarked
+package org.apache.camel.clock;
-public class StreamCacheException extends TypeConversionException {
-
- public StreamCacheException(Object value, Throwable cause) {
- super(value, StreamCache.class, cause);
- }
-}
+import org.jspecify.annotations.NullMarked;
diff --git a/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java b/core/camel-api/src/main/java/org/apache/camel/cloudevents/package-info.java
similarity index 78%
copy from core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
copy to core/camel-api/src/main/java/org/apache/camel/cloudevents/package-info.java
index 6fa8fd3ab806..2b522bdfc8f2 100644
--- a/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/cloudevents/package-info.java
@@ -14,11 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel;
+@NullMarked
+package org.apache.camel.cloudevents;
-public class StreamCacheException extends TypeConversionException {
-
- public StreamCacheException(Object value, Throwable cause) {
- super(value, StreamCache.class, cause);
- }
-}
+import org.jspecify.annotations.NullMarked;
diff --git a/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java b/core/camel-api/src/main/java/org/apache/camel/cluster/package-info.java
similarity index 78%
copy from core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
copy to core/camel-api/src/main/java/org/apache/camel/cluster/package-info.java
index 6fa8fd3ab806..93a65c4c32f6 100644
--- a/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/cluster/package-info.java
@@ -14,11 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel;
+@NullMarked
+package org.apache.camel.cluster;
-public class StreamCacheException extends TypeConversionException {
-
- public StreamCacheException(Object value, Throwable cause) {
- super(value, StreamCache.class, cause);
- }
-}
+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 97bc253cf39e..674136df4df4 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
@@ -19,6 +19,7 @@ package org.apache.camel.component.extension;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import org.apache.camel.Component;
@@ -28,6 +29,7 @@ import org.apache.camel.component.extension.ComponentVerifierExtensionHelper.Exc
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
@@ -128,8 +130,8 @@ public interface ComponentVerifierExtension extends ComponentExtension {
* @param scope the scope as string, which can be in any case
* @return the scope enum represented by this string
*/
- public static Scope fromString(String scope) {
- return Scope.valueOf(scope != null ? scope.toUpperCase() : null);
+ public static Scope fromString(@Nullable String scope) {
+ return Scope.valueOf(Objects.requireNonNull(scope, "scope").toUpperCase());
}
}
@@ -153,6 +155,7 @@ public interface ComponentVerifierExtension extends ComponentExtension {
*
* @return the error description (if available)
*/
+ @Nullable
String getDescription();
/**
@@ -179,7 +182,7 @@ public interface ComponentVerifierExtension extends ComponentExtension {
* @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<Attribute, Object> details = getDetails();
if (details != null) {
return details.get(attribute);
@@ -193,7 +196,7 @@ public interface ComponentVerifierExtension extends ComponentExtension {
* @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 c9f38c8e9592..78274008dbb6 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 java.util.Optional;
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 @@ public interface MetaDataExtension extends ComponentExtension {
* @param name the attribute name
* @return the attribute
*/
+ @Nullable
Object getAttribute(String name);
/**
@@ -59,13 +61,14 @@ public interface MetaDataExtension extends ComponentExtension {
* for the given name
* @throws TypeConversionException is thrown if error during type conversion
*/
- <T> T getAttribute(String name, Class<T> type);
+ <T> @Nullable T getAttribute(String name, Class<T> type);
/**
* Returns the payload of the meta data as a POJO.
*
* @return the body, can be <tt>null</tt>
*/
+ @Nullable
Object getPayload();
/**
@@ -75,6 +78,6 @@ public interface MetaDataExtension extends ComponentExtension {
* @return the payload of the meta data as the specified type.
* @throws TypeConversionException is thrown if error during type conversion
*/
- <T> T getPayload(Class<T> type);
+ <T> @Nullable T getPayload(Class<T> type);
}
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java b/core/camel-api/src/main/java/org/apache/camel/component/extension/package-info.java
similarity index 78%
copy from core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
copy to core/camel-api/src/main/java/org/apache/camel/component/extension/package-info.java
index 6fa8fd3ab806..1bc7fecebbe2 100644
--- a/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/component/extension/package-info.java
@@ -14,11 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel;
+@NullMarked
+package org.apache.camel.component.extension;
-public class StreamCacheException extends TypeConversionException {
-
- public StreamCacheException(Object value, Throwable cause) {
- super(value, StreamCache.class, cause);
- }
-}
+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 8a70cdcd8af8..cc5a1b675c6a 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.CamelContextAware;
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 <tt>null</tt> if none found.
*/
+ @Nullable
DevConsole resolveById(String id);
/**
@@ -95,7 +97,7 @@ public interface DevConsoleRegistry extends CamelContextAware, StaticService, 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 4ff39eff4ec3..dd1f3418d705 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 java.util.Optional;
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 <tt>null</tt> if not found
*/
+ @Nullable
DevConsole resolveDevConsole(String id);
/**
diff --git a/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java b/core/camel-api/src/main/java/org/apache/camel/console/package-info.java
similarity index 78%
copy from core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
copy to core/camel-api/src/main/java/org/apache/camel/console/package-info.java
index 6fa8fd3ab806..f0ec3840de36 100644
--- a/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/console/package-info.java
@@ -14,11 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel;
+@NullMarked
+package org.apache.camel.console;
-public class StreamCacheException extends TypeConversionException {
-
- public StreamCacheException(Object value, Throwable cause) {
- super(value, StreamCache.class, cause);
- }
-}
+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 d27d7ef14108..135cda654051 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
@@ -21,6 +21,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Map;
+import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Predicate;
@@ -28,6 +29,7 @@ import java.util.stream.Collectors;
import org.apache.camel.CamelContext;
import org.apache.camel.util.ObjectHelper;
+import org.jspecify.annotations.Nullable;
/**
* Helper for invoking {@link HealthCheck}'s.
@@ -47,6 +49,7 @@ public final class HealthCheckHelper {
* Invokes all the checks and returns a collection of results.
*/
public static Collection<HealthCheck.Result> invoke(CamelContext camelContext) {
+ Objects.requireNonNull(camelContext, "camelContext");
return invoke(camelContext, check -> Map.of(HealthCheck.CHECK_KIND, HealthCheck.Kind.ALL), check -> false, null);
}
@@ -56,7 +59,8 @@ public final class HealthCheckHelper {
* @param camelContext the camel context
* @param exposureLevel level of exposure (full, oneline or default)
*/
- public static Collection<HealthCheck.Result> invoke(CamelContext camelContext, String exposureLevel) {
+ public static Collection<HealthCheck.Result> invoke(CamelContext camelContext, @Nullable String exposureLevel) {
+ Objects.requireNonNull(camelContext, "camelContext");
return invoke(camelContext, check -> Map.of(HealthCheck.CHECK_KIND, HealthCheck.Kind.ALL), check -> false,
exposureLevel);
}
@@ -65,6 +69,7 @@ public final class HealthCheckHelper {
* Invokes the readiness checks and returns a collection of results.
*/
public static Collection<HealthCheck.Result> invokeReadiness(CamelContext camelContext) {
+ Objects.requireNonNull(camelContext, "camelContext");
return invoke(camelContext, check -> Map.of(HealthCheck.CHECK_KIND, HealthCheck.Kind.READINESS),
check -> !check.isReadiness(), null);
}
@@ -75,7 +80,8 @@ public final class HealthCheckHelper {
* @param camelContext the camel context
* @param exposureLevel level of exposure (full, oneline or default)
*/
- public static Collection<HealthCheck.Result> invokeReadiness(CamelContext camelContext, String exposureLevel) {
+ public static Collection<HealthCheck.Result> invokeReadiness(CamelContext camelContext, @Nullable String exposureLevel) {
+ Objects.requireNonNull(camelContext, "camelContext");
return invoke(camelContext, check -> Map.of(HealthCheck.CHECK_KIND, HealthCheck.Kind.READINESS),
check -> !check.isReadiness(), exposureLevel);
}
@@ -84,6 +90,7 @@ public final class HealthCheckHelper {
* Invokes the liveness checks and returns a collection of results.
*/
public static Collection<HealthCheck.Result> invokeLiveness(CamelContext camelContext) {
+ Objects.requireNonNull(camelContext, "camelContext");
return invoke(camelContext, check -> Map.of(HealthCheck.CHECK_KIND, HealthCheck.Kind.LIVENESS),
check -> !check.isLiveness(), null);
}
@@ -94,7 +101,8 @@ public final class HealthCheckHelper {
* @param camelContext the camel context
* @param exposureLevel level of exposure (full, oneline or default)
*/
- public static Collection<HealthCheck.Result> invokeLiveness(CamelContext camelContext, String exposureLevel) {
+ public static Collection<HealthCheck.Result> invokeLiveness(CamelContext camelContext, @Nullable String exposureLevel) {
+ Objects.requireNonNull(camelContext, "camelContext");
return invoke(camelContext, check -> Map.of(HealthCheck.CHECK_KIND, HealthCheck.Kind.LIVENESS),
check -> !check.isLiveness(), exposureLevel);
}
@@ -105,7 +113,8 @@ public final class HealthCheckHelper {
public static Collection<HealthCheck.Result> invoke(
CamelContext camelContext,
Function<HealthCheck, Map<String, Object>> optionsSupplier) {
-
+ Objects.requireNonNull(camelContext, "camelContext");
+ Objects.requireNonNull(optionsSupplier, "optionsSupplier");
return invoke(camelContext, optionsSupplier, check -> false, null);
}
@@ -115,7 +124,8 @@ public final class HealthCheckHelper {
public static Collection<HealthCheck.Result> invoke(
CamelContext camelContext,
Predicate<HealthCheck> filter) {
-
+ Objects.requireNonNull(camelContext, "camelContext");
+ Objects.requireNonNull(filter, "filter");
return invoke(camelContext, check -> Collections.emptyMap(), filter, null);
}
@@ -131,7 +141,10 @@ public final class HealthCheckHelper {
CamelContext camelContext,
Function<HealthCheck, Map<String, Object>> optionsSupplier,
Predicate<HealthCheck> filter,
- String exposureLevel) {
+ @Nullable String exposureLevel) {
+ Objects.requireNonNull(camelContext, "camelContext");
+ Objects.requireNonNull(optionsSupplier, "optionsSupplier");
+ Objects.requireNonNull(filter, "filter");
final HealthCheckRegistry registry = HealthCheckRegistry.get(camelContext);
@@ -191,6 +204,9 @@ public final class HealthCheckHelper {
* @return an optional {@link HealthCheck.Result}.
*/
public static Optional<HealthCheck.Result> invoke(CamelContext camelContext, String id, Map<String, Object> options) {
+ Objects.requireNonNull(camelContext, "camelContext");
+ Objects.requireNonNull(id, "id");
+ Objects.requireNonNull(options, "options");
final HealthCheckRegistry registry = HealthCheckRegistry.get(camelContext);
if (registry != null) {
@@ -206,7 +222,8 @@ public final class HealthCheckHelper {
* @param context the camel context
* @return the health check registry, or <tt>null</tt> if health-check is not enabled.
*/
- public static HealthCheckRegistry getHealthCheckRegistry(CamelContext context) {
+ public static @Nullable HealthCheckRegistry getHealthCheckRegistry(CamelContext context) {
+ Objects.requireNonNull(context, "context");
return context.getCamelContextExtension().getContextPlugin(HealthCheckRegistry.class);
}
@@ -217,7 +234,9 @@ public final class HealthCheckHelper {
* @param id the id of the health check
* @return the health check, or <tt>null</tt> 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) {
+ Objects.requireNonNull(context, "context");
+ Objects.requireNonNull(id, "id");
HealthCheck answer = null;
HealthCheckRegistry hcr = context.getCamelContextExtension().getContextPlugin(HealthCheckRegistry.class);
@@ -227,7 +246,7 @@ public final class HealthCheckHelper {
// use resolver to load from classpath if needed
HealthCheckResolver resolver
= context.getCamelContextExtension().getContextPlugin(HealthCheckResolver.class);
- HealthCheck hc = resolver.resolveHealthCheck(id);
+ HealthCheck hc = resolver != null ? resolver.resolveHealthCheck(id) : null;
if (hc != null) {
check = Optional.of(hc);
hcr.register(hc);
@@ -248,7 +267,10 @@ public final class HealthCheckHelper {
* @param type the expected type of the health check repository
* @return the health check, or <tt>null</tt> if no health check exists with this id
*/
- public static <T extends HealthCheck> T getHealthCheck(CamelContext context, String id, Class<T> type) {
+ public static <T extends HealthCheck> @Nullable T getHealthCheck(CamelContext context, String id, Class<T> type) {
+ Objects.requireNonNull(context, "context");
+ Objects.requireNonNull(id, "id");
+ Objects.requireNonNull(type, "type");
HealthCheck answer = getHealthCheck(context, id);
if (answer != null) {
return type.cast(answer);
@@ -263,7 +285,9 @@ public final class HealthCheckHelper {
* @param id the id of the health check repository
* @return the health check repository, or <tt>null</tt> 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) {
+ Objects.requireNonNull(context, "context");
+ Objects.requireNonNull(id, "id");
HealthCheckRepository answer = null;
HealthCheckRegistry hcr = context.getCamelContextExtension().getContextPlugin(HealthCheckRegistry.class);
@@ -273,7 +297,7 @@ public final class HealthCheckHelper {
// use resolver to load from classpath if needed
HealthCheckResolver resolver
= context.getCamelContextExtension().getContextPlugin(HealthCheckResolver.class);
- HealthCheckRepository hr = resolver.resolveHealthCheckRepository(id);
+ HealthCheckRepository hr = resolver != null ? resolver.resolveHealthCheckRepository(id) : null;
if (hr != null) {
repo = Optional.of(hr);
hcr.register(hr);
@@ -294,7 +318,11 @@ public final class HealthCheckHelper {
* @param type the expected type of the health check repository
* @return the health check repository, or <tt>null</tt> if no health check repository exists with this id
*/
- public static <T extends HealthCheckRepository> T getHealthCheckRepository(CamelContext context, String id, Class<T> type) {
+ public static <T extends HealthCheckRepository> @Nullable T getHealthCheckRepository(
+ CamelContext context, String id, Class<T> type) {
+ Objects.requireNonNull(context, "context");
+ Objects.requireNonNull(id, "id");
+ Objects.requireNonNull(type, "type");
HealthCheckRepository answer = getHealthCheckRepository(context, id);
if (answer != null) {
return type.cast(answer);
@@ -310,6 +338,7 @@ public final class HealthCheckHelper {
* @return true if up, or false if down
*/
public static boolean isResultsUp(Collection<HealthCheck.Result> results, boolean readiness) {
+ Objects.requireNonNull(results, "results");
boolean up;
if (readiness) {
// readiness requires that all are UP
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 f48ac1a565a5..4c463fe65323 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.CamelContextAware;
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 <tt>null</tt> if none found.
*/
+ @Nullable
Object resolveById(String id);
/**
@@ -106,7 +108,7 @@ public interface HealthCheckRegistry extends CamelContextAware, StaticService, I
* 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 @@ public interface HealthCheckRegistry extends CamelContextAware, StaticService, I
* 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 342102a303ba..3b167772fbbc 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 <tt>null</tt> 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 <tt>null</tt> 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 3aee92b6d644..1d77075ce42d 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
@@ -19,10 +19,12 @@ package org.apache.camel.health;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.Objects;
import java.util.Optional;
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,38 +32,41 @@ import org.apache.camel.util.ObjectHelper;
public final class HealthCheckResultBuilder implements Builder<HealthCheck.Result> {
private final HealthCheck check;
- private String message;
- private Throwable error;
- private Map<String, Object> details;
- private HealthCheck.State state;
+ private @Nullable String message;
+ private @Nullable Throwable error;
+ private @Nullable Map<String, Object> details;
+ private HealthCheck.@Nullable State state;
private HealthCheckResultBuilder(HealthCheck check) {
- this.check = check;
+ this.check = Objects.requireNonNull(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) {
+ Objects.requireNonNull(key, "key");
return this.details != null ? this.details.get(key) : null;
}
public HealthCheckResultBuilder detail(String key, Object value) {
+ Objects.requireNonNull(key, "key");
+ Objects.requireNonNull(value, "value");
if (this.details == null) {
this.details = new HashMap<>();
}
@@ -71,6 +76,7 @@ public final class HealthCheckResultBuilder implements Builder<HealthCheck.Resul
}
public HealthCheckResultBuilder details(Map<String, Object> details) {
+ Objects.requireNonNull(details, "details");
if (ObjectHelper.isNotEmpty(details)) {
details.forEach(this::detail);
}
@@ -78,12 +84,12 @@ public final class HealthCheckResultBuilder implements Builder<HealthCheck.Resul
return this;
}
- public HealthCheck.State state() {
+ public HealthCheck.@Nullable State state() {
return this.state;
}
public HealthCheckResultBuilder state(HealthCheck.State state) {
- this.state = state;
+ this.state = Objects.requireNonNull(state, "state");
return this;
}
@@ -104,7 +110,7 @@ public final class HealthCheckResultBuilder implements Builder<HealthCheck.Resul
// Validation
ObjectHelper.notNull(this.state, "Response State");
- final HealthCheck.State responseState = this.state;
+ final HealthCheck.State responseState = Objects.requireNonNull(this.state, "state");
final Optional<String> responseMessage = Optional.ofNullable(this.message);
final Optional<Throwable> responseError = Optional.ofNullable(this.error);
final Map<String, Object> responseDetails = ObjectHelper.isNotEmpty(this.details)
@@ -140,6 +146,7 @@ public final class HealthCheckResultBuilder implements Builder<HealthCheck.Resul
}
public static HealthCheckResultBuilder on(HealthCheck check) {
+ Objects.requireNonNull(check, "check");
return new HealthCheckResultBuilder(check);
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java b/core/camel-api/src/main/java/org/apache/camel/health/package-info.java
similarity index 78%
copy from core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
copy to core/camel-api/src/main/java/org/apache/camel/health/package-info.java
index 6fa8fd3ab806..becfd29bf211 100644
--- a/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/health/package-info.java
@@ -14,11 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel;
+@NullMarked
+package org.apache.camel.health;
-public class StreamCacheException extends TypeConversionException {
-
- public StreamCacheException(Object value, Throwable cause) {
- super(value, StreamCache.class, cause);
- }
-}
+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 3defafe1460d..43e2cbc05342 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,9 +17,11 @@
/**
* The core Camel API.
*/
+@NullMarked
@XmlSchema(namespace = "http://camel.apache.org/schema/spring",
elementFormDefault = XmlNsForm.QUALIFIED)
package org.apache.camel;
import jakarta.xml.bind.annotation.XmlNsForm;
import jakarta.xml.bind.annotation.XmlSchema;
+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 599c170a7b31..a62002f5fbc1 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 @@ package org.apache.camel.resume;
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 @@ public interface Deserializable {
* @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 @@ public interface Deserializable {
* @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 ca05ae67035f..e02a186f9220 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 @@ package org.apache.camel.resume;
import java.nio.ByteBuffer;
+import org.jspecify.annotations.Nullable;
+
/**
* Generic offset without a concrete type
*
@@ -38,6 +40,7 @@ public interface Offset<T> extends Serializable {
*
* @return the offset value
*/
+ @Nullable
T getValue();
/**
@@ -46,7 +49,7 @@ public interface Offset<T> extends Serializable {
* @param tClass type to convert the value to
* @return the offset value or null if it cannot be converted
*/
- default <V> V getValue(Class<V> tClass) {
+ default <V> @Nullable V getValue(Class<V> tClass) {
try {
return tClass.cast(getValue());
} catch (ClassCastException e) {
@@ -55,7 +58,7 @@ public interface Offset<T> extends Serializable {
}
@Override
- default ByteBuffer serialize() {
+ default @Nullable ByteBuffer serialize() {
return serialize(getValue());
}
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/resume/OffsetKey.java b/core/camel-api/src/main/java/org/apache/camel/resume/OffsetKey.java
index 704db81346a3..82816057e583 100644
--- a/core/camel-api/src/main/java/org/apache/camel/resume/OffsetKey.java
+++ b/core/camel-api/src/main/java/org/apache/camel/resume/OffsetKey.java
@@ -19,6 +19,8 @@ package org.apache.camel.resume;
import java.nio.ByteBuffer;
+import org.jspecify.annotations.Nullable;
+
/**
* An interface to represent offset keys (addressable for an offset)
*
@@ -37,10 +39,11 @@ public interface OffsetKey<K> extends Serializable {
*
* @return the key instance
*/
+ @Nullable
K getValue();
@Override
- default ByteBuffer serialize() {
+ default @Nullable ByteBuffer serialize() {
return serialize(getValue());
}
}
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 dd98f3f47272..761282859c1c 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 eee438990431..187be962eab4 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 @@ public interface ResumeStrategy extends Service {
*
* @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 @@ public interface ResumeStrategy extends Service {
* @param updateCallBack a callback to be executed after the updated has occurred (null if not available)
* @throws Exception if unable to update the offset
*/
- <T extends Resumable> void updateLastOffset(T offset, UpdateCallBack updateCallBack) throws Exception;
+ <T extends Resumable> void updateLastOffset(T offset, @Nullable UpdateCallBack updateCallBack) throws Exception;
/**
* Updates the last processed offset
@@ -105,7 +106,7 @@ public interface ResumeStrategy extends Service {
* @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 eb99746fc3b2..a5dde69d5fdd 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
@@ -17,21 +17,24 @@
package org.apache.camel.resume;
+import java.util.Objects;
+
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;
}
@@ -41,7 +44,7 @@ public abstract class ResumeStrategyConfiguration {
* @param cacheFillPolicy the fill policy to use
*/
public void setCacheFillPolicy(Cacheable.FillPolicy cacheFillPolicy) {
- this.cacheFillPolicy = cacheFillPolicy;
+ this.cacheFillPolicy = Objects.requireNonNull(cacheFillPolicy, "cacheFillPolicy");
}
/**
@@ -53,11 +56,11 @@ public abstract class ResumeStrategyConfiguration {
*/
public abstract String resumeStrategyService();
- public ResumeCache<?> getResumeCache() {
+ public @Nullable ResumeCache<?> getResumeCache() {
return resumeCache;
}
public void setResumeCache(ResumeCache<?> resumeCache) {
- this.resumeCache = resumeCache;
+ this.resumeCache = Objects.requireNonNull(resumeCache, "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 0103d57e883f..0fe2afb44956 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.io.File;
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(@Nullable Object obj) {
ObjectHelper.notNull(obj, "Cannot perform serialization on a null object");
if (obj instanceof Long value) {
@@ -79,5 +80,6 @@ public interface Serializable {
*
* @return a ByteBuffer instance with the serialized contents of this object
*/
+ @Nullable
ByteBuffer serialize();
}
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 14afe5981c4d..51941bf1094b 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.BiFunction;
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<K> {
* @param clazz the class object representing the value to be obtained
* @return the offset value wrapped in an optional
*/
- <T> T get(K key, Class<T> clazz);
+ <T> @Nullable T get(K key, Class<T> clazz);
/**
* Gets the offset entry for the key
@@ -92,6 +93,7 @@ public interface ResumeCache<K> {
* @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/StreamCacheException.java b/core/camel-api/src/main/java/org/apache/camel/resume/cache/package-info.java
similarity index 78%
copy from core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
copy to core/camel-api/src/main/java/org/apache/camel/resume/cache/package-info.java
index 6fa8fd3ab806..48d2fc72529b 100644
--- a/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/resume/cache/package-info.java
@@ -14,11 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel;
+@NullMarked
+package org.apache.camel.resume.cache;
-public class StreamCacheException extends TypeConversionException {
-
- public StreamCacheException(Object value, Throwable cause) {
- super(value, StreamCache.class, cause);
- }
-}
+import org.jspecify.annotations.NullMarked;
diff --git a/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java b/core/camel-api/src/main/java/org/apache/camel/resume/package-info.java
similarity index 78%
copy from core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
copy to core/camel-api/src/main/java/org/apache/camel/resume/package-info.java
index 6fa8fd3ab806..a22f8db94fcd 100644
--- a/core/camel-api/src/main/java/org/apache/camel/StreamCacheException.java
+++ b/core/camel-api/src/main/java/org/apache/camel/resume/package-info.java
@@ -14,11 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel;
+@NullMarked
+package org.apache.camel.resume;
-public class StreamCacheException extends TypeConversionException {
-
- public StreamCacheException(Object value, Throwable cause) {
- super(value, StreamCache.class, cause);
- }
-}
+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 b999765d0904..26eeb38833e8 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 java.util.Set;
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 <tt>null</tt> 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 9bd94216b898..2bed568ce967 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 java.util.Collection;
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 @@ public interface AsyncProcessorAwaitManager extends StaticService {
* <p/>
* Is <tt>null</tt> if message history is disabled.
*/
+ @Nullable
String getRouteId();
/**
@@ -117,6 +119,7 @@ public interface AsyncProcessorAwaitManager extends StaticService {
* <p/>
* Is <tt>null</tt> 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 a660b43c5e18..0caee48e19b1 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.NoTypeConversionAvailableException;
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
@@ -61,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();
/**
@@ -312,6 +314,7 @@ public interface BacklogDebugger extends StatefulService {
* @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 +323,7 @@ public interface BacklogDebugger extends StatefulService {
* @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);
/**
@@ -433,6 +437,7 @@ public interface BacklogDebugger extends StatefulService {
/**
* 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/BacklogTracer.java b/core/camel-api/src/main/java/org/apache/camel/spi/BacklogTracer.java
index 95f46b0679b4..384ed1160172 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 @@ package org.apache.camel.spi;
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 8ef5c1647970..80218fe1cb23 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 @@ package org.apache.camel.spi;
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<String, String> 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 ad01fc882b2f..ef00bb85d84f 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.CamelContext;
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
@@ -38,19 +39,19 @@ public interface BeanIntrospection extends StaticService, AfterPropertiesConfigu
* Structure of an introspected class.
*/
final class ClassInfo {
- public Class<?> clazz;
- public MethodInfo[] methods;
+ public @Nullable Class<?> clazz;
+ public MethodInfo @Nullable [] methods;
}
/**
* Structure of an introspected method.
*/
final class MethodInfo {
- public Method method;
- public Boolean isGetter;
- public Boolean isSetter;
- public String getterOrSetterShorthandName;
- public Boolean hasGetterAndSetter;
+ public @Nullable Method method;
+ public @Nullable Boolean isGetter;
+ public @Nullable Boolean isSetter;
+ public @Nullable String getterOrSetterShorthandName;
+ public @Nullable Boolean hasGetterAndSetter;
}
// Statistics
@@ -100,7 +101,7 @@ public interface BeanIntrospection extends StaticService, AfterPropertiesConfigu
* @param optionPrefix an optional prefix to append the property key
* @return <tt>true</tt> if any properties was found, <tt>false</tt> otherwise.
*/
- boolean getProperties(Object target, Map<String, Object> properties, String optionPrefix);
+ boolean getProperties(Object target, Map<String, Object> properties, @Nullable String optionPrefix);
/**
* Will inspect the target for properties.
@@ -113,7 +114,7 @@ public interface BeanIntrospection extends StaticService, AfterPropertiesConfigu
* @param includeNull whether to include <tt>null</tt> values
* @return <tt>true</tt> if any properties was found, <tt>false</tt> otherwise.
*/
- boolean getProperties(Object target, Map<String, Object> properties, String optionPrefix, boolean includeNull);
+ boolean getProperties(Object target, Map<String, Object> properties, @Nullable String optionPrefix, boolean includeNull);
/**
* Introspects the given class.
@@ -179,7 +180,7 @@ public interface BeanIntrospection extends StaticService, AfterPropertiesConfigu
* 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 @@ public interface BeanIntrospection extends StaticService, AfterPropertiesConfigu
* {@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 89c9fa69af02..c56410d3bac1 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 java.lang.reflect.Method;
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 ecb9ab936753..1a11d7125daa 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.Map;
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 <tt>null</tt> 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 <tt>null</tt> if it could not be found
*/
- <T> T lookupByNameAndType(String name, Class<T> type);
+ <T> @Nullable T lookupByNameAndType(String name, Class<T> 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> T findSingleByType(Class<T> type) {
+ default <T> @Nullable T findSingleByType(Class<T> type) {
Set<T> 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 a2ef9a890c02..e4a2b45628cd 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.Exchange;
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 @@ public interface Breakpoint {
* 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/BrowsableEndpoint.java b/core/camel-api/src/main/java/org/apache/camel/spi/BrowsableEndpoint.java
index 0f82d4f4b0d5..d65845200dd9 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 java.util.stream.Collectors;
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
@@ -60,8 +61,10 @@ public interface BrowsableEndpoint extends Endpoint {
long ts = 0;
long ts2 = 0;
if (!list.isEmpty()) {
- ts = list.get(0).getMessage().getHeader(Exchange.MESSAGE_TIMESTAMP, 0L, long.class);
- ts2 = list.get(list.size() - 1).getMessage().getHeader(Exchange.MESSAGE_TIMESTAMP, 0L, long.class);
+ Long v1 = list.get(0).getMessage().getHeader(Exchange.MESSAGE_TIMESTAMP, 0L, long.class);
+ Long v2 = list.get(list.size() - 1).getMessage().getHeader(Exchange.MESSAGE_TIMESTAMP, 0L, long.class);
+ ts = v1 != null ? v1 : 0L;
+ ts2 = v2 != null ? v2 : 0L;
}
return new BrowseStatus(list.size(), ts, ts2);
}
@@ -80,7 +83,7 @@ public interface BrowsableEndpoint extends Endpoint {
* @param filter filter to filter among the messages to include.
* @return the exchanges on this endpoint
*/
- default List<Exchange> getExchanges(int limit, Predicate filter) {
+ default List<Exchange> getExchanges(int limit, @Nullable Predicate filter) {
List<Exchange> answer = getExchanges();
if (filter != null) {
answer = (List<Exchange>) answer.stream().filter(filter).collect(Collectors.toList());
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 76f475f115d8..44d646d7ac75 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.NoTypeConversionAvailableException;
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 <tt>null</tt> 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> T convertTo(Class<?> from, Class<T> to, Exchange exchange, Object value) throws TypeConversionException;
+ <T> @Nullable T convertTo(Class<?> from, Class<T> to, @Nullable Exchange exchange, @Nullable Object value)
+ throws TypeConversionException;
/**
* Tries to convert the value to the specified type, returning <tt>null</tt> 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 <tt>null</tt> if not possible to convert
*/
- default <T> T tryConvertTo(Class<?> from, Class<T> to, Exchange exchange, Object value) throws TypeConversionException {
+ default <T> @Nullable T tryConvertTo(Class<?> from, Class<T> to, @Nullable Exchange exchange, @Nullable Object value)
+ throws TypeConversionException {
try {
Object t = convertTo(from, to, exchange, value);
if (t == Void.class) {
@@ -91,7 +95,8 @@ public interface BulkTypeConverters extends Ordered, TypeConverter {
* @throws TypeConversionException is thrown if error during type conversion
* @throws NoTypeConversionAvailableException if no type converters exists to convert to the given type
*/
- default <T> T mandatoryConvertTo(Class<?> from, Class<T> to, Exchange exchange, Object value)
+ @SuppressWarnings("NullAway")
+ default <T> T mandatoryConvertTo(Class<?> from, Class<T> to, @Nullable Exchange exchange, @Nullable Object value)
throws TypeConversionException, NoTypeConversionAvailableException {
Object t = convertTo(from, to, exchange, value);
if (t == Void.class) {
@@ -119,34 +124,47 @@ public interface BulkTypeConverters extends Ordered, TypeConverter {
}
@Override
- default <T> T convertTo(Class<T> type, Object value) throws TypeConversionException {
+ default <T> @Nullable T convertTo(Class<T> type, @Nullable Object value) throws TypeConversionException {
+ if (value == null) {
+ return null;
+ }
return convertTo(value.getClass(), type, null, value);
}
@Override
- default <T> T convertTo(Class<T> type, Exchange exchange, Object value) throws TypeConversionException {
+ default <T> @Nullable T convertTo(Class<T> type, @Nullable Exchange exchange, @Nullable Object value)
+ throws TypeConversionException {
+ if (value == null) {
+ return null;
+ }
return convertTo(value.getClass(), type, exchange, value);
}
@Override
- default <T> T mandatoryConvertTo(Class<T> type, Object value)
+ default <T> T mandatoryConvertTo(Class<T> type, @Nullable Object value)
throws TypeConversionException, NoTypeConversionAvailableException {
- return mandatoryConvertTo(value.getClass(), type, null, value);
+ return mandatoryConvertTo(value != null ? value.getClass() : type, type, null, value);
}
@Override
- default <T> T mandatoryConvertTo(Class<T> type, Exchange exchange, Object value)
+ default <T> T mandatoryConvertTo(Class<T> type, @Nullable Exchange exchange, @Nullable Object value)
throws TypeConversionException, NoTypeConversionAvailableException {
- return mandatoryConvertTo(value.getClass(), type, exchange, value);
+ return mandatoryConvertTo(value != null ? value.getClass() : type, type, exchange, value);
}
@Override
- default <T> T tryConvertTo(Class<T> type, Object value) {
+ default <T> @Nullable T tryConvertTo(Class<T> type, @Nullable Object value) {
+ if (value == null) {
+ return null;
+ }
return tryConvertTo(value.getClass(), type, null, value);
}
@Override
- default <T> T tryConvertTo(Class<T> type, Exchange exchange, Object value) {
+ default <T> @Nullable T tryConvertTo(Class<T> type, @Nullable Exchange exchange, @Nullable Object value) {
+ if (value == null) {
+ return null;
+ }
return tryConvertTo(value.getClass(), type, exchange, value);
}
}
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 b340a1c64cc2..f93614942a07 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
@@ -19,6 +19,7 @@ package org.apache.camel.spi;
import java.util.function.Predicate;
import org.apache.camel.BindToRegistry;
+import org.jspecify.annotations.Nullable;
/**
* Bean post processor.
@@ -36,7 +37,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;
}
@@ -51,7 +52,7 @@ public interface CamelBeanPostProcessor {
* 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 6c70ab295812..c9ecebf4243f 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 @@ package org.apache.camel.spi;
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/CamelContextTracker.java b/core/camel-api/src/main/java/org/apache/camel/spi/CamelContextTracker.java
index 82f5bfcb81ea..3a2ef3eac5fb 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/CamelContextTracker.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/CamelContextTracker.java
@@ -18,6 +18,7 @@ package org.apache.camel.spi;
import java.io.Closeable;
import java.util.List;
+import java.util.Objects;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@@ -56,7 +57,7 @@ public class CamelContextTracker implements Closeable {
}
public CamelContextTracker(Filter filter) {
- this.filter = filter;
+ this.filter = Objects.requireNonNull(filter, "filter");
}
/**
@@ -70,6 +71,7 @@ public class CamelContextTracker implements Closeable {
* Called when a context is created.
*/
public void contextCreated(CamelContext camelContext) {
+ Objects.requireNonNull(camelContext, "camelContext");
// do nothing
}
@@ -77,6 +79,7 @@ public class CamelContextTracker implements Closeable {
* Called when a context has been shutdown.
*/
public void contextDestroyed(CamelContext camelContext) {
+ Objects.requireNonNull(camelContext, "camelContext");
// do nothing
}
@@ -96,6 +99,7 @@ public class CamelContextTracker implements Closeable {
}
public static void notifyContextCreated(CamelContext camelContext) {
+ Objects.requireNonNull(camelContext, "camelContext");
LOCK.lock();
try {
for (CamelContextTracker tracker : TRACKERS) {
@@ -113,6 +117,7 @@ public class CamelContextTracker implements Closeable {
}
public static void notifyContextDestroyed(CamelContext camelContext) {
+ Objects.requireNonNull(camelContext, "camelContext");
LOCK.lock();
try {
for (CamelContextTracker tracker : TRACKERS) {
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 a1907ed9df8e..f56368357b3c 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.Endpoint;
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 @@ public interface CamelEvent {
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 d5782b2072d7..84285c4855cb 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<T> {
* method, or use <tt>null</tt> 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<T> {
* @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 c6c28aa1625a..463f9ef29f2a 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
@@ -16,8 +16,11 @@
*/
package org.apache.camel.spi;
+import java.util.Objects;
+
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;
@@ -31,8 +34,8 @@ import org.slf4j.MarkerFactory;
*/
public class CamelLogger {
private Logger log;
- private LoggingLevel level;
- private Marker marker;
+ private LoggingLevel level = LoggingLevel.INFO;
+ private @Nullable Marker marker;
public CamelLogger() {
this(LoggerFactory.getLogger(CamelLogger.class));
@@ -46,22 +49,22 @@ public class CamelLogger {
this(log, level, null);
}
- public CamelLogger(Logger log, LoggingLevel level, String marker) {
- this.log = log;
+ public CamelLogger(Logger log, LoggingLevel level, @Nullable String marker) {
+ this.log = Objects.requireNonNull(log, "log");
setLevel(level);
setMarker(marker);
}
public CamelLogger(String logName) {
- this(LoggerFactory.getLogger(logName));
+ this(LoggerFactory.getLogger(Objects.requireNonNull(logName, "logName")));
}
public CamelLogger(String logName, LoggingLevel level) {
this(logName, level, null);
}
- public CamelLogger(String logName, LoggingLevel level, String marker) {
- this(LoggerFactory.getLogger(logName), level, marker);
+ public CamelLogger(String logName, LoggingLevel level, @Nullable String marker) {
+ this(LoggerFactory.getLogger(Objects.requireNonNull(logName, "logName")), level, marker);
}
@Override
@@ -70,6 +73,8 @@ public class CamelLogger {
}
public void log(String message, LoggingLevel loggingLevel) {
+ Objects.requireNonNull(message, "message");
+ Objects.requireNonNull(loggingLevel, "loggingLevel");
LoggingLevel oldLogLevel = getLevel();
setLevel(loggingLevel);
log(message);
@@ -82,6 +87,7 @@ public class CamelLogger {
* @param message the message to log, if {@link #shouldLog()} returned <tt>true</tt>
*/
public void log(String message) {
+ Objects.requireNonNull(message, "message");
if (shouldLog(log, level)) {
if (marker != null) {
log(log, level, marker, message);
@@ -97,6 +103,7 @@ public class CamelLogger {
* @param message the message to log
*/
public void doLog(String message) {
+ Objects.requireNonNull(message, "message");
if (marker != null) {
log(log, level, marker, message);
} else {
@@ -105,10 +112,15 @@ public class CamelLogger {
}
public void log(String message, Throwable exception, LoggingLevel loggingLevel) {
+ Objects.requireNonNull(message, "message");
+ Objects.requireNonNull(exception, "exception");
+ Objects.requireNonNull(loggingLevel, "loggingLevel");
log(log, loggingLevel, marker, message, exception);
}
public void log(String message, Throwable exception) {
+ Objects.requireNonNull(message, "message");
+ Objects.requireNonNull(exception, "exception");
if (shouldLog(log, level)) {
log(log, level, marker, message, exception);
}
@@ -119,7 +131,7 @@ public class CamelLogger {
}
public void setLog(Logger log) {
- this.log = log;
+ this.log = Objects.requireNonNull(log, "log");
}
public LoggingLevel getLevel() {
@@ -135,18 +147,19 @@ public class CamelLogger {
}
public void setLogName(String logName) {
+ Objects.requireNonNull(logName, "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 {
@@ -155,6 +168,9 @@ public class CamelLogger {
}
public static void log(Logger log, LoggingLevel level, String message) {
+ Objects.requireNonNull(log, "log");
+ Objects.requireNonNull(level, "level");
+ Objects.requireNonNull(message, "message");
switch (level) {
case DEBUG:
log.debug(message);
@@ -176,6 +192,10 @@ public class CamelLogger {
}
public static void log(Logger log, LoggingLevel level, Marker marker, String message) {
+ Objects.requireNonNull(log, "log");
+ Objects.requireNonNull(level, "level");
+ Objects.requireNonNull(marker, "marker");
+ Objects.requireNonNull(message, "message");
switch (level) {
case DEBUG:
log.debug(marker, message);
@@ -197,6 +217,10 @@ public class CamelLogger {
}
public static void log(Logger log, LoggingLevel level, String message, Throwable th) {
+ Objects.requireNonNull(log, "log");
+ Objects.requireNonNull(level, "level");
+ Objects.requireNonNull(message, "message");
+ Objects.requireNonNull(th, "th");
switch (level) {
case DEBUG:
log.debug(message, th);
@@ -217,7 +241,11 @@ public class CamelLogger {
}
}
- 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) {
+ Objects.requireNonNull(log, "log");
+ Objects.requireNonNull(level, "level");
+ Objects.requireNonNull(message, "message");
+ Objects.requireNonNull(th, "th");
if (marker == null) {
log(log, level, message, th);
return;
@@ -249,6 +277,8 @@ public class CamelLogger {
}
public static boolean shouldLog(Logger log, LoggingLevel level) {
+ Objects.requireNonNull(log, "log");
+ Objects.requireNonNull(level, "level");
switch (level) {
case DEBUG:
return log.isDebugEnabled();
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 cc07b5d91660..2357824e2a5f 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 @@ package org.apache.camel.spi;
import org.apache.camel.Exchange;
import org.apache.camel.Service;
+import org.jspecify.annotations.Nullable;
/**
* Access to a repository of keys to implement the <a href="http://camel.apache.org/claim-check.html">Claim Check</a>
@@ -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 <tt>null</tt> 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 <tt>null</tt> 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 fa0897d1ab4c..8dae03544b2c 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.net.URL;
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 <tt>null</tt> 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, <tt>null</tt> 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, <tt>null</tt> if not found.
*/
- <T> Class<T> resolveClass(String name, Class<T> type);
+ <T> @Nullable Class<T> resolveClass(String name, Class<T> 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, <tt>null</tt> 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, <tt>null</tt> if not found.
*/
- <T> Class<T> resolveClass(String name, Class<T> type, ClassLoader loader);
+ <T> @Nullable Class<T> resolveClass(String name, Class<T> 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 0024c25466ab..18bdfbc6146a 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/CompileStrategy.java b/core/camel-api/src/main/java/org/apache/camel/spi/CompileStrategy.java
index 31111f571f3e..fe9445adfe29 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/ComponentCustomizer.java b/core/camel-api/src/main/java/org/apache/camel/spi/ComponentCustomizer.java
index 2daf2c260acf..a53d08f4701e 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/ComponentCustomizer.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/ComponentCustomizer.java
@@ -23,6 +23,7 @@ import org.apache.camel.Ordered;
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 Component} instances.
@@ -139,7 +140,7 @@ public interface ComponentCustomizer extends Ordered {
*/
class Builder<T extends Component> {
private final Class<T> type;
- private BiPredicate<String, Component> condition;
+ private @Nullable BiPredicate<String, Component> condition;
private int order;
public Builder(Class<T> type) {
@@ -221,10 +222,11 @@ public interface ComponentCustomizer extends Ordered {
};
}
+ final BiPredicate<String, Component> cond = condition;
return new BiPredicate<>() {
@Override
public boolean test(String name, Component target) {
- return type.isAssignableFrom(target.getClass()) && condition.test(name, target);
+ return type.isAssignableFrom(target.getClass()) && cond != null && cond.test(name, target);
}
};
}
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 d836a74ff526..3847bf8a02e2 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 @@ package org.apache.camel.spi;
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 0033d3341575..2e872cd6a1b7 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 <tt>null</tt> 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/ConfigurerStrategy.java b/core/camel-api/src/main/java/org/apache/camel/spi/ConfigurerStrategy.java
index b2893743b84c..773561ab862d 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/ConfigurerStrategy.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/ConfigurerStrategy.java
@@ -18,6 +18,7 @@ package org.apache.camel.spi;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
/**
* Strategy for configurers.
@@ -27,6 +28,7 @@ public abstract class ConfigurerStrategy {
private static final List<Runnable> BOOTSTRAP_CLEARERS = new ArrayList<>();
public static void addBootstrapConfigurerClearer(Runnable strategy) {
+ Objects.requireNonNull(strategy, "strategy");
BOOTSTRAP_CLEARERS.add(strategy);
}
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 38be3addd27d..d639bffc0ee3 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.Endpoint;
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 <tt>null</tt> 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 <tt>null</tt>
*/
+ @Nullable
Exchange receiveNoWait(Endpoint endpoint);
/**
@@ -120,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/ContentTypeAware.java b/core/camel-api/src/main/java/org/apache/camel/spi/ContentTypeAware.java
index d50553c7a69b..2f498a75ab9e 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 d6383b3ffbb2..e5f7bb033ce3 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
@@ -16,21 +16,24 @@
*/
package org.apache.camel.spi;
+import java.util.Objects;
+
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}.
*/
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 DataType getInputType() {
+ public @Nullable DataType getInputType() {
return inputType;
}
@@ -40,6 +43,7 @@ public class Contract {
* @param inputType input data type
*/
public void setInputType(String inputType) {
+ Objects.requireNonNull(inputType, "inputType");
this.inputType = new DataType(inputType);
this.contractString = null;
}
@@ -50,11 +54,12 @@ public class Contract {
* @param clazz Java class which represents input data type
*/
public void setInputType(Class<?> clazz) {
+ Objects.requireNonNull(clazz, "clazz");
this.inputType = new DataType(clazz);
this.contractString = null;
}
- public DataType getOutputType() {
+ public @Nullable DataType getOutputType() {
return outputType;
}
@@ -64,6 +69,7 @@ public class Contract {
* @param outputType output data type
*/
public void setOutputType(String outputType) {
+ Objects.requireNonNull(outputType, "outputType");
this.outputType = new DataType(outputType);
this.contractString = null;
}
@@ -74,6 +80,7 @@ public class Contract {
* @param clazz Java class which represents output data type
*/
public void setOutputType(Class<?> clazz) {
+ Objects.requireNonNull(clazz, "clazz");
this.outputType = new DataType(clazz);
this.contractString = null;
}
@@ -113,7 +120,7 @@ public class Contract {
}
@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/DataFormatCustomizer.java b/core/camel-api/src/main/java/org/apache/camel/spi/DataFormatCustomizer.java
index 12aaece25caa..4ee55e5aa3ec 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/DataFormatCustomizer.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/DataFormatCustomizer.java
@@ -23,6 +23,7 @@ import org.apache.camel.Ordered;
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 DataFormat} instances.
@@ -139,7 +140,7 @@ public interface DataFormatCustomizer extends Ordered {
*/
class Builder<T extends DataFormat> {
private final Class<T> type;
- private BiPredicate<String, DataFormat> condition;
+ private @Nullable BiPredicate<String, DataFormat> condition;
private int order;
public Builder(Class<T> type) {
@@ -221,10 +222,11 @@ public interface DataFormatCustomizer extends Ordered {
};
}
+ final BiPredicate<String, DataFormat> cond = condition;
return new BiPredicate<>() {
@Override
public boolean test(String name, DataFormat target) {
- return type.isAssignableFrom(target.getClass()) && condition.test(name, target);
+ return type.isAssignableFrom(target.getClass()) && cond != null && cond.test(name, target);
}
};
}
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 b2ada308dd81..aa8aa4cbf912 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 <tt>null</tt> 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 eff7ab184a16..aac9ad7e939f 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
@@ -16,7 +16,10 @@
*/
package org.apache.camel.spi;
+import java.util.Objects;
+
import org.apache.camel.util.StringHelper;
+import org.jspecify.annotations.Nullable;
/**
* Represents the data type URN which is used for message data type contract.
@@ -48,11 +51,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];
@@ -67,6 +70,7 @@ public class DataType {
}
public DataType(Class<?> clazz) {
+ Objects.requireNonNull(clazz, "clazz");
scheme = JAVA_TYPE_SCHEME;
isJavaType = true;
name = clazz.getName();
@@ -76,7 +80,7 @@ public class DataType {
return scheme;
}
- public String getName() {
+ public @Nullable String getName() {
return name;
}
@@ -96,16 +100,16 @@ public class DataType {
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/DataTypeAware.java b/core/camel-api/src/main/java/org/apache/camel/spi/DataTypeAware.java
index 9a22e4c13b21..1ba5a601db80 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 1a32da721f9b..db594c49859a 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 @@ package org.apache.camel.spi;
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<String, String> getServiceMetadata() {
+ default @Nullable Map<String, String> 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 1d70e670fee4..2a276b1e41b0 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.List;
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 @@ public interface EndpointServiceRegistry extends StaticService {
*
* @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 @@ public interface EndpointServiceRegistry extends StaticService {
*
* @return optional metadata or null if no data
*/
- default Map<String, String> getServiceMetadata() {
+ default @Nullable Map<String, String> getServiceMetadata() {
return null;
}
@@ -91,6 +94,7 @@ public interface EndpointServiceRegistry extends StaticService {
/**
* 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 9d7f61e97e43..cab4955315ea 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 b8bb1dea77cf..a8bef47a992a 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 @@ package org.apache.camel.spi;
import java.time.Instant;
+import org.jspecify.annotations.Nullable;
+
/**
* A snapshot of an error that occurred during message routing.
* <p/>
@@ -38,6 +40,7 @@ public interface ErrorRegistryEntry {
/**
* The endpoint URI where the error occurred (if available)
*/
+ @Nullable
String endpointUri();
/**
@@ -58,6 +61,7 @@ public interface ErrorRegistryEntry {
/**
* The exception message
*/
+ @Nullable
String exceptionMessage();
/**
@@ -65,12 +69,12 @@ public interface ErrorRegistryEntry {
* <p/>
* 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.
* <p/>
* 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 af3387fe5632..185af1b4b523 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.Endpoint;
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 @@ public interface EventFactory {
*/
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/ExceptionHandler.java b/core/camel-api/src/main/java/org/apache/camel/spi/ExceptionHandler.java
index 14f90be07fd1..06245220ab4d 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 3ecaf4c88415..c7f6f902863b 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.Consumer;
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<Exchange>, NonManag
/**
* The consumer using this factory.
*/
+ @Nullable
Consumer getConsumer();
/**
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 34bdcc3826a6..4e3ae04c32d2 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 java.util.concurrent.ThreadFactory;
import org.apache.camel.ShutdownableService;
import org.apache.camel.StaticService;
+import org.jspecify.annotations.Nullable;
/**
* Strategy to create thread pools.
@@ -110,6 +111,7 @@ public interface ExecutorServiceManager extends ShutdownableService, StaticServi
* @param id id of the thread pool profile to get
* @return the found profile, or <tt>null</tt> if not found
*/
+ @Nullable
ThreadPoolProfile getThreadPoolProfile(String id);
/**
@@ -218,6 +220,7 @@ public interface ExecutorServiceManager extends ShutdownableService, StaticServi
* @param profileId the id of the profile with the thread pool settings to use
* @return the created thread pool, or <tt>null</tt> 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 0e95d606b933..8ac4084e03da 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/GroovyScriptCompiler.java b/core/camel-api/src/main/java/org/apache/camel/spi/GroovyScriptCompiler.java
index c234a7339cac..4386384c9ade 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/GroovyScriptCompiler.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/GroovyScriptCompiler.java
@@ -71,6 +71,9 @@ public interface GroovyScriptCompiler {
boolean exists = false;
PackageScanResourceResolver resolver
= context.getCamelContextExtension().getContextPlugin(PackageScanResourceResolver.class);
+ if (resolver == null) {
+ return false;
+ }
for (String pattern : scriptPattern.split(",")) {
// include all kind of resources
for (Resource resource : resolver.findResources(pattern, n -> true)) {
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 6df1a6f5d976..1d8fc9c90832 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/HasCamelContext.java b/core/camel-api/src/main/java/org/apache/camel/spi/HasCamelContext.java
index 73b6e0a450eb..113dd4681bcb 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/HasCamelContext.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/HasCamelContext.java
@@ -17,6 +17,7 @@
package org.apache.camel.spi;
import org.apache.camel.CamelContext;
+import org.jspecify.annotations.Nullable;
/**
* A simple marker interface for an object which holds a {@link CamelContext}.
@@ -28,5 +29,6 @@ public interface HasCamelContext {
*
* @return the camel context.
*/
+ @Nullable
CamelContext getCamelContext();
}
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 f327d4e7f19a..58cb623ab02a 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 9a2d6519e305..8768e0d044a7 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 @@ public interface HeaderFilterStrategy {
* @param exchange the context to perform filtering
* @return <tt>true</tt> 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 @@ public interface HeaderFilterStrategy {
* @param exchange the context to perform filtering
* @return <tt>true</tt> 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 3e84e84bc9bd..4b836e7cde31 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 a9bf0ebd19a1..2efa06f4ba5e 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 a4704984055b..046ac36f9a7e 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 java.util.Collection;
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 @@ public interface InflightRepository extends StaticService {
* <p/>
* Is <tt>null</tt> if message history is disabled.
*/
+ @Nullable
String getNodeId();
/**
@@ -68,6 +70,7 @@ public interface InflightRepository extends StaticService {
* <p/>
* Is <tt>null</tt> if message history is disabled.
*/
+ @Nullable
String getAtRouteId();
}
@@ -166,7 +169,7 @@ public interface InflightRepository extends StaticService {
*
* @param fromRouteId the route id, or <tt>null</tt> for all routes.
*/
- Collection<InflightExchange> browse(String fromRouteId);
+ Collection<InflightExchange> browse(@Nullable String fromRouteId);
/**
* A <i>read-only</i> browser of the {@link InflightExchange}s that are currently inflight.
@@ -186,7 +189,7 @@ public interface InflightRepository extends StaticService {
* @param sortByLongestDuration to sort by the longest duration. Set to <tt>true</tt> to include the exchanges that
* has been inflight the longest time, set to <tt>false</tt> to sort by exchange id
*/
- Collection<InflightExchange> browse(String fromRouteId, int limit, boolean sortByLongestDuration);
+ Collection<InflightExchange> 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 @@ public interface InflightRepository extends StaticService {
* @param fromRouteId the route id, or <tt>null</tt> for all routes.
* @return the oldest, or <tt>null</tt> 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 f150e441e72d..c52158770b7c 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.CamelContext;
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 5a4417f353ff..b8badf4fb22b 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 @@ package org.apache.camel.spi;
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 b290b73b4b1b..6044968658bc 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 @@ package org.apache.camel.spi;
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 3e338080e7da..92f31c1039b1 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.CamelContext;
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 <tt>null</tt> if no advices has been added with the given type.
*/
- <T> T getAdvice(Class<T> type);
+ <T> @Nullable T getAdvice(Class<T> 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 7344c3a6962a..b2ebbc38d856 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.Predicate;
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 07060b516423..7f562757c04e 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 @@ package org.apache.camel.spi;
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 970fbf25a914..33953efe2cce 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.Ordered;
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 interface LanguageCustomizer extends Ordered {
*/
class Builder<T extends Language> {
private final Class<T> type;
- private BiPredicate<String, Language> condition;
+ private @Nullable BiPredicate<String, Language> condition;
private int order;
public Builder(Class<T> 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 c035c773be14..737de85ab25d 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.Endpoint;
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 @@ public interface LifecycleStrategy {
* @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 @@ public interface LifecycleStrategy {
* @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 @@ public interface LifecycleStrategy {
* @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 @@ public interface LifecycleStrategy {
* @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 @@ public interface LifecycleStrategy {
* @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 f9a2c747f330..71c0e436c53b 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 <tt>null</tt> 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 96b90989f814..07196df0516c 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 javax.management.ObjectName;
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 <tt>null</tt> if mbean does not exist
*/
- <T> T newProxyClient(ObjectName name, Class<T> mbean);
+ <T> @Nullable T newProxyClient(ObjectName name, Class<T> 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 828c080063b6..a0f96c5e751f 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.Exchange;
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<T> 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 b3d158aeefb1..7584e8464fac 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.ObjectName;
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 a5afb8dd64ec..b0b6207d413c 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 <tt>null</tt> 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 64bd66b15e95..a8ae8a6cf75d 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.Producer;
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 @@ public interface ManagementObjectNameStrategy {
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 1a44a9887c0f..26e1792958b3 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.Route;
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 @@ public interface ManagementObjectStrategy {
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 444cb9cd2d98..7666c72b07ca 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 @@ package org.apache.camel.spi;
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 c3b7123bb709..fe7ab740dc12 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.Exchange;
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 781c4245e8f9..b928475f4000 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 81470a3f5a4c..c5acc7d8d648 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 such as XML or YAML dump).
*
@@ -26,6 +28,6 @@ package org.apache.camel.spi;
* @param code EIP code such as label or short name that is human-readable or pseudocode
* @param description optional description of the EIP node
*/
-public record ModelDumpLine(String location, String type, String id, int level, String code, String description) {
-
+public record ModelDumpLine(@Nullable String location, String type, String id, int level, String code,
+ @Nullable String description) {
}
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 a6602ffd3a96..ae2d463de340 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 @@ package org.apache.camel.spi;
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<String, String> getNamespaces();
}
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 3de233754e6c..5c49bc083755 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,10 @@
*/
package org.apache.camel.spi;
+import java.util.Objects;
+
+import org.jspecify.annotations.Nullable;
+
/**
* Configuration for OAuth 2.0 Client Credentials grant.
* <p/>
@@ -24,46 +28,46 @@ package org.apache.camel.spi;
*/
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;
}
public OAuthClientConfig setClientId(String clientId) {
- this.clientId = clientId;
+ this.clientId = Objects.requireNonNull(clientId, "clientId");
return this;
}
- public String getClientSecret() {
+ public @Nullable String getClientSecret() {
return clientSecret;
}
public OAuthClientConfig setClientSecret(String clientSecret) {
- this.clientSecret = clientSecret;
+ this.clientSecret = Objects.requireNonNull(clientSecret, "clientSecret");
return this;
}
- public String getTokenEndpoint() {
+ public @Nullable String getTokenEndpoint() {
return tokenEndpoint;
}
public OAuthClientConfig setTokenEndpoint(String tokenEndpoint) {
- this.tokenEndpoint = tokenEndpoint;
+ this.tokenEndpoint = Objects.requireNonNull(tokenEndpoint, "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/OnCamelContextEvent.java b/core/camel-api/src/main/java/org/apache/camel/spi/OnCamelContextEvent.java
index 968cfc897e95..67b667760c26 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/OptimisticLockingAggregationRepository.java b/core/camel-api/src/main/java/org/apache/camel/spi/OptimisticLockingAggregationRepository.java
index a91d1e3fac3b..ac885e02c9c7 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 java.io.Serial;
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 @@ public interface OptimisticLockingAggregationRepository extends AggregationRepos
* @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 61b35fc7e274..c57bafd33d9e 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 <tt>null</tt> if no tasks exists
*/
- <T> T getTaskByType(Class<T> type);
+ <T> @Nullable T getTaskByType(Class<T> 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 8cbd505a87bc..cfc94a7dcf61 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 @@ package org.apache.camel.spi;
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 <tt>null</tt> if no extension has been installed.
*/
- <T> T getContextPlugin(Class<T> type);
+ <T> @Nullable T getContextPlugin(Class<T> 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 9e6b22d6cd33..b01abcf268b8 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.CamelContextAware;
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 interface PollDynamicAware extends Service, CamelContextAware {
* @return the static uri, or <tt>null</tt> 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 6b3053aa6325..d19179fbbd05 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 @@ package org.apache.camel.spi;
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 @@ public interface PooledObjectFactory<T> extends Service, CamelContextAware {
*
* @return the statistics, or null if statistics is not enabled
*/
+ @Nullable
Statistics getStatistics();
/**
@@ -108,6 +110,7 @@ public interface PooledObjectFactory<T> extends Service, CamelContextAware {
*
* @return the object or <tt>null</tt> 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 8e70a5ca9900..44b0124c0425 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 @@ package org.apache.camel.spi;
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 <tt>null</tt> 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 56355c9ad161..9a00403ae8ac 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.CamelContext;
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 <tt>null</tt> 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 fb841d2b50b3..0aa0248e3f41 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.ExchangePattern;
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<Exchange> asyncSendExchange(
Endpoint endpoint, ExchangePattern pattern,
- Processor processor, Processor resultProcessor, Exchange exchange, CompletableFuture<Exchange> future);
+ Processor processor, @Nullable Processor resultProcessor, @Nullable Exchange exchange,
+ @Nullable CompletableFuture<Exchange> 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 fc1d586cfc01..250731b7128a 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 java.util.function.Predicate;
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 @@ public interface PropertiesComponent extends StaticService {
* @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 @@ public interface PropertiesComponent extends StaticService {
* @param name the function name
* @return the function or null if no function exists
*/
+ @Nullable
PropertiesFunction getPropertiesFunction(String name);
/**
@@ -269,12 +272,13 @@ public interface PropertiesComponent extends StaticService {
* 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 <tt>null</tt> if not
* currently in use.
*/
+ @Nullable
Properties getLocalProperties();
/**
@@ -284,7 +288,7 @@ public interface PropertiesComponent extends StaticService {
* @return a {@link Map} representing the local properties, or <tt>null</tt> if not currently in use.
*/
@SuppressWarnings("unchecked")
- default Map<String, Object> getLocalPropertiesAsMap() {
+ default @Nullable Map<String, Object> getLocalPropertiesAsMap() {
return (Map) getLocalProperties();
}
@@ -304,7 +308,7 @@ public interface PropertiesComponent extends StaticService {
* @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 2863b5065f78..03b9c934932d 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 0e0a6ff3db0a..61ac1eaa0ba3 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 <tt>null</tt> 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 <tt>null</tt> 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 6c1b7639b41f..832675254496 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 ee617212e4e0..79f7eb548263 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 <tt>null</tt> 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 @@ public interface PropertyConfigurerGetter {
* @return the class type, or <tt>null</tt> 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 @@ public interface PropertyConfigurerGetter {
* @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 b570fc0052f8..4379bd2aefba 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 java.util.concurrent.TimeUnit;
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 <tt>null</tt> if not found
*/
+ @Nullable
Exchange recover(CamelContext camelContext, String exchangeId);
/**
@@ -101,13 +103,14 @@ public interface RecoverableAggregationRepository extends AggregationRepository
*
* @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 48601f45adea..345d50bfbe25 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 java.util.function.Supplier;
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 @@ public interface Registry extends BeanRepository {
* @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 @@ public interface Registry extends BeanRepository {
* @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 @@ public interface Registry extends BeanRepository {
* @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<Object> bean, String initMethod, String destroyMethod)
+ void bind(
+ String id, Class<?> type, Supplier<Object> 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 ca32988afb27..2891c74a18ca 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 @@ package org.apache.camel.spi;
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 b5c04bbb06d0..e4763d00a228 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.net.URL;
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 @@ public interface Resource {
* </p>
* 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 3469b4ef0003..2c6c2d7814e4 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 @@ public interface ResourceAware {
/**
* 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 ea15a3d01fbf..aa06690e564f 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 @@ package org.apache.camel.spi;
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 ac032e1d41b7..eabaf4d3179e 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 12cfce11903b..d6a6c337a70c 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 15479e86a9d8..cf31e203f4cf 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.Map;
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 @@ public interface RestClientRequestValidator {
* @param validationContent validation context
* @return the validation error, or <tt>null</tt> 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 b01d1dbc7d95..4168a89cc03c 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.Map;
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 @@ public interface RestClientResponseValidator {
* @param validationContent validation context
* @return the validation error, or <tt>null</tt> 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 413e9538f346..89bf0f8e5232 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
@@ -17,6 +17,9 @@
package org.apache.camel.spi;
import java.util.Map;
+import java.util.Objects;
+
+import org.jspecify.annotations.Nullable;
/**
* Configuration use by {@link org.apache.camel.spi.RestConsumerFactory} and
@@ -49,37 +52,37 @@ public class RestConfiguration {
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<String, Object> componentProperties;
- private Map<String, Object> endpointProperties;
- private Map<String, Object> consumerProperties;
- private Map<String, Object> dataFormatProperties;
- private Map<String, Object> apiProperties;
- private Map<String, String> corsHeaders;
- private Map<String, String> validationLevels;
+ private @Nullable String jsonDataFormat;
+ private @Nullable String xmlDataFormat;
+ private @Nullable Map<String, Object> componentProperties;
+ private @Nullable Map<String, Object> endpointProperties;
+ private @Nullable Map<String, Object> consumerProperties;
+ private @Nullable Map<String, Object> dataFormatProperties;
+ private @Nullable Map<String, Object> apiProperties;
+ private @Nullable Map<String, String> corsHeaders;
+ private @Nullable Map<String, String> validationLevels;
/**
* Gets the name of the Camel component to use as the REST consumer
@@ -87,7 +90,7 @@ public class RestConfiguration {
* @return the component name, or <tt>null</tt> to let Camel search the {@link Registry} to find suitable
* implementation
*/
- public String getComponent() {
+ public @Nullable String getComponent() {
return component;
}
@@ -97,7 +100,7 @@ public class RestConfiguration {
* @param componentName the name of the component (such as netty-http, jetty, servlet, undertow, etc.)
*/
public void setComponent(String componentName) {
- this.component = componentName;
+ this.component = Objects.requireNonNull(componentName, "componentName");
}
/**
@@ -105,7 +108,7 @@ public class RestConfiguration {
*
* @return the component name
*/
- public String getApiComponent() {
+ public @Nullable String getApiComponent() {
return apiComponent;
}
@@ -115,7 +118,7 @@ public class RestConfiguration {
* @param apiComponent the name of the component (such as swagger or openapi)
*/
public void setApiComponent(String apiComponent) {
- this.apiComponent = apiComponent;
+ this.apiComponent = Objects.requireNonNull(apiComponent, "apiComponent");
}
/**
@@ -124,7 +127,7 @@ public class RestConfiguration {
* @return the component name, or <tt>null</tt> to let Camel search the {@link Registry} to find suitable
* implementation
*/
- public String getProducerComponent() {
+ public @Nullable String getProducerComponent() {
return producerComponent;
}
@@ -134,14 +137,14 @@ public class RestConfiguration {
* @param componentName the name of the component (such as http, netty-http, undertow, etc.)
*/
public void setProducerComponent(String componentName) {
- this.producerComponent = componentName;
+ this.producerComponent = Objects.requireNonNull(componentName, "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;
}
@@ -154,7 +157,7 @@ public class RestConfiguration {
* <tt>http:</tt> to refer to resources to load from file or http url.
*/
public void setProducerApiDoc(String producerApiDoc) {
- this.producerApiDoc = producerApiDoc;
+ this.producerApiDoc = Objects.requireNonNull(producerApiDoc, "producerApiDoc");
}
/**
@@ -162,7 +165,7 @@ public class RestConfiguration {
*
* @return the hostname, or <tt>null</tt> to use default hostname
*/
- public String getHost() {
+ public @Nullable String getHost() {
return host;
}
@@ -172,7 +175,7 @@ public class RestConfiguration {
* @param host the hostname
*/
public void setHost(String host) {
- this.host = host;
+ this.host = Objects.requireNonNull(host, "host");
}
/**
@@ -197,7 +200,7 @@ public class RestConfiguration {
this.useXForwardHeaders = useXForwardHeaders;
}
- public String getApiHost() {
+ public @Nullable String getApiHost() {
return apiHost;
}
@@ -207,7 +210,7 @@ public class RestConfiguration {
* This can be used to override the generated host with this configured hostname
*/
public void setApiHost(String apiHost) {
- this.apiHost = apiHost;
+ this.apiHost = Objects.requireNonNull(apiHost, "apiHost");
}
/**
@@ -215,7 +218,7 @@ public class RestConfiguration {
*
* @return the scheme, or <tt>null</tt> to use default scheme
*/
- public String getScheme() {
+ public @Nullable String getScheme() {
return scheme;
}
@@ -225,7 +228,7 @@ public class RestConfiguration {
* @param scheme the scheme
*/
public void setScheme(String scheme) {
- this.scheme = scheme;
+ this.scheme = Objects.requireNonNull(scheme, "scheme");
}
/**
@@ -251,7 +254,7 @@ public class RestConfiguration {
*
* @return the context path, or <tt>null</tt> if none configured.
*/
- public String getContextPath() {
+ public @Nullable String getContextPath() {
return contextPath;
}
@@ -265,10 +268,10 @@ public class RestConfiguration {
* @param contextPath the context path
*/
public void setContextPath(String contextPath) {
- this.contextPath = contextPath;
+ this.contextPath = Objects.requireNonNull(contextPath, "contextPath");
}
- public String getApiContextPath() {
+ public @Nullable String getApiContextPath() {
return apiContextPath;
}
@@ -281,10 +284,10 @@ public class RestConfiguration {
* @param contextPath the API context path
*/
public void setApiContextPath(String contextPath) {
- this.apiContextPath = contextPath;
+ this.apiContextPath = Objects.requireNonNull(contextPath, "contextPath");
}
- public String getApiContextRouteId() {
+ public @Nullable String getApiContextRouteId() {
return apiContextRouteId;
}
@@ -296,7 +299,7 @@ public class RestConfiguration {
* @param apiContextRouteId the route id
*/
public void setApiContextRouteId(String apiContextRouteId) {
- this.apiContextRouteId = apiContextRouteId;
+ this.apiContextRouteId = Objects.requireNonNull(apiContextRouteId, "apiContextRouteId");
}
public boolean isApiVendorExtension() {
@@ -327,7 +330,7 @@ public class RestConfiguration {
* @param hostNameResolver the resolver
*/
public void setHostNameResolver(RestHostNameResolver hostNameResolver) {
- this.hostNameResolver = hostNameResolver;
+ this.hostNameResolver = Objects.requireNonNull(hostNameResolver, "hostNameResolver");
}
/**
@@ -336,6 +339,7 @@ public class RestConfiguration {
* @param hostNameResolver the resolver
*/
public void setHostNameResolver(String hostNameResolver) {
+ Objects.requireNonNull(hostNameResolver, "hostNameResolver");
this.hostNameResolver = RestHostNameResolver.valueOf(hostNameResolver);
}
@@ -354,7 +358,7 @@ public class RestConfiguration {
* @param bindingMode the binding mode
*/
public void setBindingMode(RestBindingMode bindingMode) {
- this.bindingMode = bindingMode;
+ this.bindingMode = Objects.requireNonNull(bindingMode, "bindingMode");
}
/**
@@ -363,10 +367,11 @@ public class RestConfiguration {
* @param bindingMode the binding mode
*/
public void setBindingMode(String bindingMode) {
+ Objects.requireNonNull(bindingMode, "bindingMode");
this.bindingMode = RestBindingMode.valueOf(bindingMode);
}
- public String getBindingPackageScan() {
+ public @Nullable String getBindingPackageScan() {
return bindingPackageScan;
}
@@ -375,7 +380,7 @@ public class RestConfiguration {
* is enabled for JSon or XML. Multiple package names can be separated by comma.
*/
public void setBindingPackageScan(String bindingPackageScan) {
- this.bindingPackageScan = bindingPackageScan;
+ this.bindingPackageScan = Objects.requireNonNull(bindingPackageScan, "bindingPackageScan");
}
/**
@@ -496,7 +501,7 @@ public class RestConfiguration {
*
* @return the name, or <tt>null</tt> to use default
*/
- public String getJsonDataFormat() {
+ public @Nullable String getJsonDataFormat() {
return jsonDataFormat;
}
@@ -509,7 +514,7 @@ public class RestConfiguration {
* @param name name of the data format
*/
public void setJsonDataFormat(String name) {
- this.jsonDataFormat = name;
+ this.jsonDataFormat = Objects.requireNonNull(name, "name");
}
/**
@@ -520,7 +525,7 @@ public class RestConfiguration {
*
* @return the name, or <tt>null</tt> to use default
*/
- public String getXmlDataFormat() {
+ public @Nullable String getXmlDataFormat() {
return xmlDataFormat;
}
@@ -533,7 +538,7 @@ public class RestConfiguration {
* @param name name of the data format
*/
public void setXmlDataFormat(String name) {
- this.xmlDataFormat = name;
+ this.xmlDataFormat = Objects.requireNonNull(name, "name");
}
/**
@@ -541,7 +546,7 @@ public class RestConfiguration {
*
* @return additional options
*/
- public Map<String, Object> getComponentProperties() {
+ public @Nullable Map<String, Object> getComponentProperties() {
return componentProperties;
}
@@ -551,7 +556,7 @@ public class RestConfiguration {
* @param componentProperties the options
*/
public void setComponentProperties(Map<String, Object> componentProperties) {
- this.componentProperties = componentProperties;
+ this.componentProperties = Objects.requireNonNull(componentProperties, "componentProperties");
}
/**
@@ -559,7 +564,7 @@ public class RestConfiguration {
*
* @return additional options
*/
- public Map<String, Object> getEndpointProperties() {
+ public @Nullable Map<String, Object> getEndpointProperties() {
return endpointProperties;
}
@@ -569,7 +574,7 @@ public class RestConfiguration {
* @param endpointProperties the options
*/
public void setEndpointProperties(Map<String, Object> endpointProperties) {
- this.endpointProperties = endpointProperties;
+ this.endpointProperties = Objects.requireNonNull(endpointProperties, "endpointProperties");
}
/**
@@ -577,7 +582,7 @@ public class RestConfiguration {
*
* @return additional options
*/
- public Map<String, Object> getConsumerProperties() {
+ public @Nullable Map<String, Object> getConsumerProperties() {
return consumerProperties;
}
@@ -587,7 +592,7 @@ public class RestConfiguration {
* @param consumerProperties the options
*/
public void setConsumerProperties(Map<String, Object> consumerProperties) {
- this.consumerProperties = consumerProperties;
+ this.consumerProperties = Objects.requireNonNull(consumerProperties, "consumerProperties");
}
/**
@@ -595,7 +600,7 @@ public class RestConfiguration {
*
* @return additional options
*/
- public Map<String, Object> getDataFormatProperties() {
+ public @Nullable Map<String, Object> getDataFormatProperties() {
return dataFormatProperties;
}
@@ -605,10 +610,10 @@ public class RestConfiguration {
* @param dataFormatProperties the options
*/
public void setDataFormatProperties(Map<String, Object> dataFormatProperties) {
- this.dataFormatProperties = dataFormatProperties;
+ this.dataFormatProperties = Objects.requireNonNull(dataFormatProperties, "dataFormatProperties");
}
- public Map<String, Object> getApiProperties() {
+ public @Nullable Map<String, Object> getApiProperties() {
return apiProperties;
}
@@ -618,7 +623,7 @@ public class RestConfiguration {
* @param apiProperties the options
*/
public void setApiProperties(Map<String, Object> apiProperties) {
- this.apiProperties = apiProperties;
+ this.apiProperties = Objects.requireNonNull(apiProperties, "apiProperties");
}
/**
@@ -626,7 +631,7 @@ public class RestConfiguration {
*
* @return the CORS headers
*/
- public Map<String, String> getCorsHeaders() {
+ public @Nullable Map<String, String> getCorsHeaders() {
return corsHeaders;
}
@@ -636,7 +641,7 @@ public class RestConfiguration {
* @param corsHeaders the CORS headers
*/
public void setCorsHeaders(Map<String, String> corsHeaders) {
- this.corsHeaders = corsHeaders;
+ this.corsHeaders = Objects.requireNonNull(corsHeaders, "corsHeaders");
}
/**
@@ -644,7 +649,7 @@ public class RestConfiguration {
*
* @return the validation levels
*/
- public Map<String, String> getValidationLevels() {
+ public @Nullable Map<String, String> getValidationLevels() {
return validationLevels;
}
@@ -652,6 +657,6 @@ public class RestConfiguration {
* Sets the client request validation levels when using camel-openapi-validator.
*/
public void setValidationLevels(Map<String, String> validationLevels) {
- this.validationLevels = validationLevels;
+ this.validationLevels = Objects.requireNonNull(validationLevels, "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 06ccdb8f94ae..8b4ca6deb2a4 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 java.util.Map;
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<String, Object> parameters)
+ CamelContext camelContext, Processor processor, String verb, String basePath,
+ @Nullable String uriTemplate,
+ @Nullable String consumes, @Nullable String produces, RestConfiguration configuration,
+ Map<String, Object> 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 0f28fda5b513..2430217633cb 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 java.util.Map;
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,
... 4549 lines suppressed ...