Skip to content

Commit 395936f

Browse files
authored
spring-projectsGH-10083: Migrate spring-integration-cassandra to JSpecify
Related to: spring-projects#10083 * Replaced deprecated Spring Framework Nullability API with JSpecify one. * Fix null-away problems in Cassandra module Signed-off-by: Anayonkar Shivalkar <[email protected]> Co-authored-with: Artem Bilan <[email protected]>
1 parent 2efd22b commit 395936f

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

spring-integration-cassandra/src/main/java/org/springframework/integration/cassandra/config/xml/package-info.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 the original author or authors.
2+
* Copyright 2022-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,4 +17,5 @@
1717
/**
1818
* Provides classes for Cassandra parsers and namespace handlers.
1919
*/
20+
@org.jspecify.annotations.NullMarked
2021
package org.springframework.integration.cassandra.config.xml;
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
22
* Provides Apache Cassandra Components support for the Java DSL.
33
*/
4-
@org.springframework.lang.NonNullApi
5-
@org.springframework.lang.NonNullFields
4+
@org.jspecify.annotations.NullMarked
65
package org.springframework.integration.cassandra.dsl;

spring-integration-cassandra/src/main/java/org/springframework/integration/cassandra/outbound/CassandraMessageHandler.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
2828
import com.datastax.oss.driver.api.core.cql.Statement;
2929
import com.datastax.oss.driver.api.querybuilder.QueryBuilder;
30+
import org.jspecify.annotations.Nullable;
3031
import reactor.core.publisher.Flux;
3132
import reactor.core.publisher.Mono;
3233

@@ -50,7 +51,6 @@
5051
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
5152
import org.springframework.integration.handler.ExpressionEvaluatingMessageProcessor;
5253
import org.springframework.integration.handler.MessageProcessor;
53-
import org.springframework.lang.Nullable;
5454
import org.springframework.messaging.Message;
5555
import org.springframework.util.Assert;
5656

@@ -85,8 +85,10 @@ public class CassandraMessageHandler extends AbstractReplyProducingMessageHandle
8585
*/
8686
private WriteOptions writeOptions;
8787

88+
@SuppressWarnings("NullAway.Init")
8889
private ReactiveSessionMessageCallback sessionMessageCallback;
8990

91+
@SuppressWarnings("NullAway.Init")
9092
private EvaluationContext evaluationContext;
9193

9294
public CassandraMessageHandler(ReactiveCassandraOperations cassandraOperations) {
@@ -164,10 +166,13 @@ public void setParameterExpressions(Map<String, Expression> parameterExpressions
164166
public void setStatementProcessor(MessageProcessor<Statement<?>> statementProcessor) {
165167
Assert.notNull(statementProcessor, "'statementProcessor' must not be null.");
166168
this.sessionMessageCallback =
167-
(session, requestMessage) ->
168-
session.execute(
169-
QueryOptionsUtil.addQueryOptions(statementProcessor.processMessage(requestMessage),
170-
this.writeOptions));
169+
(session, requestMessage) -> {
170+
Statement<?> statement = statementProcessor.processMessage(requestMessage);
171+
Assert.notNull(statement, "Statement must not be null");
172+
return session.execute(
173+
QueryOptionsUtil.addQueryOptions(statement,
174+
this.writeOptions));
175+
};
171176
this.mode = Type.STATEMENT;
172177
}
173178

@@ -191,6 +196,7 @@ protected void doInit() {
191196
}
192197

193198
@Override
199+
@Nullable
194200
protected Object handleRequestMessage(Message<?> requestMessage) {
195201
Object payload = requestMessage.getPayload();
196202

@@ -220,7 +226,8 @@ protected Object handleRequestMessage(Message<?> requestMessage) {
220226

221227
@SuppressWarnings("unchecked")
222228
private Mono<? extends WriteResult> handleInsert(Object payload) {
223-
if (this.ingestQuery != null) {
229+
final String localIngestQuery = this.ingestQuery;
230+
if (localIngestQuery != null) {
224231
Assert.isInstanceOf(List.class, payload,
225232
"to perform 'ingest' the 'payload' must be of 'List<List<?>>' type.");
226233
List<?> list = (List<?>) payload;
@@ -232,7 +239,7 @@ private Mono<? extends WriteResult> handleInsert(Object payload) {
232239
return this.cassandraOperations.getReactiveCqlOperations()
233240
.execute((ReactiveSessionCallback<WriteResult>) session ->
234241
session.prepare(
235-
QueryOptionsUtil.addQueryOptions(SimpleStatement.newInstance(this.ingestQuery),
242+
QueryOptionsUtil.addQueryOptions(SimpleStatement.newInstance(localIngestQuery),
236243
this.writeOptions))
237244
.flatMapMany(s ->
238245
Flux.fromIterable(rows)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
22
* Provides classes supporting Cassandra outbound endpoints.
33
*/
4-
@org.springframework.lang.NonNullApi
4+
@org.jspecify.annotations.NullMarked
55
package org.springframework.integration.cassandra.outbound;

0 commit comments

Comments
 (0)