RFR: 8340572: ConcurrentModificationException when sorting ArrayList sublists

Attila Szegedi attila at openjdk.org
Thu Oct 3 19:38:36 UTC 2024


On Tue, 1 Oct 2024 03:26:26 GMT, Stuart Marks <smarks at openjdk.org> wrote:

>> @dholmes-ora and @dfuch both your observations are quite valid and I agree with them. If you look at the [JBS issue](https://bugs.openjdk.org/browse/JDK-8340572), we discussed this topic there. 
>> 
>> Clarifying the collections' behavior with regard to when to throw a CME, and hopefully making that behavior be consistent would be a welcome enhancement. As things stand, the scope of this fix is just ensuring that the behavior of ArrayList reverts back to what it was prior to my optimization, since the change triggered a test failure in some Google test suite. All the while recognizing that the behavior was not particularly consistent to begin with.
>
> @szegedi Thanks for starting this. Just a couple comments on the test.
> 
> 1. It would be good to have a test case that verifies that sorting the entire list **does** increment modcount, in addition to the existing test case that tests that sorting a sublist **does not** increment modcount. (As before, this is arguably not the correct behavior, but it's the behavior that the system exhibited prior to JDK-8325679.)
> 2. It would be good for the test to have a more descriptive name than just the bug ID. Something like SortingModCount or similar would be fine.
> 
> Thanks.

@stuart-marks and @liach thanks, those are good suggestions – done.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/21250#issuecomment-2392185387


More information about the core-libs-dev mailing list