aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java
diff options
context:
space:
mode:
authorGravatar tomlu <tomlu@google.com>2018-01-05 09:19:27 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-01-05 09:22:10 -0800
commit80c8ff1819a889814cbe2dae477d7fedce6aa181 (patch)
tree063fa71759e4174891ccf2db3107e412ec96f2d7 /src/main/java/com/google/devtools/build/lib/vfs/AbstractFileSystem.java
parent3ed01597a938c4b762606d02af1c793196961da0 (diff)
Automated rollback of commit d50cbbeef115f28c0cea1ac17572e0f12c0cf312.
*** Reason for rollback *** b/71442447 *** Original change description *** 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, rep... *** ROLLBACK_OF=180290901 PiperOrigin-RevId: 180936132
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.java20
1 files changed, 11 insertions, 9 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 4d47205843..743bf37dd0 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,16 +96,18 @@ abstract class AbstractFileSystem extends FileSystem {
@Override
protected OutputStream getOutputStream(Path path, boolean append) throws IOException {
- 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());
+ 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;
}
- throw e;
}
}