Skip to content

Commit

Permalink
Fix varargs warn for CompositeProducerListener
Browse files Browse the repository at this point in the history
**Cherry-pick to 2.1.x**
  • Loading branch information
artembilan authored and garyrussell committed Jun 13, 2018
1 parent 4fe846d commit b80fbd4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
*
* @param <K> the key type.
* @param <V> the value type.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 2.1.6
*
Expand All @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -268,6 +268,7 @@ public void onError(ProducerRecord<Integer, String> producerRecord, Exception ex
}
PL pl1 = new PL();
PL pl2 = new PL();
@SuppressWarnings("unchecked")
CompositeProducerListener<Integer, String> cpl = new CompositeProducerListener<>(pl1, pl2);
template.setProducerListener(cpl);
template.sendDefault("foo");
Expand Down

0 comments on commit b80fbd4

Please sign in to comment.