This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-collections.git
The following commit(s) were added to refs/heads/master by this push:
new 648f993f5 Fix generics in
org.apache.commons.collections4.IteratorUtils.chainedIterator(Collection<?
extends Iterator<? extends E>>)
648f993f5 is described below
commit 648f993f56090a93f061a3351a3e45fec31cfa60
Author: Gary Gregory <[email protected]>
AuthorDate: Sat Oct 19 10:26:56 2024 -0400
Fix generics in
org.apache.commons.collections4.IteratorUtils.chainedIterator(Collection<?
extends Iterator<? extends E>>)
---
src/changes/changes.xml | 1 +
.../org/apache/commons/collections4/IteratorUtils.java | 2 +-
.../apache/commons/collections4/IteratorUtilsTest.java | 17 +++++++++++++++++
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 8c18f9fa3..b2dde9c3d 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -39,6 +39,7 @@
<action type="fix" dev="ggregory" due-to="Gary Gregory, Claude
Warren">Improve WrappedBloomFilterTest. All tests now assert copy() the same
way.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory, Daniele"
issue="COLLECTIONS-860">Javadoc CollectionBag.add* to throw
ClassCastException.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">Fix generics in
IteratorChain.IteratorChain(Collection).</action>
+ <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix generics in
org.apache.commons.collections4.IteratorUtils.chainedIterator(Collection).</action>
<!-- ADD -->
<action type="add" dev="ggregory" due-to="Gary
Gregory">LayerManager.Builder implements Supplier.</action>
<action type="add" dev="ggregory" due-to="Gary Gregory, hemanth0525">Add
CollectionUtils.duplicateList(Collection).</action>
diff --git a/src/main/java/org/apache/commons/collections4/IteratorUtils.java
b/src/main/java/org/apache/commons/collections4/IteratorUtils.java
index cbe052656..75fcaf5ae 100644
--- a/src/main/java/org/apache/commons/collections4/IteratorUtils.java
+++ b/src/main/java/org/apache/commons/collections4/IteratorUtils.java
@@ -422,7 +422,7 @@ public class IteratorUtils {
* @throws NullPointerException if iterators collection is null or
contains a null
* @throws ClassCastException if the iterators collection contains the
wrong object type
*/
- public static <E> Iterator<E> chainedIterator(final Collection<Iterator<?
extends E>> iterators) {
+ public static <E> Iterator<E> chainedIterator(final Collection<? extends
Iterator<? extends E>> iterators) {
return new IteratorChain<>(iterators);
}
diff --git
a/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java
b/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java
index 519a73540..05e2347c8 100644
--- a/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java
+++ b/src/test/java/org/apache/commons/collections4/IteratorUtilsTest.java
@@ -435,6 +435,23 @@ public class IteratorUtilsTest {
"Expecting NullPointerException");
}
+ @Test
+ public void testChainedIteratorList() {
+ final IteratorChainTest iteratorChainTest = new IteratorChainTest();
+ iteratorChainTest.setUp();
+ final List<Iterator<String>> list = new ArrayList<>();
+ list.add(iteratorChainTest.getList1().iterator());
+ list.add(iteratorChainTest.getList2().iterator());
+ list.add(iteratorChainTest.getList3().iterator());
+ final List<String> expected = new
ArrayList<>(iteratorChainTest.getList1());
+ expected.addAll(iteratorChainTest.getList2());
+ expected.addAll(iteratorChainTest.getList3());
+ final Iterator<String> iter = IteratorUtils.chainedIterator(list);
+ final List<String> actual = new ArrayList<>();
+ iter.forEachRemaining(actual::add);
+ assertEquals(actual, expected);
+ }
+
@Test
public void testChainedIteratorRawGenerics() {
final ArrayList arrayList = new ArrayList();