aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/vfs
diff options
context:
space:
mode:
authorGravatar Philipp Wollermann <philwo@google.com>2016-10-19 11:47:10 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2016-10-19 13:19:14 +0000
commit4b4b9d33e50dfba8c4b2e798d3ede2c75fa3b256 (patch)
treea4de4035585cd04ced3214faaf14ce3356ea322c /src/main/java/com/google/devtools/build/lib/vfs
parentf04dfb9c60e4f7477b84a245f4ad516dc52a7d97 (diff)
*** Reason for rollback *** Suspected root cause for Windows bootstrap on Bazel CI breakage: java.lang.NullPointerException at com.google.devtools.build.lib.vfs.Path$1.run(Path.java:123) http://ci.bazel.io/view/Bazel%20bootstrap%20and%20maintenance/job/Bazel/922/JAVA_VERSION=1.8,PLATFORM_NAME=windows-x86_64/console *** Original change description *** VFS, WindowsFileSystem: fix UNIX_ROOT retrieval Executing bash.exe directly instead of through cmd.exe doesn't seem to work. This change fixes that problem. Fixes https://github.com/bazelbuild/bazel/issues/1463 (again) -- MOS_MIGRATED_REVID=136581532
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/vfs')
-rw-r--r--src/main/java/com/google/devtools/build/lib/vfs/WindowsFileSystem.java37
1 files changed, 10 insertions, 27 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/vfs/WindowsFileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/WindowsFileSystem.java
index 48f1ff8502..bc9a10d414 100644
--- a/src/main/java/com/google/devtools/build/lib/vfs/WindowsFileSystem.java
+++ b/src/main/java/com/google/devtools/build/lib/vfs/WindowsFileSystem.java
@@ -20,7 +20,6 @@ import com.google.devtools.build.lib.vfs.Path.PathFactory;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.LinkOption;
@@ -171,11 +170,9 @@ public class WindowsFileSystem extends JavaIoFileSystem {
UNIX_ROOT,
"Could not determine Unix path root or it is not an absolute Windows path. Set the "
+ "\"%s\" JVM argument, or export the \"%s\" environment variable for the MSYS bash"
- + " and have /usr/bin/cygpath installed. Parent is \"%s\", name is \"%s\".",
+ + " and have /usr/bin/cygpath installed",
WINDOWS_UNIX_ROOT_JVM_ARG,
- BAZEL_SH_ENV_VAR,
- parent,
- name);
+ BAZEL_SH_ENV_VAR);
return (WindowsPath) parent.getRelative(UNIX_ROOT);
} else {
@@ -411,19 +408,19 @@ public class WindowsFileSystem extends JavaIoFileSystem {
String bash = System.getenv(bazelShEnvVar);
Process process = null;
try {
- process = Runtime.getRuntime().exec("cmd.exe /C " + bash + " -c \"/usr/bin/cygpath -m /\"");
+ process = Runtime.getRuntime().exec(bash + "-c \"/usr/bin/cygpath -m /\"");
// Wait 3 seconds max, that should be enough to run this command.
process.waitFor(3, TimeUnit.SECONDS);
if (process.exitValue() == 0) {
- path = readAll(process.getInputStream());
- } else {
- System.err.print(
- String.format(
- "ERROR: %s (exit code: %d)%n",
- readAll(process.getErrorStream()),
- process.exitValue()));
+ char[] buf = new char[256];
+ try (InputStreamReader r = new InputStreamReader(process.getInputStream())) {
+ int len = 0;
+ while ((len = r.read(buf)) > 0) {
+ path = path + new String(buf, 0, len);
+ }
+ }
}
} catch (InterruptedException | IOException e) {
// Silently ignore failure. Either MSYS is installed at a different location, or not
@@ -440,18 +437,4 @@ public class WindowsFileSystem extends JavaIoFileSystem {
return result;
}
}
-
- private static String readAll(InputStream s) {
- String result = "";
- int len;
- char[] buf = new char[4096];
- try (InputStreamReader r = new InputStreamReader(s)) {
- while ((len = r.read(buf)) > 0) {
- result += new String(buf, 0, len);
- }
- } catch (IOException e) {
- return null;
- }
- return result;
- }
}