Missing synchronized block in BasicDirectoryModel

XMLWordPrintable

    • Type: Bug
    • Resolution: Not an Issue
    • Priority: P4
    • tbd
    • Affects Version/s: 8, 11, 17, 21, 22, 23
    • Component/s: 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

            Assignee:
            Tejesh R
            Reporter:
            Alexey Ivanov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: