Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2019-06-06 20:15:28 -0400
committerJeff Johnston2019-06-06 22:22:32 -0400
commit037d7779f5e9612b45684ff6ee85204983768a0d (patch)
tree107c04d8120dce292049a17f47634291ee696633
parent1e037ba754c52cc391fe80dec5148077ed4fe737 (diff)
downloadorg.eclipse.linuxtools-037d7779f5e9612b45684ff6ee85204983768a0d.tar.gz
org.eclipse.linuxtools-037d7779f5e9612b45684ff6ee85204983768a0d.tar.xz
org.eclipse.linuxtools-037d7779f5e9612b45684ff6ee85204983768a0d.zip
Bug 548018 - Container launch targets may disappear
- add new IDockerConnection3 interface that adds the isFinalizing() method - have DockerConnection implement IDockerConnection3 and add new isFinalizing() method override - have DockerConnection.finalize() set a boolean field which is returned in the new isFinalizing() method Change-Id: I3d68e0e5eb92396e4cefe4bccbacefc5b09f03c6 Reviewed-on: https://git.eclipse.org/r/143475 Tested-by: Linux Tools Bot <linuxtools-bot@eclipse.org> Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection3.java25
-rw-r--r--containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java21
2 files changed, 41 insertions, 5 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection3.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection3.java
new file mode 100644
index 0000000000..ad25205787
--- /dev/null
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection3.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Red Hat.
+ *
+ * This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License 2.0
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Red Hat - Initial Contribution
+ *******************************************************************************/
+package org.eclipse.linuxtools.docker.core;
+
+public interface IDockerConnection3 {
+
+ /**
+ * Get whether the connection is finalizing or not.
+ *
+ * @return true if connection is finalizing
+ * @since 4.3
+ */
+ boolean isFinalizing();
+
+}
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 71c855a23f..5c395d9afe 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
@@ -62,6 +62,7 @@ import org.eclipse.linuxtools.docker.core.EnumDockerLoggingStatus;
import org.eclipse.linuxtools.docker.core.IDockerConfParameter;
import org.eclipse.linuxtools.docker.core.IDockerConnection;
import org.eclipse.linuxtools.docker.core.IDockerConnection2;
+import org.eclipse.linuxtools.docker.core.IDockerConnection3;
import org.eclipse.linuxtools.docker.core.IDockerConnectionInfo;
import org.eclipse.linuxtools.docker.core.IDockerConnectionManagerListener;
import org.eclipse.linuxtools.docker.core.IDockerConnectionSettings;
@@ -136,7 +137,8 @@ import com.spotify.docker.client.messages.VolumeList;
*
*/
public class DockerConnection
- implements IDockerConnection, IDockerConnection2, Closeable {
+ implements IDockerConnection, IDockerConnection2, IDockerConnection3,
+ Closeable {
// Builder allowing different binding modes (unix socket vs TCP connection)
public static class Builder {
@@ -182,6 +184,7 @@ public class DockerConnection
@SuppressWarnings("unused")
private IDockerConnectionInfo connectionInfo;
private final String username;
+ private boolean finalizing;
private final Object imageLock = new Object();
private final Object containerLock = new Object();
private final Object actionLock = new Object();
@@ -392,11 +395,17 @@ public class DockerConnection
@Override
protected void finalize() throws Throwable {
+ this.finalizing = true;
close();
super.finalize();
}
@Override
+ public boolean isFinalizing() {
+ return this.finalizing;
+ }
+
+ @Override
public void close() {
// stop and remove all logging threads
for (String key : loggingThreads.keySet().toArray(new String[0])) {
@@ -820,14 +829,15 @@ public class DockerConnection
Activator.log(
new Status(IStatus.WARNING, Activator.PLUGIN_ID,
Messages.Docker_Connection_Timeout, e));
- close();
}
} catch (com.spotify.docker.client.exceptions.DockerException
| InterruptedException e) {
if (isOpen() && e.getCause() != null
&& e.getCause().getCause() != null && e.getCause()
.getCause() instanceof ProcessingException) {
- close();
+ Activator.log(new Status(IStatus.WARNING,
+ Activator.PLUGIN_ID,
+ Messages.List_Docker_Containers_Failure, e));
} else {
throw new DockerException(e.getMessage());
}
@@ -1125,7 +1135,6 @@ public class DockerConnection
Activator.log(
new Status(IStatus.WARNING, Activator.PLUGIN_ID,
Messages.Docker_Connection_Timeout, e));
- close();
}
} catch (com.spotify.docker.client.exceptions.DockerRequestException e) {
throw new DockerException(e.getResponseBody());
@@ -1134,7 +1143,9 @@ public class DockerConnection
if (isOpen() && e.getCause() != null
&& e.getCause().getCause() != null && e.getCause()
.getCause() instanceof ProcessingException) {
- close();
+ Activator.log(
+ new Status(IStatus.WARNING, Activator.PLUGIN_ID,
+ Messages.List_Docker_Images_Failure, e));
} else {
throw new DockerException(
NLS.bind(Messages.List_Docker_Images_Failure,

Back to the top