You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2022/05/09 12:20:59 UTC
[GitHub] [commons-collections] stevebosman-oc opened a new pull request, #308: COLLECTIONS-770 When creating an iterator chain containing other iterator chains flatten the resulting internal object.
stevebosman-oc opened a new pull request, #308:
URL: https://github.com/apache/commons-collections/pull/308
Contributed on behalf of the @opencastsoftware open source team
I am slightly wary of opening up UnmodifiableIterator, but this seems to solve the performance degradation of nested IteratorChains seen in COLLECTIONS-770
--
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: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-collections] Claudenw commented on a diff in pull request #308: COLLECTIONS-770 When creating an iterator chain containing other iterator chains flatten the resulting internal object.
Posted by "Claudenw (via GitHub)" <gi...@apache.org>.
Claudenw commented on code in PR #308:
URL: https://github.com/apache/commons-collections/pull/308#discussion_r1145199169
##########
src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java:
##########
@@ -170,4 +177,60 @@ public void testEmptyChain() {
);
}
+ @Test
+ public void testChainOfChains() {
+ final Iterator<String> iteratorChain1 = new IteratorChain<>(list1.iterator(), list2.iterator());
+ final Iterator<String> iteratorChain2 = new IteratorChain<>(list3.iterator(), list4.iterator());
+ final Iterator<String> iteratorChainOfChains = new IteratorChain<>(iteratorChain1, iteratorChain2);
+
+ for (final String testValue : testArray1234) {
+ final Object iterValue = iteratorChainOfChains.next();
+
+ assertEquals( "Iteration value is correct", testValue, iterValue );
+ }
+
+ assertFalse("Iterator should now be empty", iteratorChainOfChains.hasNext());
+
+ try {
+ iteratorChainOfChains.next();
+ } catch (final Exception e) {
+ assertEquals("NoSuchElementException must be thrown", e.getClass(), NoSuchElementException.class);
+ }
+ }
+
+ @Test
+ public void testChainOfUnmodifiableChains() {
+ final Iterator<String> iteratorChain1 = new IteratorChain<>(list1.iterator(), list2.iterator());
+ final Iterator<String> unmodifiableChain1 = IteratorUtils.unmodifiableIterator(iteratorChain1);
+ final Iterator<String> iteratorChain2 = new IteratorChain<>(list3.iterator(), list4.iterator());
+ final Iterator<String> unmodifiableChain2 = IteratorUtils.unmodifiableIterator(iteratorChain2);
+ final Iterator<String> iteratorChainOfChains = new IteratorChain<>(unmodifiableChain1, unmodifiableChain2);
+
+ for (final String testValue : testArray1234) {
+ final Object iterValue = iteratorChainOfChains.next();
+
+ assertEquals( "Iteration value is correct", testValue, iterValue );
+ }
+
+ assertFalse("Iterator should now be empty", iteratorChainOfChains.hasNext());
+
+ try {
+ iteratorChainOfChains.next();
+ } catch (final Exception e) {
+ assertEquals("NoSuchElementException must be thrown", e.getClass(), NoSuchElementException.class);
+ }
Review Comment:
Replace this with `assertThrows()`
##########
src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java:
##########
@@ -170,4 +177,60 @@ public void testEmptyChain() {
);
}
+ @Test
+ public void testChainOfChains() {
+ final Iterator<String> iteratorChain1 = new IteratorChain<>(list1.iterator(), list2.iterator());
+ final Iterator<String> iteratorChain2 = new IteratorChain<>(list3.iterator(), list4.iterator());
+ final Iterator<String> iteratorChainOfChains = new IteratorChain<>(iteratorChain1, iteratorChain2);
+
+ for (final String testValue : testArray1234) {
+ final Object iterValue = iteratorChainOfChains.next();
+
+ assertEquals( "Iteration value is correct", testValue, iterValue );
+ }
+
+ assertFalse("Iterator should now be empty", iteratorChainOfChains.hasNext());
+
+ try {
+ iteratorChainOfChains.next();
+ } catch (final Exception e) {
+ assertEquals("NoSuchElementException must be thrown", e.getClass(), NoSuchElementException.class);
+ }
Review Comment:
Replace this with `assertThrows()`
--
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: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [commons-collections] codecov-commenter commented on pull request #308: COLLECTIONS-770 When creating an iterator chain containing other iterator chains flatten the resulting internal object.
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #308:
URL: https://github.com/apache/commons-collections/pull/308#issuecomment-1121037988
# [Codecov](https://codecov.io/gh/apache/commons-collections/pull/308?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#308](https://codecov.io/gh/apache/commons-collections/pull/308?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2257274) into [master](https://codecov.io/gh/apache/commons-collections/commit/1677daceab74895fdf5056c9a48aa94f9e709fb9?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (1677dac) will **increase** coverage by `0.01%`.
> The diff coverage is `100.00%`.
```diff
@@ Coverage Diff @@
## master #308 +/- ##
============================================
+ Coverage 85.87% 85.88% +0.01%
- Complexity 4676 4683 +7
============================================
Files 292 292
Lines 13469 13482 +13
Branches 1955 1959 +4
============================================
+ Hits 11566 11579 +13
Misses 1326 1326
Partials 577 577
```
| [Impacted Files](https://codecov.io/gh/apache/commons-collections/pull/308?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [.../commons/collections4/iterators/IteratorChain.java](https://codecov.io/gh/apache/commons-collections/pull/308/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvY29sbGVjdGlvbnM0L2l0ZXJhdG9ycy9JdGVyYXRvckNoYWluLmphdmE=) | `88.88% <100.00%> (+2.61%)` | :arrow_up: |
| [...s/collections4/iterators/UnmodifiableIterator.java](https://codecov.io/gh/apache/commons-collections/pull/308/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvY29sbGVjdGlvbnM0L2l0ZXJhdG9ycy9Vbm1vZGlmaWFibGVJdGVyYXRvci5qYXZh) | `100.00% <100.00%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/commons-collections/pull/308?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/commons-collections/pull/308?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [1677dac...2257274](https://codecov.io/gh/apache/commons-collections/pull/308?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
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: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org