RFR: 8323670: A few client tests intermittently throw ConcurrentModificationException
Tejesh R
tr at openjdk.org
Mon Jan 22 06:53:26 UTC 2024
On Sat, 20 Jan 2024 15:05:09 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:
>> Suggested fix [JDK-8307091](https://bugs.openjdk.org/browse/JDK-8307091) also created concurrent exception intermittently (monthly once/quarterly once) on CI system. The issue was not able to be reproduced yet, hence proposing an alternative fix which uses iterators to compare the List.
>> CI testing shows green.
>
> src/java.desktop/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java line 417:
>
>> 415: }
>> 416:
>> 417: private synchronized <T> boolean compareIterators(Iterator<T> iterator1, Iterator<T> iterator2) {
>
> I'm not sure I understand, how this `synchronized` helps to avoid the issue.
Since concurrent modification exception is thrown, it is clear that the List is being modified while comparing two list. Hence instead of copying the list locally, I have used iterators and comparing element by element in a `synchronized` method which ensures single thread is accessing the iterators. Without `synchronized` I guess it would again cause `concurrentModificationException`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17462#discussion_r1461412618
More information about the client-libs-dev
mailing list