On Mon, 4 Mar 2024 20:21:30 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:
> Ensure access to the `filesLoader` field of `BasicDirectoryModel` is > synchronized. > > Without synchronization, a thread checks if `filesLoader` is not null and > creates a new `FilesLoader` thread. If the thread is pre-empted between these > two operations, another thread or even several threads can see the `null` > value and create new `FilesLoader` threads. > > The same way, `BasicDirectoryModel.invalidateFileCache` needs to be > synchornized to interrupt the current `filesLoader` and assign `null`. > > This bug allows reproducing `ConcurrentModificationException` seen in > [JDK-8323670](https://bugs.openjdk.org/browse/JDK-8323670) and > [JDK-8307091](https://bugs.openjdk.org/browse/JDK-8307091) using the test in > PR #18109. This pull request has now been integrated. Changeset: e66788c1 Author: Alexey Ivanov <aiva...@openjdk.org> URL: https://git.openjdk.org/jdk/commit/e66788c16563d343f6cccd2807a251ccc6f9b64a Stats: 69 lines in 1 file changed: 17 ins; 21 del; 31 mod 8325179: Race in BasicDirectoryModel.validateFileCache 8238169: BasicDirectoryModel getDirectories and DoChangeContents.run can deadlock Reviewed-by: prr, tr, aturbanov, serb ------------- PR: https://git.openjdk.org/jdk/pull/18111