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

Race in BasicDirectoryModel.validateFileCache

XMLWordPrintable

    • b19
    • 15
    • b16

        BasicDirectoryModel.validateFileCache starts a background thread, a FilesLoader object, to update the list of files in the current directory.

        First, the method checks if there's an existing filesLoader and interrupts it.

        Then it creates a new filesLoader.

        The above is done without any synchronisation, which means if the method is called concurrently by several threads, several fileLoader threads could be started concurrently. If it happens, only the latest one may be interrupted.

        A similar problem exists in invalidateFileCache, access to filesLoader field isn't protected by a lock.


        BasicDirectoryModel.FilesLoader.cancelRunnables has a data race too. The 'runnable' field is a volatile field, but it's not enough.

        It is possible that runnable is not null when the condition is checked but becomes null in the body of the if statement. It could be set a new value too.

              aivanov Alexey Ivanov
              aivanov Alexey Ivanov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: