Skip to content

Commit ac42a1d

Browse files
committed
gh-10083: Scope: spring-integration-cassandra
Handled suppression of NullAway warnings by adding explicit null checks. Signed-off-by: Anayonkar Shivalkar <[email protected]>
1 parent c68d05c commit ac42a1d

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
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;

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,16 @@ public void setParameterExpressions(Map<String, Expression> parameterExpressions
163163
this.parameterExpressions.putAll(parameterExpressions);
164164
}
165165

166-
@SuppressWarnings("NullAway")
167166
public void setStatementProcessor(MessageProcessor<Statement<?>> statementProcessor) {
168167
Assert.notNull(statementProcessor, "'statementProcessor' must not be null.");
169168
this.sessionMessageCallback =
170-
(session, requestMessage) ->
171-
session.execute(
172-
QueryOptionsUtil.addQueryOptions(statementProcessor.processMessage(requestMessage),
173-
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+
};
174176
this.mode = Type.STATEMENT;
175177
}
176178

@@ -194,7 +196,7 @@ protected void doInit() {
194196
}
195197

196198
@Override
197-
@SuppressWarnings("NullAway")
199+
@Nullable
198200
protected Object handleRequestMessage(Message<?> requestMessage) {
199201
Object payload = requestMessage.getPayload();
200202

@@ -222,9 +224,10 @@ protected Object handleRequestMessage(Message<?> requestMessage) {
222224
}
223225
}
224226

225-
@SuppressWarnings({"unchecked", "NullAway"})
227+
@SuppressWarnings("unchecked")
226228
private Mono<? extends WriteResult> handleInsert(Object payload) {
227-
if (this.ingestQuery != null) {
229+
final String localIngestQuery = this.ingestQuery;
230+
if (localIngestQuery != null) {
228231
Assert.isInstanceOf(List.class, payload,
229232
"to perform 'ingest' the 'payload' must be of 'List<List<?>>' type.");
230233
List<?> list = (List<?>) payload;
@@ -236,7 +239,7 @@ private Mono<? extends WriteResult> handleInsert(Object payload) {
236239
return this.cassandraOperations.getReactiveCqlOperations()
237240
.execute((ReactiveSessionCallback<WriteResult>) session ->
238241
session.prepare(
239-
QueryOptionsUtil.addQueryOptions(SimpleStatement.newInstance(this.ingestQuery),
242+
QueryOptionsUtil.addQueryOptions(SimpleStatement.newInstance(localIngestQuery),
240243
this.writeOptions))
241244
.flatMapMany(s ->
242245
Flux.fromIterable(rows)

0 commit comments

Comments
 (0)