diff --git a/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java b/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java index ad21774db16575..4381ad48182a8c 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/SourceManifestAction.java @@ -302,6 +302,9 @@ public void writeEntry( @Nullable PathFragment symlinkTarget) throws IOException { String rootRelativePathString = rootRelativePath.getPathString(); + // Source paths with spaces require escaping. Target paths with spaces don't as consumers + // are expected to split on the first space (without escaping) or after the part indicated + // by the length prefix (with escaping). if (rootRelativePathString.indexOf(' ') != -1) { manifestWriter.append(' '); manifestWriter.append(String.valueOf(rootRelativePathString.length())); diff --git a/src/test/shell/bazel/bazel_determinism_test.sh b/src/test/shell/bazel/bazel_determinism_test.sh index ca8d00d9432adb..4ba42fb3edc174 100755 --- a/src/test/shell/bazel/bazel_determinism_test.sh +++ b/src/test/shell/bazel/bazel_determinism_test.sh @@ -61,6 +61,7 @@ function hash_outputs() { } function test_determinism() { + # Verify that Bazel can build itself under a path with spaces. local workdir="${TEST_TMPDIR}/work dir" mkdir "${workdir}" || fail "Could not create work directory" cd "${workdir}" || fail "Could not change to work directory" diff --git a/tools/java/runfiles/Runfiles.java b/tools/java/runfiles/Runfiles.java index 26cbaf06a7d056..7445648e355b02 100644 --- a/tools/java/runfiles/Runfiles.java +++ b/tools/java/runfiles/Runfiles.java @@ -157,9 +157,10 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (!(o instanceof RepoMappingKey that)) { + if (o == null || !(o instanceof RepoMappingKey)) { return false; } + RepoMappingKey that = (RepoMappingKey) o; return sourceRepo.equals(that.sourceRepo) && targetRepoApparentName.equals(that.targetRepoApparentName); }