Skip to content

Commit 947e586

Browse files
committed
Fix NullAway errors for array element type annotations
Change array field and getter annotations from @nullable element types to non-nullable element types to match constructor expectations. Arrays can still be null (reference nullable), but elements within those arrays must be non-null, consistent with varargs constructors that don't accept nullable elements. Signed-off-by: Soby Chacko <[email protected]>
1 parent 634dcb9 commit 947e586

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

spring-kafka/src/main/java/org/springframework/kafka/listener/AbstractMessageListenerContainer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ protected AbstractMessageListenerContainer(@Nullable ConsumerFactory<? super K,
157157
Assert.notNull(containerProperties, "'containerProperties' cannot be null");
158158
Assert.notNull(consumerFactory, "'consumerFactory' cannot be null");
159159
this.consumerFactory = (ConsumerFactory<K, V>) consumerFactory;
160-
@Nullable String @Nullable [] topics = containerProperties.getTopics();
160+
String @Nullable [] topics = containerProperties.getTopics();
161161
if (topics != null) {
162162
this.containerProperties = new ContainerProperties(topics);
163163
}
@@ -167,7 +167,7 @@ protected AbstractMessageListenerContainer(@Nullable ConsumerFactory<? super K,
167167
this.containerProperties = new ContainerProperties(topicPattern);
168168
}
169169
else {
170-
@Nullable TopicPartitionOffset @Nullable [] topicPartitions = containerProperties.getTopicPartitions();
170+
TopicPartitionOffset @Nullable [] topicPartitions = containerProperties.getTopicPartitions();
171171
if (topicPartitions != null) {
172172
this.containerProperties = new ContainerProperties(topicPartitions);
173173
}

spring-kafka/src/main/java/org/springframework/kafka/listener/AbstractShareKafkaMessageListenerContainer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected AbstractShareKafkaMessageListenerContainer(ShareConsumerFactory<? supe
9494
Assert.notNull(containerProperties, "'containerProperties' cannot be null");
9595
Assert.notNull(shareConsumerFactory, "'shareConsumerFactory' cannot be null");
9696
this.shareConsumerFactory = (ShareConsumerFactory<K, V>) shareConsumerFactory;
97-
@Nullable String @Nullable [] topics = containerProperties.getTopics();
97+
String @Nullable [] topics = containerProperties.getTopics();
9898
if (topics != null) {
9999
this.containerProperties = new ContainerProperties(topics);
100100
}
@@ -104,7 +104,7 @@ protected AbstractShareKafkaMessageListenerContainer(ShareConsumerFactory<? supe
104104
this.containerProperties = new ContainerProperties(topicPattern);
105105
}
106106
else {
107-
@Nullable TopicPartitionOffset @Nullable [] topicPartitions = containerProperties.getTopicPartitions();
107+
TopicPartitionOffset @Nullable [] topicPartitions = containerProperties.getTopicPartitions();
108108
if (topicPartitions != null) {
109109
this.containerProperties = new ContainerProperties(topicPartitions);
110110
}

spring-kafka/src/main/java/org/springframework/kafka/listener/ConsumerProperties.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class ConsumerProperties {
5252
/**
5353
* Topic names.
5454
*/
55-
private final @Nullable String @Nullable [] topics;
55+
private final String @Nullable [] topics;
5656

5757
/**
5858
* Topic pattern.
@@ -62,7 +62,7 @@ public class ConsumerProperties {
6262
/**
6363
* Topics/partitions/initial offsets.
6464
*/
65-
private final @Nullable TopicPartitionOffset @Nullable [] topicPartitions;
65+
private final TopicPartitionOffset @Nullable [] topicPartitions;
6666

6767
/**
6868
* The max time to block in the consumer waiting for records.
@@ -160,7 +160,6 @@ public ConsumerProperties(TopicPartitionOffset... topicPartitions) {
160160
* Return the configured topics.
161161
* @return the topics.
162162
*/
163-
@Nullable
164163
public String @Nullable [] getTopics() {
165164
return this.topics != null
166165
? Arrays.copyOf(this.topics, this.topics.length)
@@ -181,7 +180,6 @@ public Pattern getTopicPattern() {
181180
* @return the topics/partitions.
182181
* @since 2.5
183182
*/
184-
@Nullable
185183
public TopicPartitionOffset @Nullable [] getTopicPartitions() {
186184
return this.topicPartitions != null
187185
? Arrays.copyOf(this.topicPartitions, this.topicPartitions.length)

spring-kafka/src/main/java/org/springframework/kafka/retrytopic/ListenerContainerFactoryConfigurer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class ListenerContainerFactoryConfigurer {
6262
@Nullable
6363
private BackOff providedBlockingBackOff;
6464

65-
private @Nullable Class<? extends Exception> @Nullable [] blockingExceptionTypes;
65+
private Class<? extends Exception> @Nullable [] blockingExceptionTypes;
6666

6767
private boolean retainStandardFatal;
6868

0 commit comments

Comments
 (0)