diff options
author | Xavier Coulon | 2016-01-14 11:29:05 +0000 |
---|---|---|
committer | Jeff Johnston | 2016-01-18 23:07:22 +0000 |
commit | 71dce61d031b429041d048f10c80f7f896b69ed5 (patch) | |
tree | 0568ebe2c6825458fd00b89e1912e5503fd0d67d | |
parent | c813585d7d5674bdd3a9f11910f3497168dc9876 (diff) | |
download | org.eclipse.linuxtools-71dce61d031b429041d048f10c80f7f896b69ed5.tar.gz org.eclipse.linuxtools-71dce61d031b429041d048f10c80f7f896b69ed5.tar.xz org.eclipse.linuxtools-71dce61d031b429041d048f10c80f7f896b69ed5.zip |
Bug 485732 - DockerException in DockerConnection.ping
Prevent NPE if the client is null
Only log the exception if there's an underlying cause.
Change-Id: Iaae5ee3d8b967e6736ffe37b577fa6729ce294bc
Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
Reviewed-on: https://git.eclipse.org/r/64364
Tested-by: Hudson CI
Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
(cherry picked from commit 4b7421a420ba3913d02130bc99457aa9a29b149d)
Reviewed-on: https://git.eclipse.org/r/64508
2 files changed, 24 insertions, 15 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtilsSWTBotTest.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtilsSWTBotTest.java index 8ba73909c3..4038e979c7 100644 --- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtilsSWTBotTest.java +++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/commands/CommandUtilsSWTBotTest.java @@ -70,7 +70,7 @@ public class CommandUtilsSWTBotTest { } @Test - public void shouldRetrieveConnectionFromSelectedContainersCategory() throws InterruptedException { + public void shouldRetrieveConnectionFromSelectedContainersCategory() { // given final DockerClient client = MockDockerClientFactory .container(MockDockerContainerFactory.name("foo_bar").build()).build(); @@ -84,7 +84,7 @@ public class CommandUtilsSWTBotTest { } @Test - public void shouldRetrieveConnectionFromSelectedContainer() throws InterruptedException { + public void shouldRetrieveConnectionFromSelectedContainer() { // given final DockerClient client = MockDockerClientFactory .container(MockDockerContainerFactory.name("foo_bar").build()).build(); @@ -98,7 +98,7 @@ public class CommandUtilsSWTBotTest { } @Test - public void shouldRetrieveConnectionFromSelectedContainerLinksCategory() throws InterruptedException { + public void shouldRetrieveConnectionFromSelectedContainerLinksCategory() { // given final DockerClient client = MockDockerClientFactory .container(MockDockerContainerFactory.name("foo_bar").build(), @@ -118,7 +118,7 @@ public class CommandUtilsSWTBotTest { } @Test - public void shouldRetrieveConnectionFromSelectedContainerLink() throws InterruptedException { + public void shouldRetrieveConnectionFromSelectedContainerLink() { // given final DockerClient client = MockDockerClientFactory .container(MockDockerContainerFactory.name("foo_bar").build(), @@ -139,7 +139,7 @@ public class CommandUtilsSWTBotTest { } @Test - public void shouldRetrieveConnectionFromSelectedContainerVolumesCategory() throws InterruptedException { + public void shouldRetrieveConnectionFromSelectedContainerVolumesCategory() { // given final DockerClient client = MockDockerClientFactory .container(MockDockerContainerFactory.name("foo_bar").build(), @@ -160,7 +160,7 @@ public class CommandUtilsSWTBotTest { } @Test - public void shouldRetrieveConnectionFromSelectedContainerVolume() throws InterruptedException { + public void shouldRetrieveConnectionFromSelectedContainerVolume() { // given final DockerClient client = MockDockerClientFactory .container(MockDockerContainerFactory.name("foo_bar").build(), @@ -181,7 +181,7 @@ public class CommandUtilsSWTBotTest { } @Test - public void shouldRetrieveConnectionFromSelectedContainerPortsCategory() throws InterruptedException { + public void shouldRetrieveConnectionFromSelectedContainerPortsCategory() { // given final DockerClient client = MockDockerClientFactory .container(MockDockerContainerFactory.name("foo_bar").build(), @@ -201,7 +201,7 @@ public class CommandUtilsSWTBotTest { } @Test - public void shouldRetrieveConnectionFromSelectedContainerPort() throws InterruptedException { + public void shouldRetrieveConnectionFromSelectedContainerPort() { // given final DockerClient client = MockDockerClientFactory .container(MockDockerContainerFactory.name("foo_bar").build(), @@ -222,7 +222,7 @@ public class CommandUtilsSWTBotTest { } @Test - public void shouldRetrieveConnectionFromSelectedImagesCategory() throws InterruptedException { + public void shouldRetrieveConnectionFromSelectedImagesCategory() { // given final DockerClient client = MockDockerClientFactory.image(MockDockerImageFactory.name("foo").build()) .build(); @@ -236,7 +236,7 @@ public class CommandUtilsSWTBotTest { } @Test - public void shouldRetrieveConnectionFromSelectedImage() throws InterruptedException { + public void shouldRetrieveConnectionFromSelectedImage() { // given final DockerClient client = MockDockerClientFactory.image(MockDockerImageFactory.name("foo").build()) .build(); diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionPage.java index 0a8c2ff4ef..b2d36174a1 100644 --- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionPage.java +++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionPage.java @@ -77,6 +77,8 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.dialogs.ListDialog; import org.eclipse.ui.dialogs.PreferencesUtil; +import com.spotify.docker.client.DockerCertificateException; + /** * {@link WizardPage} to input the settings to connect to a Docker * engine/daemon. @@ -572,12 +574,19 @@ public class NewDockerConnectionPage extends WizardPage { IProgressMonitor.UNKNOWN); try { final DockerConnection dockerConnection = getDockerConnection(); - dockerConnection.open(false); - dockerConnection.ping(); - dockerConnection.close(); - resultQueue.add(true); + if (dockerConnection.getClient() != null) { + dockerConnection.open(false); + dockerConnection.ping(); + dockerConnection.close(); + resultQueue.add(true); + } else { + resultQueue.add(false); + } } catch (DockerException e) { - Activator.log(e); + // only log if there's an underlying cause. + if (e.getCause() != null) { + Activator.log(e); + } resultQueue.add(false); } } |