Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IJPL 173473: fix ArrayIndexOutOfBoundsException when using ContainerUtil.concat() #2893

Open
wants to merge 2 commits into
base: 243.22562
Choose a base branch
from

Conversation

dieterstueken
Copy link
Contributor

Context

The method ContainerUtil.concat(list1, list2) works fine with immutable lists. However, if the lists are modified concurrently, iteration may fail. see: IJPL-173473

This fix contains a unit test ContainerUtilTest.testConcatenatedDynamicListsAreIterable to disclose the problem.
Surprisingly it does not indicate any problem, if you start joining two empty lists. This is, because the size of the composed list is calculated in advance and never change. So, while an underlying List is growing, the composed List just does nothing. But I think this is also not the expected behavior. But if any List shrinks, the concatenated List throws an IndexOutOfBoundsException.

To fix this, I introduced an iterator() method for the concatenated List to get the actual elements from both lists.

Other utility methods here, using a straightforward new AbstractList<T>, may suffer from the same problem but are not fixed so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant