diff options
author | tomlu <tomlu@google.com> | 2017-12-28 13:25:27 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2017-12-28 13:27:25 -0800 |
commit | d50cbbeef115f28c0cea1ac17572e0f12c0cf312 (patch) | |
tree | 6ec56af5f5c931727a251fda277f55b53cbc6e51 /src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java | |
parent | 29bd80d40bbca49d29e5ae45aa1341e1d19cc7f0 (diff) |
Remove synchronization from file system.
After the path refactor we will no longer have path instances to synchronize on.
The underlying OS file systems are already naturally thread safe, that is, their internal data structures cannot be damaged. Any further synchronization (eg. races between directory creation and deletion) has to be managed at the client level.
The last attempt to do this failed because of races in FileUtils#createDirectoryAndParents on Windows. This method is now gone, replaced by a method from the Java framework that knows how to synchronize.
PiperOrigin-RevId: 180290901
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java index 743bf37dd0..4d47205843 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java @@ -96,18 +96,16 @@ abstract class AbstractFileSystem extends FileSystem { @Override protected OutputStream getOutputStream(Path path, boolean append) throws IOException { - synchronized (path) { - try { - return createFileOutputStream(path, append); - } catch (FileNotFoundException e) { - // Why does it throw a *FileNotFoundException* if it can't write? - // That does not make any sense! And its in a completely different - // format than in other situations, no less! - if (e.getMessage().equals(path + ERR_PERMISSION_DENIED)) { - throw new FileAccessException(e.getMessage()); - } - throw e; + try { + return createFileOutputStream(path, append); + } catch (FileNotFoundException e) { + // Why does it throw a *FileNotFoundException* if it can't write? + // That does not make any sense! And its in a completely different + // format than in other situations, no less! + if (e.getMessage().equals(path + ERR_PERMISSION_DENIED)) { + throw new FileAccessException(e.getMessage()); } + throw e; } } |