Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Coulon2016-01-14 10:43:32 +0000
committerJeff Johnston2016-01-19 17:48:17 +0000
commit014be453aac2ed06ac50c0e1126c76338c0f0e18 (patch)
treebfa35c83c0316e7b0eddc22ec5b9435178d81484 /containers/org.eclipse.linuxtools.docker.core/src/org/eclipse
parent74009a4c16dd7d815428a428cde147b63dead303 (diff)
downloadorg.eclipse.linuxtools-014be453aac2ed06ac50c0e1126c76338c0f0e18.tar.gz
org.eclipse.linuxtools-014be453aac2ed06ac50c0e1126c76338c0f0e18.tar.xz
org.eclipse.linuxtools-014be453aac2ed06ac50c0e1126c76338c0f0e18.zip
Bug 485733 - NullPointerException in DefaultDockerConnectionSettingsFinder.defaultsWithShellEnv
Fixed the default value to 'false' instead of 'null' when there is no DOCKER_TLS_VERIFY variable available Added unit tests Change-Id: Ib1be00ca2ba87cd4e6d57efc363c75acdf94d7d2 Signed-off-by: Xavier Coulon <xcoulon@redhat.com> Reviewed-on: https://git.eclipse.org/r/64653 Tested-by: Hudson CI Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> (cherry picked from commit 58caa912f554efd30455a3b76744591e88e3699d) Reviewed-on: https://git.eclipse.org/r/64676
Diffstat (limited to 'containers/org.eclipse.linuxtools.docker.core/src/org/eclipse')
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DefaultDockerConnectionSettingsFinder.java40
1 files changed, 22 insertions, 18 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DefaultDockerConnectionSettingsFinder.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DefaultDockerConnectionSettingsFinder.java
index 5a5f99e050..fd576cea3e 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DefaultDockerConnectionSettingsFinder.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DefaultDockerConnectionSettingsFinder.java
@@ -121,7 +121,7 @@ public class DefaultDockerConnectionSettingsFinder
* @return {@code IDockerConnectionSettings} if the Unix socket exists and
* is readable and writable, {@code null} otherwise.
*/
- private IDockerConnectionSettings defaultsWithUnixSocket() {
+ public IDockerConnectionSettings defaultsWithUnixSocket() {
final File unixSocketFile = new File("/var/run/docker.sock"); //$NON-NLS-1$
if (unixSocketFile.exists() && unixSocketFile.canRead()
&& unixSocketFile.canWrite()) {
@@ -146,7 +146,7 @@ public class DefaultDockerConnectionSettingsFinder
* @return {@code IDockerConnectionSettings} if the {@code DOCKER_xxx}
* environment variables exist, {@code null} otherwise.
*/
- private IDockerConnectionSettings defaultsWithSystemEnv() {
+ public IDockerConnectionSettings defaultsWithSystemEnv() {
final String dockerHostEnv = System.getenv(DOCKER_HOST);
if (dockerHostEnv != null) {
final String tlsVerifyEnv = System.getenv(DOCKER_TLS_VERIFY);
@@ -165,9 +165,8 @@ public class DefaultDockerConnectionSettingsFinder
*
* @return {@code IDockerConnectionSettings} if the {@code DOCKER_xxx}
* environment variables exist, {@code null} otherwise.
- * @throws DockerException
*/
- private IDockerConnectionSettings defaultsWithShellEnv() {
+ public IDockerConnectionSettings defaultsWithShellEnv() {
try {
final String connectionSettingsDetectionScriptName = getConnectionSettingsDetectionScriptName();
if (connectionSettingsDetectionScriptName == null) {
@@ -187,20 +186,7 @@ public class DefaultDockerConnectionSettingsFinder
// read content from process input stream
final Properties dockerSettings = new Properties();
dockerSettings.load(processInputStream);
- final Object dockerHostEnvVariable = dockerSettings.get(DOCKER_HOST);
- final Object dockerTlsVerifyEnvVariable = dockerSettings
- .get(DOCKER_TLS_VERIFY);
- final Object dockerCertPathEnvVariable = dockerSettings
- .get(DOCKER_CERT_PATH);
- return new TCPConnectionSettings(
- dockerHostEnvVariable != null
- ? dockerHostEnvVariable.toString() : null,
- dockerTlsVerifyEnvVariable != null
- ? dockerTlsVerifyEnvVariable
- .equals(DOCKER_TLS_VERIFY_TRUE)
- : null,
- dockerCertPathEnvVariable != null
- ? dockerCertPathEnvVariable.toString() : null);
+ return createDockerConnectionSettings(dockerSettings);
} else {
// log what happened if the process did not end as expected
// an exit value of 1 should indicate no connection found
@@ -221,6 +207,24 @@ public class DefaultDockerConnectionSettingsFinder
return null;
}
+ public IDockerConnectionSettings createDockerConnectionSettings(
+ final Properties dockerSettings) {
+ final Object dockerHostEnvVariable = dockerSettings.get(DOCKER_HOST);
+ final Object dockerTlsVerifyEnvVariable = dockerSettings
+ .get(DOCKER_TLS_VERIFY);
+ final Object dockerCertPathEnvVariable = dockerSettings
+ .get(DOCKER_CERT_PATH);
+ return new TCPConnectionSettings(
+ dockerHostEnvVariable != null
+ ? dockerHostEnvVariable.toString() : null,
+ dockerTlsVerifyEnvVariable != null
+ ? dockerTlsVerifyEnvVariable
+ .equals(DOCKER_TLS_VERIFY_TRUE)
+ : false,
+ dockerCertPathEnvVariable != null
+ ? dockerCertPathEnvVariable.toString() : null);
+ }
+
/**
* @param script
* the script to execute

Back to the top