diff options
author | 2018-01-12 02:11:17 -0800 | |
---|---|---|
committer | 2018-01-12 08:19:06 -0800 | |
commit | e4794532730ce1df4072a23f9fd5209bcc2cb3e6 (patch) | |
tree | 8e224d1015b6da30497b3dffe662149ab7ce78aa /src/main/java/com/google/devtools/build/lib/skyframe | |
parent | 3e379d1479b2de6118b16aa33f6b9b6fd4ac6ab0 (diff) |
Make FileSymlinkException and InconsistentFSException IOExceptions
Most places handle them the same way as IOException, which seems like a safe
default. The places that do care can still throw or catch the more specific type.
PiperOrigin-RevId: 181719688
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe')
14 files changed, 84 insertions, 138 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunction.java index 0520c0268f..2fcbfbe1fc 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunction.java @@ -84,16 +84,12 @@ public class ASTFileLookupFunction implements SkyFunction { SkyKey fileSkyKey = FileValue.key(rootedPath); FileValue fileValue = null; try { - fileValue = (FileValue) env.getValueOrThrow(fileSkyKey, IOException.class, - FileSymlinkException.class, InconsistentFilesystemException.class); - } catch (IOException e) { - throw new ASTLookupFunctionException(new ErrorReadingSkylarkExtensionException(e), - Transience.PERSISTENT); - } catch (FileSymlinkException e) { - throw new ASTLookupFunctionException(new ErrorReadingSkylarkExtensionException(e), - Transience.PERSISTENT); + fileValue = (FileValue) env.getValueOrThrow(fileSkyKey, IOException.class); } catch (InconsistentFilesystemException e) { throw new ASTLookupFunctionException(e, Transience.PERSISTENT); + } catch (IOException e) { + throw new ASTLookupFunctionException( + new ErrorReadingSkylarkExtensionException(e), Transience.PERSISTENT); } if (fileValue == null) { return null; diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionMetadataHandler.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionMetadataHandler.java index a525bf236a..d060835c46 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionMetadataHandler.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionMetadataHandler.java @@ -575,17 +575,13 @@ public class ActionMetadataHandler implements MetadataHandler { } RootedPath realRootedPath = RootedPath.toRootedPathMaybeUnderRoot(realPath, ImmutableList.of(artifact.getRoot().getPath())); - FileStateValue fileStateValue; - FileStateValue realFileStateValue; - try { - fileStateValue = FileStateValue.createWithStatNoFollow(rootedPath, statNoFollow, tsgm); - // TODO(bazel-team): consider avoiding a 'stat' here when the symlink target hasn't changed - // and is a source file (since changes to those are checked separately). - realFileStateValue = realPath.equals(path) ? fileStateValue - : FileStateValue.create(realRootedPath, tsgm); - } catch (InconsistentFilesystemException e) { - throw new IOException(e); - } + FileStateValue fileStateValue = + FileStateValue.createWithStatNoFollow(rootedPath, statNoFollow, tsgm); + // TODO(bazel-team): consider avoiding a 'stat' here when the symlink target hasn't changed + // and is a source file (since changes to those are checked separately). + FileStateValue realFileStateValue = realPath.equals(path) + ? fileStateValue + : FileStateValue.create(realRootedPath, tsgm); return FileValue.value(rootedPath, fileStateValue, realRootedPath, realFileStateValue); } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java index 10016a1e5d..e607b195af 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java @@ -218,9 +218,8 @@ class ArtifactFunction implements SkyFunction { artifact.getPath())); FileValue fileValue; try { - fileValue = (FileValue) env.getValueOrThrow(fileSkyKey, IOException.class, - InconsistentFilesystemException.class, FileSymlinkException.class); - } catch (IOException | InconsistentFilesystemException | FileSymlinkException e) { + fileValue = (FileValue) env.getValueOrThrow(fileSkyKey, IOException.class); + } catch (IOException e) { throw makeMissingInputFileException(artifact, mandatory, e, env.getListener()); } if (fileValue == null) { diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/DirtinessCheckerUtils.java b/src/main/java/com/google/devtools/build/lib/skyframe/DirtinessCheckerUtils.java index 5400bf9453..eae3b0ce8d 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/DirtinessCheckerUtils.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/DirtinessCheckerUtils.java @@ -46,7 +46,7 @@ public class DirtinessCheckerUtils { RootedPath rootedPath = (RootedPath) key.argument(); try { return FileStateValue.create(rootedPath, tsgm); - } catch (InconsistentFilesystemException | IOException e) { + } catch (IOException e) { // TODO(bazel-team): An IOException indicates a failure to get a file digest or a symlink // target, not a missing file. Such a failure really shouldn't happen, so failing early // may be better here. diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ErrorReadingSkylarkExtensionException.java b/src/main/java/com/google/devtools/build/lib/skyframe/ErrorReadingSkylarkExtensionException.java index cf6904a0b6..f459aea1a0 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ErrorReadingSkylarkExtensionException.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ErrorReadingSkylarkExtensionException.java @@ -25,8 +25,4 @@ public class ErrorReadingSkylarkExtensionException extends Exception { public ErrorReadingSkylarkExtensionException(IOException e) { super(e.getMessage(), e); } - - public ErrorReadingSkylarkExtensionException(FileSymlinkException e) { - super(e.getMessage(), e); - } } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java index 853ab88fa9..74980d251f 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/FileFunction.java @@ -252,7 +252,8 @@ public class FileFunction implements SkyFunction { // reported exactly once. return null; } - throw new FileFunctionException(Preconditions.checkNotNull(fse, rootedPath)); + throw new FileFunctionException( + Preconditions.checkNotNull(fse, rootedPath), Transience.PERSISTENT); } return resolveFromAncestors(symlinkTargetRootedPath, env); @@ -278,15 +279,6 @@ public class FileFunction implements SkyFunction { * {@link FileFunction#compute}. */ private static final class FileFunctionException extends SkyFunctionException { - - public FileFunctionException(InconsistentFilesystemException e, Transience transience) { - super(e, transience); - } - - public FileFunctionException(FileSymlinkException e) { - super(e, Transience.PERSISTENT); - } - public FileFunctionException(IOException e, Transience transience) { super(e, transience); } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/FileStateFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/FileStateFunction.java index dece88c313..52876f2264 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/FileStateFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/FileStateFunction.java @@ -54,8 +54,6 @@ public class FileStateFunction implements SkyFunction { return FileStateValue.NONEXISTENT_FILE_STATE_NODE; } catch (IOException e) { throw new FileStateFunctionException(e); - } catch (InconsistentFilesystemException e) { - throw new FileStateFunctionException(e); } } @@ -72,9 +70,5 @@ public class FileStateFunction implements SkyFunction { public FileStateFunctionException(IOException e) { super(e, Transience.TRANSIENT); } - - public FileStateFunctionException(InconsistentFilesystemException e) { - super(e, Transience.TRANSIENT); - } } } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/FileSymlinkException.java b/src/main/java/com/google/devtools/build/lib/skyframe/FileSymlinkException.java index c2b00cf254..19ecace5b1 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/FileSymlinkException.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/FileSymlinkException.java @@ -13,8 +13,10 @@ // limitations under the License. package com.google.devtools.build.lib.skyframe; +import java.io.IOException; + /** Exception indicating a problem with symlinks. */ -public abstract class FileSymlinkException extends Exception { +public abstract class FileSymlinkException extends IOException { protected FileSymlinkException(String message) { super(message); } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/InconsistentFilesystemException.java b/src/main/java/com/google/devtools/build/lib/skyframe/InconsistentFilesystemException.java index 318aa2d35d..5397fb4937 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/InconsistentFilesystemException.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/InconsistentFilesystemException.java @@ -13,11 +13,13 @@ // limitations under the License. package com.google.devtools.build.lib.skyframe; +import java.io.IOException; + /** * Used to indicate a filesystem inconsistency, e.g. file 'a/b' exists but directory 'a' doesn't * exist. This generally means the result of the build is undefined but we shouldn't crash hard. */ -public class InconsistentFilesystemException extends Exception { +public class InconsistentFilesystemException extends IOException { public InconsistentFilesystemException(String inconsistencyMessage) { super("Inconsistent filesystem operations. " + inconsistencyMessage + " The results of the " + "build are not guaranteed to be correct. You should probably run 'blaze clean' and " diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/LocalRepositoryLookupFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/LocalRepositoryLookupFunction.java index d1ffe0e4bb..66d4afaee0 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/LocalRepositoryLookupFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/LocalRepositoryLookupFunction.java @@ -98,12 +98,7 @@ public class LocalRepositoryLookupFunction implements SkyFunction { .getRelativePath() .getRelative(BuildFileName.WORKSPACE.getFilenameFragment())); FileValue workspaceFileValue = - (FileValue) - env.getValueOrThrow( - FileValue.key(workspaceRootedFile), - IOException.class, - FileSymlinkException.class, - InconsistentFilesystemException.class); + (FileValue) env.getValueOrThrow(FileValue.key(workspaceRootedFile), IOException.class); if (workspaceFileValue == null) { return Optional.absent(); } @@ -112,10 +107,10 @@ public class LocalRepositoryLookupFunction implements SkyFunction { return Optional.of(false); } return Optional.of(workspaceFileValue.exists()); - } catch (IOException e) { + } catch (InconsistentFilesystemException e) { throw new LocalRepositoryLookupFunctionException( new ErrorDeterminingRepositoryException( - "IOException while checking if there is a WORKSPACE file in " + "InconsistentFilesystemException while checking if there is a WORKSPACE file in " + directory.asPath().getPathString(), e), Transience.PERSISTENT); @@ -126,10 +121,10 @@ public class LocalRepositoryLookupFunction implements SkyFunction { + directory.asPath().getPathString(), e), Transience.PERSISTENT); - } catch (InconsistentFilesystemException e) { + } catch (IOException e) { throw new LocalRepositoryLookupFunctionException( new ErrorDeterminingRepositoryException( - "InconsistentFilesystemException while checking if there is a WORKSPACE file in " + "IOException while checking if there is a WORKSPACE file in " + directory.asPath().getPathString(), e), Transience.PERSISTENT); diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java index c3e67c7c52..b10ab4b952 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/PackageFunction.java @@ -66,9 +66,9 @@ import com.google.devtools.build.skyframe.SkyFunctionException; import com.google.devtools.build.skyframe.SkyFunctionException.Transience; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.SkyValue; +import com.google.devtools.build.skyframe.ValueOrException; import com.google.devtools.build.skyframe.ValueOrException2; import com.google.devtools.build.skyframe.ValueOrException3; -import com.google.devtools.build.skyframe.ValueOrException4; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -296,18 +296,17 @@ public class PackageFunction implements SkyFunction { Preconditions.checkState( Iterables.all(depKeys, SkyFunctions.isSkyFunction(SkyFunctions.FILE)), depKeys); boolean packageShouldBeInError = packageWasInError; - for (Map.Entry<SkyKey, ValueOrException3<IOException, FileSymlinkException, - InconsistentFilesystemException>> entry : env.getValuesOrThrow(depKeys, IOException.class, - FileSymlinkException.class, InconsistentFilesystemException.class).entrySet()) { + for (Map.Entry<SkyKey, ValueOrException<IOException>> entry : + env.getValuesOrThrow(depKeys, IOException.class).entrySet()) { try { entry.getValue().get(); - } catch (IOException e) { - maybeThrowFilesystemInconsistency(packageIdentifier, e, packageWasInError); + } catch (InconsistentFilesystemException e) { + throw new InternalInconsistentFilesystemException(packageIdentifier, e); } catch (FileSymlinkException e) { // Legacy doesn't detect symlink cycles. packageShouldBeInError = true; - } catch (InconsistentFilesystemException e) { - throw new InternalInconsistentFilesystemException(packageIdentifier, e); + } catch (IOException e) { + maybeThrowFilesystemInconsistency(packageIdentifier, e, packageWasInError); } } return packageShouldBeInError; @@ -326,19 +325,18 @@ public class PackageFunction implements SkyFunction { Preconditions.checkState( Iterables.all(depKeys, SkyFunctions.isSkyFunction(SkyFunctions.GLOB)), depKeys); boolean packageShouldBeInError = packageWasInError; - for (Map.Entry<SkyKey, ValueOrException4<IOException, BuildFileNotFoundException, - FileSymlinkException, InconsistentFilesystemException>> entry : - env.getValuesOrThrow(depKeys, IOException.class, BuildFileNotFoundException.class, - FileSymlinkException.class, InconsistentFilesystemException.class).entrySet()) { + for (Map.Entry<SkyKey, ValueOrException2<IOException, BuildFileNotFoundException>> entry : + env.getValuesOrThrow( + depKeys, IOException.class, BuildFileNotFoundException.class).entrySet()) { try { entry.getValue().get(); - } catch (IOException | BuildFileNotFoundException e) { - maybeThrowFilesystemInconsistency(packageIdentifier, e, packageWasInError); + } catch (InconsistentFilesystemException e) { + throw new InternalInconsistentFilesystemException(packageIdentifier, e); } catch (FileSymlinkException e) { // Legacy doesn't detect symlink cycles. packageShouldBeInError = true; - } catch (InconsistentFilesystemException e) { - throw new InternalInconsistentFilesystemException(packageIdentifier, e); + } catch (IOException | BuildFileNotFoundException e) { + maybeThrowFilesystemInconsistency(packageIdentifier, e, packageWasInError); } } return packageShouldBeInError; @@ -453,12 +451,9 @@ public class PackageFunction implements SkyFunction { env.getValueOrThrow( workspaceKey, IOException.class, - FileSymlinkException.class, - InconsistentFilesystemException.class, EvalException.class, SkylarkImportFailedException.class); - } catch (IOException | FileSymlinkException | InconsistentFilesystemException - | EvalException | SkylarkImportFailedException e) { + } catch (IOException | EvalException | SkylarkImportFailedException e) { throw new PackageFunctionException( new NoSuchPackageException( Label.EXTERNAL_PACKAGE_IDENTIFIER, @@ -654,10 +649,9 @@ public class PackageFunction implements SkyFunction { throws InterruptedException { FileValue buildFileValue; try { - buildFileValue = (FileValue) env.getValueOrThrow(FileValue.key(buildFileRootedPath), - IOException.class, FileSymlinkException.class, - InconsistentFilesystemException.class); - } catch (IOException | FileSymlinkException | InconsistentFilesystemException e) { + buildFileValue = + (FileValue) env.getValueOrThrow(FileValue.key(buildFileRootedPath), IOException.class); + } catch (IOException e) { throw new IllegalStateException("Package lookup succeeded but encountered error when " + "getting FileValue for BUILD file directly.", e); } @@ -1051,10 +1045,10 @@ public class PackageFunction implements SkyFunction { } globDepsRequested.addAll(globKeys); - Map<SkyKey, ValueOrException4<IOException, BuildFileNotFoundException, - FileSymlinkCycleException, InconsistentFilesystemException>> globValueMap = + Map<SkyKey, ValueOrException3<IOException, BuildFileNotFoundException, + FileSymlinkCycleException>> globValueMap = env.getValuesOrThrow(globKeys, IOException.class, BuildFileNotFoundException.class, - FileSymlinkCycleException.class, InconsistentFilesystemException.class); + FileSymlinkCycleException.class); // For each missing glob, evaluate it asychronously via the delegate. // @@ -1087,12 +1081,12 @@ public class PackageFunction implements SkyFunction { } private Collection<SkyKey> getMissingKeys(Collection<SkyKey> globKeys, - Map<SkyKey, ValueOrException4<IOException, BuildFileNotFoundException, - FileSymlinkCycleException, InconsistentFilesystemException>> globValueMap) { + Map<SkyKey, ValueOrException3<IOException, BuildFileNotFoundException, + FileSymlinkCycleException>> globValueMap) { List<SkyKey> missingKeys = new ArrayList<>(globKeys.size()); for (SkyKey globKey : globKeys) { - ValueOrException4<IOException, BuildFileNotFoundException, FileSymlinkCycleException, - InconsistentFilesystemException> valueOrException = globValueMap.get(globKey); + ValueOrException3<IOException, BuildFileNotFoundException, FileSymlinkCycleException> + valueOrException = globValueMap.get(globKey); if (valueOrException == null) { missingKeys.add(globKey); } @@ -1100,8 +1094,7 @@ public class PackageFunction implements SkyFunction { if (valueOrException.get() == null) { missingKeys.add(globKey); } - } catch (IOException | BuildFileNotFoundException | FileSymlinkCycleException - | InconsistentFilesystemException doesntMatter) { + } catch (IOException | BuildFileNotFoundException doesntMatter) { continue; } } @@ -1156,8 +1149,8 @@ public class PackageFunction implements SkyFunction { */ private static class HybridToken extends Globber.Token { // The result of the Skyframe lookup for all the needed glob patterns. - private final Map<SkyKey, ValueOrException4<IOException, BuildFileNotFoundException, - FileSymlinkCycleException, InconsistentFilesystemException>> globValueMap; + private final Map<SkyKey, ValueOrException3<IOException, BuildFileNotFoundException, + FileSymlinkCycleException>> globValueMap; // The skyframe keys corresponding to the 'includes' patterns fetched from Skyframe // (this is includes_sky above). private final Iterable<SkyKey> includesGlobKeys; @@ -1169,8 +1162,8 @@ public class PackageFunction implements SkyFunction { // A token for computing excludes_leg. private final Token legacyExcludesToken; - private HybridToken(Map<SkyKey, ValueOrException4<IOException, BuildFileNotFoundException, - FileSymlinkCycleException, InconsistentFilesystemException>> globValueMap, + private HybridToken(Map<SkyKey, ValueOrException3<IOException, BuildFileNotFoundException, + FileSymlinkCycleException>> globValueMap, Iterable<SkyKey> includesGlobKeys, Iterable<SkyKey> excludesGlobKeys, Token delegateIncludesToken, Token delegateExcludesToken) { this.globValueMap = globValueMap; @@ -1208,20 +1201,18 @@ public class PackageFunction implements SkyFunction { SkyKey globKey, Map< SkyKey, - ValueOrException4< - IOException, BuildFileNotFoundException, FileSymlinkCycleException, - InconsistentFilesystemException>> + ValueOrException3< + IOException, BuildFileNotFoundException, FileSymlinkCycleException>> globValueMap) throws IOException { - ValueOrException4<IOException, BuildFileNotFoundException, FileSymlinkCycleException, - InconsistentFilesystemException> valueOrException = + ValueOrException3<IOException, BuildFileNotFoundException, FileSymlinkCycleException> + valueOrException = Preconditions.checkNotNull(globValueMap.get(globKey), "%s should not be missing", globKey); try { return Preconditions.checkNotNull((GlobValue) valueOrException.get(), "%s should not be missing", globKey).getMatches(); - } catch (BuildFileNotFoundException | FileSymlinkCycleException - | InconsistentFilesystemException e) { + } catch (BuildFileNotFoundException e) { // Legacy package loading is only able to handle an IOException, so a rethrow here is the // best we can do. But after legacy package loading, PackageFunction will go through all // the skyframe deps and properly handle InconsistentFilesystemExceptions. diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/PackageLookupFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/PackageLookupFunction.java index 6c29df3fe7..00d0c34f19 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/PackageLookupFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/PackageLookupFunction.java @@ -146,8 +146,15 @@ public class PackageLookupFunction implements SkyFunction { SkyKey fileSkyKey = FileValue.key(fileRootedPath); FileValue fileValue = null; try { - fileValue = (FileValue) env.getValueOrThrow(fileSkyKey, IOException.class, - FileSymlinkException.class, InconsistentFilesystemException.class); + fileValue = (FileValue) env.getValueOrThrow(fileSkyKey, IOException.class); + } catch (InconsistentFilesystemException e) { + // This error is not transient from the perspective of the PackageLookupFunction. + throw new PackageLookupFunctionException(e, Transience.PERSISTENT); + } catch (FileSymlinkException e) { + throw new PackageLookupFunctionException(new BuildFileNotFoundException(packageIdentifier, + "Symlink cycle detected while trying to find " + basename + " file " + + fileRootedPath.asPath()), + Transience.PERSISTENT); } catch (IOException e) { // TODO(bazel-team): throw an IOException here and let PackageFunction wrap that into a // BuildFileNotFoundException. @@ -155,14 +162,6 @@ public class PackageLookupFunction implements SkyFunction { "IO errors while looking for " + basename + " file reading " + fileRootedPath.asPath() + ": " + e.getMessage(), e), Transience.PERSISTENT); - } catch (FileSymlinkException e) { - throw new PackageLookupFunctionException(new BuildFileNotFoundException(packageIdentifier, - "Symlink cycle detected while trying to find " + basename + " file " - + fileRootedPath.asPath()), - Transience.PERSISTENT); - } catch (InconsistentFilesystemException e) { - // This error is not transient from the perspective of the PackageLookupFunction. - throw new PackageLookupFunctionException(e, Transience.PERSISTENT); } return fileValue; } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ProcessPackageDirectory.java b/src/main/java/com/google/devtools/build/lib/skyframe/ProcessPackageDirectory.java index 74185059af..e46f4f2b74 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ProcessPackageDirectory.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ProcessPackageDirectory.java @@ -30,7 +30,7 @@ import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.lib.vfs.RootedPath; import com.google.devtools.build.skyframe.SkyFunction; import com.google.devtools.build.skyframe.SkyKey; -import com.google.devtools.build.skyframe.ValueOrException4; +import com.google.devtools.build.skyframe.ValueOrException2; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -78,14 +78,8 @@ public class ProcessPackageDirectory { SkyKey fileKey = FileValue.key(rootedPath); FileValue fileValue; try { - fileValue = - (FileValue) - env.getValueOrThrow( - fileKey, - InconsistentFilesystemException.class, - FileSymlinkException.class, - IOException.class); - } catch (InconsistentFilesystemException | FileSymlinkException | IOException e) { + fileValue = (FileValue) env.getValueOrThrow(fileKey, IOException.class); + } catch (IOException e) { return reportErrorAndReturn( "Failed to get information about path", e, rootRelativePath, env.getListener()); } @@ -116,15 +110,12 @@ public class ProcessPackageDirectory { SkyKey dirListingKey = DirectoryListingValue.key(rootedPath); Map< SkyKey, - ValueOrException4< - NoSuchPackageException, InconsistentFilesystemException, FileSymlinkException, - IOException>> + ValueOrException2< + NoSuchPackageException, IOException>> pkgLookupAndDirectoryListingDeps = env.getValuesOrThrow( ImmutableList.of(pkgLookupKey, dirListingKey), NoSuchPackageException.class, - InconsistentFilesystemException.class, - FileSymlinkException.class, IOException.class); if (env.valuesMissing()) { return null; @@ -141,7 +132,7 @@ public class ProcessPackageDirectory { pkgLookupKey); } catch (NoSuchPackageException | InconsistentFilesystemException e) { return reportErrorAndReturn("Failed to load package", e, rootRelativePath, env.getListener()); - } catch (IOException | FileSymlinkException e) { + } catch (IOException e) { throw new IllegalStateException(e); } DirectoryListingValue dirListingValue; @@ -154,15 +145,15 @@ public class ProcessPackageDirectory { rootedPath, repositoryName, dirListingKey); - } catch (InconsistentFilesystemException | IOException e) { - return reportErrorAndReturn( - "Failed to list directory contents", e, rootRelativePath, env.getListener()); } catch (FileSymlinkException e) { // DirectoryListingFunction only throws FileSymlinkCycleException when FileFunction throws it, // but FileFunction was evaluated for rootedPath above, and didn't throw there. It shouldn't // be able to avoid throwing there but throw here. throw new IllegalStateException( "Symlink cycle found after not being found for \"" + rootedPath + "\""); + } catch (IOException e) { + return reportErrorAndReturn( + "Failed to list directory contents", e, rootRelativePath, env.getListener()); } catch (NoSuchPackageException e) { throw new IllegalStateException(e); } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunction.java index 0706308098..5b0549f3be 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunction.java @@ -174,7 +174,7 @@ public final class RecursiveFilesystemTraversalFunction implements SkyFunction { // We are free to traverse this directory. Collection<SkyKey> dependentKeys = createRecursiveTraversalKeys(env, traversal); return resultForDirectory(traversal, rootInfo, traverseChildren(env, dependentKeys)); - } catch (FileSymlinkException | InconsistentFilesystemException | IOException e) { + } catch (IOException e) { throw new RecursiveFilesystemTraversalFunctionException( new FileOperationException("Error while traversing fileset: " + e.getMessage())); } catch (MissingDepException e) { @@ -213,16 +213,10 @@ public final class RecursiveFilesystemTraversalFunction implements SkyFunction { } private static FileInfo lookUpFileInfo(Environment env, TraversalRequest traversal) - throws MissingDepException, FileSymlinkException, InconsistentFilesystemException, - IOException, InterruptedException { + throws MissingDepException, IOException, InterruptedException { // Stat the file. FileValue fileValue = - (FileValue) - env.getValueOrThrow( - FileValue.key(traversal.path), - FileSymlinkException.class, - InconsistentFilesystemException.class, - IOException.class); + (FileValue) env.getValueOrThrow(FileValue.key(traversal.path), IOException.class); if (env.valuesMissing()) { throw new MissingDepException(); @@ -301,8 +295,7 @@ public final class RecursiveFilesystemTraversalFunction implements SkyFunction { */ private static PkgLookupResult checkIfPackage( Environment env, TraversalRequest traversal, FileInfo rootInfo) - throws MissingDepException, FileSymlinkException, InconsistentFilesystemException, - IOException, InterruptedException { + throws MissingDepException, IOException, InterruptedException { Preconditions.checkArgument(rootInfo.type.exists() && !rootInfo.type.isFile(), "{%s} {%s}", traversal, rootInfo); PackageLookupValue pkgLookup = (PackageLookupValue) getDependentSkyValue(env, |