diff options
author | ulfjack <ulfjack@google.com> | 2018-01-12 02:11:17 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-01-12 08:19:06 -0800 |
commit | e4794532730ce1df4072a23f9fd5209bcc2cb3e6 (patch) | |
tree | 8e224d1015b6da30497b3dffe662149ab7ce78aa /src/main/java/com/google/devtools/build/lib/rules/repository | |
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/rules/repository')
4 files changed, 9 insertions, 47 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/LocalRepositoryFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/LocalRepositoryFunction.java index f9b520c08a..5b8f088745 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/repository/LocalRepositoryFunction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/repository/LocalRepositoryFunction.java @@ -18,9 +18,7 @@ import com.google.devtools.build.lib.analysis.BlazeDirectories; import com.google.devtools.build.lib.analysis.RuleDefinition; import com.google.devtools.build.lib.packages.BuildFileName; import com.google.devtools.build.lib.packages.Rule; -import com.google.devtools.build.lib.skyframe.FileSymlinkException; import com.google.devtools.build.lib.skyframe.FileValue; -import com.google.devtools.build.lib.skyframe.InconsistentFilesystemException; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.lib.vfs.RootedPath; @@ -103,14 +101,8 @@ public class LocalRepositoryFunction extends RepositoryFunction { SkyKey workspaceFileKey = FileValue.key(workspaceRootedFile); FileValue value; try { - value = - (FileValue) - env.getValueOrThrow( - workspaceFileKey, - IOException.class, - FileSymlinkException.class, - InconsistentFilesystemException.class); - } catch (IOException | FileSymlinkException | InconsistentFilesystemException e) { + value = (FileValue) env.getValueOrThrow(workspaceFileKey, IOException.class); + } catch (IOException e) { throw new RepositoryFunctionException( new IOException("Could not access " + workspaceRootedFile + ": " + e.getMessage()), Transience.PERSISTENT); diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/NewLocalRepositoryFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/NewLocalRepositoryFunction.java index 1e2a5317ae..9811287cb9 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/repository/NewLocalRepositoryFunction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/repository/NewLocalRepositoryFunction.java @@ -18,7 +18,6 @@ import com.google.devtools.build.lib.analysis.BlazeDirectories; import com.google.devtools.build.lib.analysis.RuleDefinition; import com.google.devtools.build.lib.packages.Rule; import com.google.devtools.build.lib.skyframe.DirectoryListingValue; -import com.google.devtools.build.lib.skyframe.FileSymlinkException; import com.google.devtools.build.lib.skyframe.FileValue; import com.google.devtools.build.lib.skyframe.InconsistentFilesystemException; import com.google.devtools.build.lib.vfs.FileSystem; @@ -61,12 +60,7 @@ public class NewLocalRepositoryFunction extends RepositoryFunction { try { FileValue dirFileValue = - (FileValue) - env.getValueOrThrow( - FileValue.key(dirPath), - IOException.class, - FileSymlinkException.class, - InconsistentFilesystemException.class); + (FileValue) env.getValueOrThrow(FileValue.key(dirPath), IOException.class); if (dirFileValue == null) { return null; } @@ -90,10 +84,6 @@ public class NewLocalRepositoryFunction extends RepositoryFunction { } } catch (IOException e) { throw new RepositoryFunctionException(e, Transience.PERSISTENT); - } catch (FileSymlinkException e) { - throw new RepositoryFunctionException(new IOException(e), Transience.PERSISTENT); - } catch (InconsistentFilesystemException e) { - throw new RepositoryFunctionException(new IOException(e), Transience.PERSISTENT); } // fetch() creates symlinks to each child under 'path' and DiffAwareness handles checking all diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/NewRepositoryFileHandler.java b/src/main/java/com/google/devtools/build/lib/rules/repository/NewRepositoryFileHandler.java index 6317a65dca..7d93da6f98 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/repository/NewRepositoryFileHandler.java +++ b/src/main/java/com/google/devtools/build/lib/rules/repository/NewRepositoryFileHandler.java @@ -19,9 +19,7 @@ import com.google.devtools.build.lib.cmdline.LabelSyntaxException; import com.google.devtools.build.lib.cmdline.LabelValidator; import com.google.devtools.build.lib.packages.Rule; import com.google.devtools.build.lib.rules.repository.RepositoryFunction.RepositoryFunctionException; -import com.google.devtools.build.lib.skyframe.FileSymlinkException; import com.google.devtools.build.lib.skyframe.FileValue; -import com.google.devtools.build.lib.skyframe.InconsistentFilesystemException; import com.google.devtools.build.lib.skyframe.PackageLookupValue; import com.google.devtools.build.lib.syntax.EvalException; import com.google.devtools.build.lib.syntax.Type; @@ -252,17 +250,11 @@ public class NewRepositoryFileHandler { // don't write to things in the file system this FileValue depends on. In theory, the latter // is possible if the file referenced by workspace_file is a symlink to somewhere under the // external/ directory, but if you do that, you are really asking for trouble. - fileValue = - (FileValue) - env.getValueOrThrow( - fileKey, - IOException.class, - FileSymlinkException.class, - InconsistentFilesystemException.class); + fileValue = (FileValue) env.getValueOrThrow(fileKey, IOException.class); if (fileValue == null) { return null; } - } catch (IOException | FileSymlinkException | InconsistentFilesystemException e) { + } catch (IOException e) { throw new RepositoryFunctionException( new IOException("Cannot lookup " + fileAttribute + ": " + e.getMessage()), Transience.TRANSIENT); diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java index 5e74aad066..0cf44e6edd 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java @@ -35,9 +35,7 @@ import com.google.devtools.build.lib.repository.ExternalPackageUtil; import com.google.devtools.build.lib.repository.ExternalRuleNotFoundException; import com.google.devtools.build.lib.skyframe.ActionEnvironmentFunction; import com.google.devtools.build.lib.skyframe.FileStateValue.RegularFileStateValue; -import com.google.devtools.build.lib.skyframe.FileSymlinkException; import com.google.devtools.build.lib.skyframe.FileValue; -import com.google.devtools.build.lib.skyframe.InconsistentFilesystemException; import com.google.devtools.build.lib.skyframe.PackageLookupValue; import com.google.devtools.build.lib.syntax.EvalException; import com.google.devtools.build.lib.syntax.Type; @@ -218,13 +216,7 @@ public abstract class RepositoryFunction { } SkyKey fileSkyKey = FileValue.key(rootedPath); - FileValue fileValue = - (FileValue) - env.getValueOrThrow( - fileSkyKey, - IOException.class, - FileSymlinkException.class, - InconsistentFilesystemException.class); + FileValue fileValue = (FileValue) env.getValueOrThrow(fileSkyKey, IOException.class); if (fileValue == null || !fileValue.isFile() || fileValue.isSpecialFile()) { return false; @@ -234,10 +226,7 @@ public abstract class RepositoryFunction { } catch (LabelSyntaxException e) { throw new IllegalStateException( "Key " + key + " is not a correct file key (should be in form FILE:label)", e); - } catch (IOException - | FileSymlinkException - | InconsistentFilesystemException - | EvalException e) { + } catch (IOException | EvalException e) { // Consider those exception to be a cause for invalidation return false; } @@ -488,9 +477,8 @@ public abstract class RepositoryFunction { repositoryDirectory, PathFragment.EMPTY_FRAGMENT)); FileValue value; try { - value = (FileValue) env.getValueOrThrow(outputDirectoryKey, IOException.class, - FileSymlinkException.class, InconsistentFilesystemException.class); - } catch (IOException | FileSymlinkException | InconsistentFilesystemException e) { + value = (FileValue) env.getValueOrThrow(outputDirectoryKey, IOException.class); + } catch (IOException e) { throw new RepositoryFunctionException( new IOException("Could not access " + repositoryDirectory + ": " + e.getMessage()), Transience.PERSISTENT); |