Fix varargs warn for CompositeProducerListener
**Cherry-pick to 2.1.x**
This commit is contained in:
committed by
Gary Russell
parent
4fe846d203
commit
b80fbd46f7
@@ -30,7 +30,9 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @param <K> the key type.
|
||||
* @param <V> the value type.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 2.1.6
|
||||
*
|
||||
@@ -40,13 +42,16 @@ public class CompositeProducerListener<K, V> implements ProducerListener<K, V> {
|
||||
private final List<ProducerListener<K, V>> delegates = new CopyOnWriteArrayList<>();
|
||||
|
||||
@SafeVarargs
|
||||
@SuppressWarnings("varargs")
|
||||
public CompositeProducerListener(ProducerListener<K, V>... delegates) {
|
||||
setDelegates(delegates);
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
@SuppressWarnings("varargs")
|
||||
public final void setDelegates(ProducerListener<K, V>... delegates) {
|
||||
Assert.notNull(delegates, "'delegates' cannot be null");
|
||||
Assert.noNullElements(delegates, "'delegates' cannot contain null elements");
|
||||
this.delegates.clear();
|
||||
this.delegates.addAll(Arrays.asList(delegates));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
* Copyright 2016-2018 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.
|
||||
@@ -268,6 +268,7 @@ public class KafkaTemplateTests {
|
||||
}
|
||||
PL pl1 = new PL();
|
||||
PL pl2 = new PL();
|
||||
@SuppressWarnings("unchecked")
|
||||
CompositeProducerListener<Integer, String> cpl = new CompositeProducerListener<>(pl1, pl2);
|
||||
template.setProducerListener(cpl);
|
||||
template.sendDefault("foo");
|
||||
|
||||
Reference in New Issue
Block a user