aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs
diff options
context:
space:
mode:
authorGravatar tomlu <tomlu@google.com>2017-10-20 20:59:44 +0200
committerGravatar Dmitry Lomov <dslomov@google.com>2017-10-23 17:16:03 +0200
commit51de88c017910e77f929bc38d5b1b1c315170443 (patch)
treeab2a18da2845d21686570edb6be05b33da00547e /src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs
parent10a6b77e342472e29d168060e06f05a9c7cad66f (diff)
Lazy-initialise rootPath in FileSystem.
Path construction entails calling isFileSystemCaseSensitive at a time when subclasses have not been initialised. This can cause a crash. Solve by deferring init of the path. PiperOrigin-RevId: 172914501
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs')
-rw-r--r--src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs/InMemoryFileSystem.java24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs/InMemoryFileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs/InMemoryFileSystem.java
index d2db9967a1..7a91db7eed 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs/InMemoryFileSystem.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs/InMemoryFileSystem.java
@@ -332,7 +332,7 @@ public class InMemoryFileSystem extends FileSystem {
// and it may only appear as part of a contiguous prefix sequence.
Stack<String> stack = new Stack<>();
- PathFragment rootPathFragment = rootPath.asFragment();
+ PathFragment rootPathFragment = getRootDirectory().asFragment();
for (Path p = path; !p.asFragment().equals(rootPathFragment); p = p.getParentDirectory()) {
stack.push(p.getBaseName());
}
@@ -408,7 +408,7 @@ public class InMemoryFileSystem extends FileSystem {
if (followSymlinks) {
return scopeLimitedStat(path, true);
} else {
- if (path.equals(rootPath)) {
+ if (path.equals(getRootDirectory())) {
return rootInode;
} else {
return getNoFollowStatOrOutOfScopeParent(path);
@@ -441,7 +441,7 @@ public class InMemoryFileSystem extends FileSystem {
if (followSymlinks) {
return pathWalk(path, false);
} else {
- if (path.equals(rootPath)) {
+ if (path.equals(getRootDirectory())) {
return rootInode;
} else {
return getNoFollowStatOrOutOfScopeParent(path);
@@ -582,7 +582,9 @@ public class InMemoryFileSystem extends FileSystem {
@Override
protected boolean createDirectory(Path path) throws IOException {
- if (path.equals(rootPath)) { throw Error.EACCES.exception(path); }
+ if (path.equals(getRootDirectory())) {
+ throw Error.EACCES.exception(path);
+ }
InMemoryDirectoryInfo parent;
synchronized (this) {
@@ -608,7 +610,9 @@ public class InMemoryFileSystem extends FileSystem {
@Override
protected void createSymbolicLink(Path path, PathFragment targetFragment)
throws IOException {
- if (path.equals(rootPath)) { throw Error.EACCES.exception(path); }
+ if (path.equals(getRootDirectory())) {
+ throw Error.EACCES.exception(path);
+ }
synchronized (this) {
InMemoryDirectoryInfo parent = getDirectory(path.getParentDirectory());
@@ -659,7 +663,9 @@ public class InMemoryFileSystem extends FileSystem {
@Override
protected boolean delete(Path path) throws IOException {
- if (path.equals(rootPath)) { throw Error.EBUSY.exception(path); }
+ if (path.equals(getRootDirectory())) {
+ throw Error.EBUSY.exception(path);
+ }
if (!exists(path, false)) { return false; }
synchronized (this) {
@@ -731,10 +737,10 @@ public class InMemoryFileSystem extends FileSystem {
@Override
protected void renameTo(Path sourcePath, Path targetPath)
throws IOException {
- if (sourcePath.equals(rootPath)) {
+ if (sourcePath.equals(getRootDirectory())) {
throw Error.EACCES.exception(sourcePath);
}
- if (targetPath.equals(rootPath)) {
+ if (targetPath.equals(getRootDirectory())) {
throw Error.EACCES.exception(targetPath);
}
synchronized (this) {
@@ -782,7 +788,7 @@ public class InMemoryFileSystem extends FileSystem {
throws IOException {
// Same check used when creating a symbolic link
- if (originalPath.equals(rootPath)) {
+ if (originalPath.equals(getRootDirectory())) {
throw Error.EACCES.exception(originalPath);
}