GH-10083: Migrate spring-integration-camel to JSpecify Nullable

Related to: https://github.com/spring-projects/spring-integration/issues/10083

This change is applicable only to `spring-integration-camel`.

*Replaced `org.springframework.lang.Nullable` with `org.jspecify.annotations.Nullable`.
* Handled changes in `package-info.java`
* Handled nullable related issues in `CamelMessageHandler`.

Fixed issues in `CamelMessageHandler` as per review comments (suppressed warnings for `NullAway.Init` so that `Objects.requireNonNull` is not needed).

Signed-off-by: Anayonkar Shivalkar <anayonkar.shivalkar@gmail.com>
This commit is contained in:
Anayonkar Shivalkar
2025-06-10 00:45:21 +05:30
committed by GitHub
parent ed544de72a
commit b07d04f9e5
6 changed files with 12 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2022-2024 the original author or authors.
* Copyright 2022-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,8 +19,7 @@ package org.springframework.integration.camel.dsl;
import org.apache.camel.ExchangePattern;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.LambdaRouteBuilder;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
/**
* Factory class for Apache Camel components DSL.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2022 the original author or authors.
* Copyright 2022-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import java.util.function.Function;
import org.apache.camel.ExchangePattern;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.LambdaRouteBuilder;
import org.jspecify.annotations.Nullable;
import org.springframework.expression.Expression;
import org.springframework.integration.camel.outbound.CamelMessageHandler;
@@ -30,7 +31,6 @@ import org.springframework.integration.camel.support.CamelHeaderMapper;
import org.springframework.integration.dsl.MessageHandlerSpec;
import org.springframework.integration.expression.FunctionExpression;
import org.springframework.integration.mapping.HeaderMapper;
import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.util.Assert;

View File

@@ -2,6 +2,5 @@
* Provides supporting classes for JavaDSL with Apache Camel components.
*/
@org.springframework.lang.NonNullApi
@org.springframework.lang.NonNullFields
@org.jspecify.annotations.NullMarked
package org.springframework.integration.camel.dsl;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2022 the original author or authors.
* Copyright 2022-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.LambdaRouteBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.RouteDefinition;
import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanInitializationException;
@@ -40,7 +41,6 @@ import org.springframework.integration.expression.ValueExpression;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.mapping.HeaderMapper;
import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -68,6 +68,7 @@ import org.springframework.util.StringUtils;
*/
public class CamelMessageHandler extends AbstractReplyProducingMessageHandler {
@SuppressWarnings("NullAway.Init")
private ProducerTemplate producerTemplate;
private Expression exchangePatternExpression = new ValueExpression<>(ExchangePattern.InOnly);
@@ -83,6 +84,7 @@ public class CamelMessageHandler extends AbstractReplyProducingMessageHandler {
@Nullable
private Expression exchangePropertiesExpression;
@SuppressWarnings("NullAway.Init")
private StandardEvaluationContext evaluationContext;
public CamelMessageHandler() {
@@ -197,6 +199,7 @@ public class CamelMessageHandler extends AbstractReplyProducingMessageHandler {
}
@Override
@Nullable
protected Object handleRequestMessage(Message<?> requestMessage) {
ExchangePattern exchangePattern =
this.exchangePatternExpression.getValue(this.evaluationContext, requestMessage, ExchangePattern.class);

View File

@@ -2,6 +2,5 @@
* Provides classes for Apache Camel outbound channel adapters.
*/
@org.springframework.lang.NonNullApi
@org.springframework.lang.NonNullFields
@org.jspecify.annotations.NullMarked
package org.springframework.integration.camel.outbound;

View File

@@ -2,6 +2,5 @@
* Provides supporting classes for Apache Camel channel adapters.
*/
@org.springframework.lang.NonNullApi
@org.springframework.lang.NonNullFields
@org.jspecify.annotations.NullMarked
package org.springframework.integration.camel.support;