rishabhdaim commented on code in PR #3144:
URL: https://github.com/apache/jackrabbit-oak/pull/3144#discussion_r4092705380
##########
oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/IteratorUtilsTest.java:
##########
@@ -26,11 +26,14 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
+import java.util.HashSet;
Review Comment:
๐ก **P3** ยท ๐ Consistency
**๐ Issue:** `HashSet` is unused, and the two new static assertion imports
are inconsistent with the existing `Assert.*` style in this test class.
**๐ ๏ธ Fix:** Remove `HashSet`, `assertEquals`, and `assertTrue` from the
imports and use `Assert.assertTrue` / `Assert.assertEquals` in the new test.
##########
oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/collections/IteratorUtilsTest.java:
##########
@@ -818,6 +821,17 @@ public void testChainedIteratorsHasNull() {
Assert.assertThrows(NullPointerException.class, () ->
IteratorUtils.chainedIterator(new ArrayList<>(Arrays.asList(iterator1,
iterator2, null)).iterator()));
}
+ @Test
+ // OAK-12410
+ public void testChainedIteratorsAfterHasNextCall() {
+ Iterator<String> subChain = IteratorUtils.chainedIterator(
+ Collections.singleton("a").iterator(),
+ Collections.singleton("b").iterator());
+ assertTrue(subChain.hasNext());
+ Iterator<String> mainChain = IteratorUtils.chainedIterator(subChain,
Collections.singleton("c").iterator());
+ assertEquals("a", mainChain.next());
+ }
Review Comment:
๐ก **P3** ยท ๐ฏ Correctness
**๐ Issue:** This checks only that `"a"` survives the prior `hasNext()`
call. A chain that drops `"b"`, omits the outer `"c"`, or never exhausts would
still pass.
**๐ ๏ธ Fix:** Please assert the complete sequence and exhaustion, and run this
regression against Commons Collections 4.6.0 in the dependency-upgrade path:
```java
Assert.assertEquals("a", mainChain.next());
Assert.assertEquals("b", mainChain.next());
Assert.assertEquals("c", mainChain.next());
Assert.assertFalse(mainChain.hasNext());
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]