Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8324719

Missing synchronized block in BasicDirectoryModel

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • tbd
    • 8, 11, 17, 21, 22, 23
    • client-libs
    • None

      Looking at the methods of BasicDirectoryModel, I can see that some methods use synchronized(fileCache) before accessing the field but others (getSize, contains, indexOf, getElementAt), which makes the BasicDirectoryModel class not thread-safe; it is especially dangerous with contains and indexOf where the contents of the fileCache can be changed while the method is iterating over the values inside fileCache.

      These methods—getSize, contains, indexOf, getElementAt—are to access fileCache within synchronized(fileCache) {}.

      https://github.com/openjdk/jdk/pull/17462#issuecomment-1909906871

            tr Tejesh R
            aivanov Alexey Ivanov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: