Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Coulon2016-01-15 09:10:52 +0000
committerJeff Johnston2016-01-18 21:57:10 +0000
commit919d59c4404f788576d37a5c9375435872780c7b (patch)
tree04a9cff6ea8b3be79d3f31f2cafef611ee316f51 /containers/org.eclipse.linuxtools.docker.core/src/org/eclipse
parent0a03290b076819c83377b6c62aa3950f2cd66e25 (diff)
downloadorg.eclipse.linuxtools-919d59c4404f788576d37a5c9375435872780c7b.tar.gz
org.eclipse.linuxtools-919d59c4404f788576d37a5c9375435872780c7b.tar.xz
org.eclipse.linuxtools-919d59c4404f788576d37a5c9375435872780c7b.zip
Bug 475331 - NullPointerException in DockerConnection.getInfo
Prevent NPE when DockerClient is null, and prevent NPE in callers that would retrieve a null value. Change-Id: I23fbdfd9f70cfdb0fc182f084377262a0eebd89d Signed-off-by: Xavier Coulon <xcoulon@redhat.com> Reviewed-on: https://git.eclipse.org/r/64358 Tested-by: Hudson CI Reviewed-on: https://git.eclipse.org/r/64600 Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
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/docker/core/IDockerConnection.java11
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java12
2 files changed, 16 insertions, 7 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection.java
index 7be3d641fb..d0511a072d 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Red Hat.
+ * Copyright (c) 2014-2016 Red Hat.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -65,7 +65,7 @@ public interface IDockerConnection {
/**
* @return the {@link IDockerImageInfo} for the {@link IDockerImage}
* identified by the given {@code id} or <code>null</code> if none
- * was found.
+ * was found or if the underlying client was not initialized
* @param id
* the {@link IDockerImage} id
*/
@@ -157,8 +157,11 @@ public interface IDockerConnection {
public void close();
/**
- * @return the {@link IDockerConnectionInfo} associated with this {@link IDockerConnection}
- * @throws DockerException if info retrieval failed
+ * @return the {@link IDockerConnectionInfo} associated with this
+ * {@link IDockerConnection} or <code>null</code> if the underlying
+ * client was not initialized.
+ * @throws DockerException
+ * if info retrieval failed
*/
public IDockerConnectionInfo getInfo() throws DockerException;
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 3978674534..e03cdc02de 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
@@ -303,9 +303,12 @@ public class DockerConnection implements IDockerConnection, Closeable {
@Override
public IDockerConnectionInfo getInfo() throws DockerException {
+ if (this.client == null) {
+ return null;
+ }
try {
- final Info info = client.info();
- final Version version = client.version();
+ final Info info = this.client.info();
+ final Version version = this.client.version();
return new DockerConnectionInfo(info, version);
} catch (com.spotify.docker.client.DockerRequestException e) {
throw new DockerException(e.message());
@@ -638,8 +641,11 @@ public class DockerConnection implements IDockerConnection, Closeable {
@Override
public IDockerImageInfo getImageInfo(String id) {
+ if (this.client == null) {
+ return null;
+ }
try {
- final ImageInfo info = client.inspectImage(id);
+ final ImageInfo info = this.client.inspectImage(id);
return new DockerImageInfo(info);
} catch (com.spotify.docker.client.DockerRequestException e) {
Activator.logErrorMessage(e.message());

Back to the top