Automated rollback of commit 82e68b75304438c96ff878a0c2b8d18b42002486.

Fixes #4322, #4306.

*** Reason for rollback ***

Introduces a deadlock (see https://github.com/bazelbuild/bazel/issues/4322)

*** Original change description ***

Make FileSystem operate on LocalPath instead of Path.

PiperOrigin-RevId: 179549866
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java
index 54f23f4..8773d54 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java
@@ -39,7 +39,6 @@
 import com.google.devtools.build.lib.vfs.FileStatus;
 import com.google.devtools.build.lib.vfs.FileSystem;
 import com.google.devtools.build.lib.vfs.FileSystemUtils;
-import com.google.devtools.build.lib.vfs.LocalPath;
 import com.google.devtools.build.lib.vfs.ModifiedFileSet;
 import com.google.devtools.build.lib.vfs.Path;
 import com.google.devtools.build.lib.vfs.PathFragment;
@@ -165,7 +164,7 @@
         return 0;
       }
     };
-    fs.stubStat(fooDir.getLocalPath(), inconsistentParentFileStatus);
+    fs.stubStat(fooDir, inconsistentParentFileStatus);
     RootedPath pkgRootedPath = RootedPath.toRootedPath(pkgRoot, fooDir);
     SkyValue fooDirValue = FileStateValue.create(pkgRootedPath, tsgm);
     differencer.inject(ImmutableMap.of(FileStateValue.key(pkgRootedPath), fooDirValue));
@@ -197,7 +196,7 @@
 
     // Our custom filesystem says "foo/bar/baz" does not exist but it also says that "foo/bar"
     // has a child directory "baz".
-    fs.stubStat(bazDir.getLocalPath(), null);
+    fs.stubStat(bazDir, null);
     RootedPath barDirRootedPath = RootedPath.toRootedPath(pkgRoot, barDir);
     FileStateValue barDirFileStateValue = FileStateValue.create(barDirRootedPath, tsgm);
     FileValue barDirFileValue = FileValue.value(barDirRootedPath, barDirFileStateValue,
@@ -226,7 +225,7 @@
     Path fooDir = fooBuildFile.getParentDirectory();
     Path barDir = fooDir.getRelative("bar");
     scratch.file("foo/bar/baz.sh");
-    fs.scheduleMakeUnreadableAfterReaddir(barDir.getLocalPath());
+    fs.scheduleMakeUnreadableAfterReaddir(barDir);
 
     SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
     String expectedMessage = "Encountered error 'Directory is not readable'";
@@ -537,7 +536,7 @@
     scratch.file("foo/BUILD",
         "sh_library(name = 'foo', srcs = ['bar/baz.sh'])");
     Path barBuildFile = scratch.file("foo/bar/BUILD");
-    fs.stubStatError(barBuildFile.getLocalPath(), new IOException("nope"));
+    fs.stubStatError(barBuildFile, new IOException("nope"));
     SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
     EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate(
         getSkyframeExecutor(), skyKey, /*keepGoing=*/false, reporter);
@@ -675,7 +674,7 @@
   public void testPackageLoadingErrorOnIOExceptionReadingBuildFile() throws Exception {
     Path fooBuildFilePath = scratch.file("foo/BUILD");
     IOException exn = new IOException("nope");
-    fs.throwExceptionOnGetInputStream(fooBuildFilePath.getLocalPath(), exn);
+    fs.throwExceptionOnGetInputStream(fooBuildFilePath, exn);
 
     SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
     EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate(
@@ -693,7 +692,7 @@
     scratch.file("foo/BUILD", "load('//foo:bzl.bzl', 'x')");
     Path fooBzlFilePath = scratch.file("foo/bzl.bzl");
     IOException exn = new IOException("nope");
-    fs.throwExceptionOnGetInputStream(fooBzlFilePath.getLocalPath(), exn);
+    fs.throwExceptionOnGetInputStream(fooBzlFilePath, exn);
 
     SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
     EvaluationResult<PackageValue> result = SkyframeExecutorTestUtils.evaluate(
@@ -740,49 +739,49 @@
       }
     }
 
-    private final Map<LocalPath, FileStatusOrException> stubbedStats = Maps.newHashMap();
-    private final Set<LocalPath> makeUnreadableAfterReaddir = Sets.newHashSet();
-    private final Map<LocalPath, IOException> pathsToErrorOnGetInputStream = Maps.newHashMap();
+    private final Map<Path, FileStatusOrException> stubbedStats = Maps.newHashMap();
+    private final Set<Path> makeUnreadableAfterReaddir = Sets.newHashSet();
+    private final Map<Path, IOException> pathsToErrorOnGetInputStream = Maps.newHashMap();
 
     public CustomInMemoryFs(ManualClock manualClock) {
       super(manualClock);
     }
 
-    public void stubStat(LocalPath path, @Nullable FileStatus stubbedResult) {
+    public void stubStat(Path path, @Nullable FileStatus stubbedResult) {
       stubbedStats.put(path, new FileStatusOrException.FileStatusImpl(stubbedResult));
     }
 
-    public void stubStatError(LocalPath path, IOException stubbedResult) {
+    public void stubStatError(Path path, IOException stubbedResult) {
       stubbedStats.put(path, new FileStatusOrException.ExceptionImpl(stubbedResult));
     }
 
     @Override
-    public FileStatus stat(LocalPath path, boolean followSymlinks) throws IOException {
+    public FileStatus stat(Path path, boolean followSymlinks) throws IOException {
       if (stubbedStats.containsKey(path)) {
         return stubbedStats.get(path).get();
       }
       return super.stat(path, followSymlinks);
     }
 
-    public void scheduleMakeUnreadableAfterReaddir(LocalPath path) {
+    public void scheduleMakeUnreadableAfterReaddir(Path path) {
       makeUnreadableAfterReaddir.add(path);
     }
 
     @Override
-    public Collection<Dirent> readdir(LocalPath path, boolean followSymlinks) throws IOException {
+    public Collection<Dirent> readdir(Path path, boolean followSymlinks) throws IOException {
       Collection<Dirent> result = super.readdir(path, followSymlinks);
       if (makeUnreadableAfterReaddir.contains(path)) {
-        setReadable(path, false);
+        path.setReadable(false);
       }
       return result;
     }
 
-    public void throwExceptionOnGetInputStream(LocalPath path, IOException exn) {
+    public void throwExceptionOnGetInputStream(Path path, IOException exn) {
       pathsToErrorOnGetInputStream.put(path, exn);
     }
 
     @Override
-    protected InputStream getInputStream(LocalPath path) throws IOException {
+    protected InputStream getInputStream(Path path) throws IOException {
       IOException exnToThrow = pathsToErrorOnGetInputStream.get(path);
       if (exnToThrow != null) {
         throw exnToThrow;