Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Coulon2015-06-02 08:10:53 -0400
committerJeff Johnston2015-06-02 14:33:24 -0400
commiteb5a7e12754184f8b4f6330c162e04b3c6aeecbb (patch)
tree26cf1870bb65b62aa1ad1a36527c037162e5d432
parent9da2683f8c44c23d179838c620c7963f81a5588b (diff)
downloadorg.eclipse.linuxtools-eb5a7e12754184f8b4f6330c162e04b3c6aeecbb.tar.gz
org.eclipse.linuxtools-eb5a7e12754184f8b4f6330c162e04b3c6aeecbb.tar.xz
org.eclipse.linuxtools-eb5a7e12754184f8b4f6330c162e04b3c6aeecbb.zip
Bug 469112 - Error when detecting boot2docker settings on Windows
Use "cmd.exe /C" on Windows to run the script since only .exe can be executed on Windows Change-Id: Ibad4a560f175a050349e453fc491afeb927c3384 Signed-off-by: Xavier Coulon <xcoulon@redhat.com> Reviewed-on: https://git.eclipse.org/r/49225 Tested-by: Hudson CI Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> Tested-by: Jeff Johnston <jjohnstn@redhat.com> Reviewed-on: https://git.eclipse.org/r/49237
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java32
1 files changed, 28 insertions, 4 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java
index abfa65a033..5c21fb2edc 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java
@@ -206,9 +206,11 @@ public class DockerConnection implements IDockerConnection {
Messages.Docker_No_Settings_Description_Script));
return false;
}
- final File connectionSettingsDetectionScript = getConnectionSettingsDetectionScript(connectionSettingsDetectionScriptName);
- final Process process = Runtime.getRuntime().exec(
- new String[] {connectionSettingsDetectionScript.getAbsolutePath()});
+ final File connectionSettingsDetectionScript = getConnectionSettingsDetectionScript(
+ connectionSettingsDetectionScriptName);
+ final String[] cmdArray = getConnectionSettingsDetectionCommandArray(
+ connectionSettingsDetectionScript);
+ final Process process = Runtime.getRuntime().exec(cmdArray);
process.waitFor();
if (process.exitValue() == 0) {
final InputStream processInputStream = process
@@ -242,13 +244,35 @@ public class DockerConnection implements IDockerConnection {
Activator.log(new Status(IStatus.ERROR,
Activator.PLUGIN_ID, errorMessage));
}
- } catch (IOException | InterruptedException e) {
+ } catch (IOException | IllegalArgumentException
+ | InterruptedException e) {
throw new DockerException(Messages.Retrieve_Default_Settings_Failure, e);
}
return false;
}
/**
+ * @param script
+ * the script to execute
+ * @return the OS-specific command to run the connection settings
+ * detection script.
+ */
+ private String[] getConnectionSettingsDetectionCommandArray(
+ final File script) {
+ final String osName = System.getProperty("os.name"); //$NON-NLS-1$
+ if (osName.toLowerCase().startsWith("win")) { //$NON-NLS-1$
+ return new String[] { "cmd.exe", "/C", //$NON-NLS-1$ //$NON-NLS-2$
+ script.getAbsolutePath() };
+ } else if (osName.toLowerCase().startsWith("mac") //$NON-NLS-1$
+ || osName.toLowerCase().contains("linux") //$NON-NLS-1$
+ || osName.toLowerCase().contains("nix")) { //$NON-NLS-1$
+ return new String[] { script.getAbsolutePath() };
+ } else {
+ return null;
+ }
+ }
+
+ /**
* Finds the script file in the data directory of the bundle given its
* name, or creates it from the 'resources' dir in the bundle if it was
* not found in the data dir.

Back to the top