Propagate IO exceptions encountered while globbing during include scanning, rather than swallowing them: we already handle IO exceptions, and there is no great clamor from users to allow a build to complete even if the filesystem is bad.
PiperOrigin-RevId: 397080099
diff --git a/src/main/java/com/google/devtools/build/lib/includescanning/IncludeParser.java b/src/main/java/com/google/devtools/build/lib/includescanning/IncludeParser.java
index a8d1dde..0e405b0 100644
--- a/src/main/java/com/google/devtools/build/lib/includescanning/IncludeParser.java
+++ b/src/main/java/com/google/devtools/build/lib/includescanning/IncludeParser.java
@@ -266,7 +266,8 @@
*/
@Nullable
ImmutableSet<Artifact> getPathLevelHintedInclusions(
- ImmutableList<PathFragment> paths, Environment env) throws InterruptedException {
+ ImmutableList<PathFragment> paths, Environment env)
+ throws InterruptedException, IOException {
ImmutableList<String> pathStrings =
paths.stream()
.map(PathFragment::getPathString)
@@ -359,15 +360,9 @@
return null;
}
for (Map.Entry<SkyKey, ValueOrException<IOException>> globEntry : globResults.entrySet()) {
- GlobValue globValue;
GlobDescriptor globKey = (GlobDescriptor) globEntry.getKey();
PathFragment packageFragment = globKey.getPackageId().getPackageFragment();
- try {
- globValue = (GlobValue) globEntry.getValue().get();
- } catch (IOException e) {
- logger.atWarning().withCause(e).log("Error getting hints for %s", packageFragment);
- continue;
- }
+ GlobValue globValue = (GlobValue) globEntry.getValue().get();
for (PathFragment file : globValue.getMatches().toList()) {
hints.add(
artifactFactory.getSourceArtifact(
diff --git a/src/test/java/com/google/devtools/build/lib/buildtool/CustomRealFilesystemBuildIntegrationTest.java b/src/test/java/com/google/devtools/build/lib/buildtool/CustomRealFilesystemBuildIntegrationTest.java
index 64106a9..c8d6aea 100644
--- a/src/test/java/com/google/devtools/build/lib/buildtool/CustomRealFilesystemBuildIntegrationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/buildtool/CustomRealFilesystemBuildIntegrationTest.java
@@ -47,6 +47,8 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.function.Consumer;
import java.util.regex.Pattern;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -578,6 +580,7 @@
private final Map<PathFragment, Integer> badPaths = new HashMap<>();
private final Map<PathFragment, Integer> statBadPaths = new HashMap<>();
private final Set<String> createDirectoryErrorNames = new HashSet<>();
+ private Consumer<PathFragment> pathConsumer = null;
private CustomRealFilesystem(DigestHashFunction digestHashFunction) {
super(digestHashFunction, /*hashAttributeName=*/ "");
@@ -603,6 +606,10 @@
return badPaths.getOrDefault(path.asFragment(), 0);
}
+ void setConsumer(Consumer<PathFragment> pathConsumer) {
+ this.pathConsumer = pathConsumer;
+ }
+
private static boolean shouldThrowExn(PathFragment path, Map<PathFragment, Integer> paths) {
if (paths.containsKey(path)) {
Integer numCallsRemaining = paths.get(path);
@@ -619,6 +626,9 @@
if (shouldThrowExn(path, badPaths)) {
throw new IOException("nope");
}
+ if (pathConsumer != null) {
+ pathConsumer.accept(path);
+ }
}
@Override