diff options
author | Xavier Coulon | 2016-11-22 20:45:09 +0000 |
---|---|---|
committer | Jeff Johnston | 2016-11-22 22:01:02 +0000 |
commit | c7817de26ef2f92de8cc056bb3d3148a0e887222 (patch) | |
tree | ad0d561d4568055f4bc9f1f5a00723b4b16f85cb /containers/org.eclipse.linuxtools.docker.core/src/org/eclipse | |
parent | 38b39dd7452110c01381d45b2ae7b2355b2d87b8 (diff) | |
download | org.eclipse.linuxtools-c7817de26ef2f92de8cc056bb3d3148a0e887222.tar.gz org.eclipse.linuxtools-c7817de26ef2f92de8cc056bb3d3148a0e887222.tar.xz org.eclipse.linuxtools-c7817de26ef2f92de8cc056bb3d3148a0e887222.zip |
Bug 507769 - NullPointerException when the list of images is not loaded in the Run launch config
Main problem was that the result of the call to `getImages(force)` was not assigned to
the local `latestImages` variable which was set to `null` (as `this.images` would be
`null` at this stage). Thus, even though the list of images was correctly loaded, it
would return `null` on the first call.
Also, removed the use of `containersLoaded` and `imagesLoaded` fields, which can be
replaced with tests on the `containers` and `images` lists instead.
Change-Id: I64584fbee2da1dfa8d6146c9ecfd89b3f3623e34
Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
Reviewed-on: https://git.eclipse.org/r/85314
Tested-by: Hudson CI
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/internal/docker/core/DockerConnection.java | 16 |
1 files changed, 4 insertions, 12 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 ab1f7a4d70..5ee3f3bee1 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 @@ -189,9 +189,7 @@ public class DockerConnection private Map<String, IDockerContainer> containersById = new HashMap<>(); // flag to indicate if the state of the connection to the Docker daemon private EnumDockerConnectionState state = EnumDockerConnectionState.UNKNOWN; - private boolean containersLoaded = false; private List<IDockerImage> images; - private boolean imagesLoaded = false; private Boolean isLocalConnection; ListenerList<IDockerContainerListener> containerListeners; @@ -292,7 +290,7 @@ public class DockerConnection this.connectionInfo = getInfo(); } catch (Exception e) { // ignore for now as this seems to occur too often and we always - // check the value of connectioninfo before using + // check the value of connectionInfo before using } } /** @@ -320,8 +318,6 @@ public class DockerConnection this.images = Collections.emptyList(); this.containers = Collections.emptyList(); this.containersById = new HashMap<>(); - this.imagesLoaded = true; - this.containersLoaded = true; notifyContainerListeners(this.containers); notifyImageListeners(this.images); break; @@ -579,7 +575,7 @@ public class DockerConnection @Override public boolean isContainersLoaded() { - return containersLoaded; + return this.containers != null; } /** @@ -749,7 +745,6 @@ public class DockerConnection (container, otherContainer) -> container.name() .compareTo(otherContainer.name())); this.containers = sortedContainers; - this.containersLoaded = true; } } // perform notification outside of containerLock so we don't have a View @@ -963,7 +958,7 @@ public class DockerConnection } else if (this.state == EnumDockerConnectionState.UNKNOWN) { try { open(true); - getImages(force); + latestImages = getImages(force); } catch (DockerException e) { Activator.log(e); } @@ -975,8 +970,6 @@ public class DockerConnection this.images = Collections.emptyList(); } Activator.log(e); - } finally { - this.imagesLoaded = true; } } return latestImages; @@ -984,7 +977,7 @@ public class DockerConnection @Override public boolean isImagesLoaded() { - return imagesLoaded; + return this.images != null; } // TODO: remove this method from the API @@ -1054,7 +1047,6 @@ public class DockerConnection } } finally { this.images = tempImages; - this.imagesLoaded = true; } } // Perform notification outside of lock so that listener doesn't cause a |