diff options
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, |