Add a sanity check to prevent creation of Artifacts with an empty path And fix the tests that were doing this. PiperOrigin-RevId: 179548691
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionInputHelper.java b/src/main/java/com/google/devtools/build/lib/actions/ActionInputHelper.java index 49e262f..0f2c387 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ActionInputHelper.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ActionInputHelper.java
@@ -72,6 +72,7 @@ public BasicActionInput(String path) { this.path = Preconditions.checkNotNull(path); + Preconditions.checkArgument(!path.isEmpty()); } @Override
diff --git a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java index 7d1a5b7..7ecdede 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java +++ b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
@@ -189,6 +189,10 @@ throw new IllegalArgumentException(execPath + ": illegal execPath for " + path + " (root: " + root + ")"); } + if (execPath.segmentCount() == 0) { + throw new IllegalArgumentException( + "it is illegal to create an artifact with an empty execPath"); + } this.hashCode = path.hashCode(); this.path = path; this.root = root;