Repository navigation
Fix race when creating the npm install cache directory - #3096
Merged
Merged
Conversation
Multiple NodeModulesCachingNpmProcessFactory instances can share the same cache directory. If another instance creates it between the exists() check and mkdirs(), mkdirs() returns false and triggers a spurious "Cache dir could not be created." exception. Use Files.createDirectories() to tolerate concurrent directory creation. Preserve actual filesystem failures through UncheckedIOException, including the cache path and original cause. Remove synchronized from assertDir(). It only locks the current factory instance and cannot coordinate other instances sharing the directory. The replacement no longer needs that instance-level lock.
Member
|
needs a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Concurrent npm-based formatters sharing an initially missing npm install cache directory can report
Cache dir could not be created.NodeModulesCachingNpmProcessFactory.assertDir()checks whether the directory exists before callingmkdirs(). Another factory instance can create the directory between those operations, causingmkdirs()to returnfalseand triggering a spurious exception.This change:
Files.createDirectories()to tolerate concurrent directory creation.synchronizedfromassertDir(). It only locks the current factory instance, so separate instances sharing the directory can still enter the method concurrently. The replacement does not need that instance-level lock.UncheckedIOException, including the cache path and original cause.This addresses a possible cause of intermittent Prettier initialization errors observed in OpenRemote with Spotless 8.10.1. The reported stack trace points to this directory-creation check.
Related to #1984 and #2151.