Skip to content

Commit b80fbd4

Browse files
artembilangaryrussell
authored andcommitted
Fix varargs warn for CompositeProducerListener
**Cherry-pick to 2.1.x**
1 parent 4fe846d commit b80fbd4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Diff for: spring-kafka/src/main/java/org/springframework/kafka/support/CompositeProducerListener.java

+5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
*
3131
* @param <K> the key type.
3232
* @param <V> the value type.
33+
*
3334
* @author Gary Russell
35+
* @author Artem Bilan
3436
*
3537
* @since 2.1.6
3638
*
@@ -40,13 +42,16 @@ public class CompositeProducerListener<K, V> implements ProducerListener<K, V> {
4042
private final List<ProducerListener<K, V>> delegates = new CopyOnWriteArrayList<>();
4143

4244
@SafeVarargs
45+
@SuppressWarnings("varargs")
4346
public CompositeProducerListener(ProducerListener<K, V>... delegates) {
4447
setDelegates(delegates);
4548
}
4649

4750
@SafeVarargs
51+
@SuppressWarnings("varargs")
4852
public final void setDelegates(ProducerListener<K, V>... delegates) {
4953
Assert.notNull(delegates, "'delegates' cannot be null");
54+
Assert.noNullElements(delegates, "'delegates' cannot contain null elements");
5055
this.delegates.clear();
5156
this.delegates.addAll(Arrays.asList(delegates));
5257
}

Diff for: spring-kafka/src/test/java/org/springframework/kafka/core/KafkaTemplateTests.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2017 the original author or authors.
2+
* Copyright 2016-2018 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.
@@ -268,6 +268,7 @@ public void onError(ProducerRecord<Integer, String> producerRecord, Exception ex
268268
}
269269
PL pl1 = new PL();
270270
PL pl2 = new PL();
271+
@SuppressWarnings("unchecked")
271272
CompositeProducerListener<Integer, String> cpl = new CompositeProducerListener<>(pl1, pl2);
272273
template.setProducerListener(cpl);
273274
template.sendDefault("foo");

0 commit comments

Comments
 (0)