diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7dec19aef..d301147be 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,5 +4,6 @@ updates: directory: "/" schedule: interval: weekly + day: tuesday open-pull-requests-limit: 99 rebase-strategy: disabled diff --git a/docker-java-api/pom.xml b/docker-java-api/pom.xml index 82d176e38..8bfd9e8d4 100644 --- a/docker-java-api/pom.xml +++ b/docker-java-api/pom.xml @@ -42,7 +42,7 @@ org.projectlombok lombok - 1.18.30 + 1.18.38 provided @@ -50,7 +50,7 @@ org.junit.jupiter junit-jupiter - 5.10.0 + 5.12.1 test @@ -84,6 +84,18 @@ com.github.siom79.japicmp japicmp-maven-plugin + + + + com.github.dockerjava.api.command.UpdateContainerCmd#getCpuPeriod() + com.github.dockerjava.api.command.UpdateContainerCmd#withCpuPeriod(java.lang.Integer) + com.github.dockerjava.api.command.UpdateContainerCmd#getCpuQuota() + com.github.dockerjava.api.command.UpdateContainerCmd#withCpuQuota(java.lang.Integer) + com.github.dockerjava.api.command.InspectContainerResponse#getSizeRootFs() + com.github.dockerjava.api.command.InspectContainerResponse#getSizeRw() + + + diff --git a/docker-java-api/src/main/java/com/github/dockerjava/api/command/InspectContainerResponse.java b/docker-java-api/src/main/java/com/github/dockerjava/api/command/InspectContainerResponse.java index 94207fd2c..f06bd4ed9 100644 --- a/docker-java-api/src/main/java/com/github/dockerjava/api/command/InspectContainerResponse.java +++ b/docker-java-api/src/main/java/com/github/dockerjava/api/command/InspectContainerResponse.java @@ -61,10 +61,10 @@ public class InspectContainerResponse extends DockerObject { private String id; @JsonProperty("SizeRootFs") - private Integer sizeRootFs; + private Long sizeRootFs; @JsonProperty("SizeRw") - private Integer sizeRw; + private Long sizeRw; @JsonProperty("Image") private String imageId; @@ -124,11 +124,11 @@ public String getId() { return id; } - public Integer getSizeRootFs() { + public Long getSizeRootFs() { return sizeRootFs; } - public Integer getSizeRw() { + public Long getSizeRw() { return sizeRw; } diff --git a/docker-java-api/src/main/java/com/github/dockerjava/api/command/UpdateContainerCmd.java b/docker-java-api/src/main/java/com/github/dockerjava/api/command/UpdateContainerCmd.java index 82fbca5f8..d53bcdcdf 100644 --- a/docker-java-api/src/main/java/com/github/dockerjava/api/command/UpdateContainerCmd.java +++ b/docker-java-api/src/main/java/com/github/dockerjava/api/command/UpdateContainerCmd.java @@ -1,9 +1,16 @@ package com.github.dockerjava.api.command; +import com.github.dockerjava.api.model.BlkioRateDevice; +import com.github.dockerjava.api.model.BlkioWeightDevice; +import com.github.dockerjava.api.model.Device; +import com.github.dockerjava.api.model.DeviceRequest; +import com.github.dockerjava.api.model.RestartPolicy; +import com.github.dockerjava.api.model.Ulimit; import com.github.dockerjava.api.model.UpdateContainerResponse; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; +import java.util.List; /** * @author Kanstantsin Shautsou @@ -13,22 +20,47 @@ public interface UpdateContainerCmd extends SyncDockerCmd getBlkioWeightDevice(); + + UpdateContainerCmd withBlkioWeightDevice(List blkioWeightDevice); @CheckForNull - Integer getCpuPeriod(); + List getBlkioDeviceReadBps(); - UpdateContainerCmd withCpuPeriod(Integer cpuPeriod); + UpdateContainerCmd withBlkioDeviceReadBps(List blkioDeviceReadBps); @CheckForNull - Integer getCpuQuota(); + List getBlkioDeviceWriteBps(); - UpdateContainerCmd withCpuQuota(Integer cpuQuota); + UpdateContainerCmd withBlkioDeviceWriteBps(List blkioDeviceWriteBps); + + @CheckForNull + List getBlkioDeviceReadIOps(); + + UpdateContainerCmd withBlkioDeviceReadIOps(List blkioDeviceReadIOps); + + @CheckForNull + List getBlkioDeviceWriteIOps(); + + UpdateContainerCmd withBlkioDeviceWriteIOps(List blkioDeviceWriteIOps); + + @CheckForNull + Long getCpuPeriod(); + + UpdateContainerCmd withCpuPeriod(Long cpuPeriod); + + @CheckForNull + Long getCpuQuota(); + + UpdateContainerCmd withCpuQuota(Long cpuQuota); @CheckForNull String getCpusetCpus(); @@ -45,6 +77,31 @@ public interface UpdateContainerCmd extends SyncDockerCmd getDevices(); + + UpdateContainerCmd withDevices(List devices); + + @CheckForNull + List getDeviceCgroupRules(); + + UpdateContainerCmd withDeviceCgroupRules(List deviceCgroupRules); + + @CheckForNull + List getDeviceRequests(); + + UpdateContainerCmd withDeviceRequests(List deviceRequests); + @CheckForNull Long getKernelMemory(); @@ -65,6 +122,36 @@ public interface UpdateContainerCmd extends SyncDockerCmd getUlimits(); + + UpdateContainerCmd withUlimits(List ulimits); + + @CheckForNull + RestartPolicy getRestartPolicy(); + + UpdateContainerCmd withRestartPolicy(RestartPolicy restartPolicy); + interface Exec extends DockerCmdSyncExec { } } diff --git a/docker-java-api/src/main/java/com/github/dockerjava/api/model/Info.java b/docker-java-api/src/main/java/com/github/dockerjava/api/model/Info.java index 75afefd2b..67348b86b 100644 --- a/docker-java-api/src/main/java/com/github/dockerjava/api/model/Info.java +++ b/docker-java-api/src/main/java/com/github/dockerjava/api/model/Info.java @@ -1108,14 +1108,33 @@ public Info withIsolation(String isolation) { return this; } + /** + * @see #securityOptions + */ public List getSecurityOptions() { return securityOptions; } + /** + * @see #securityOptions + */ + public Info withSecurityOptions(List securityOptions) { + this.securityOptions = securityOptions; + return this; + } + /** * @see #runtimes */ public Map getRuntimes() { return runtimes; } + + /** + * @see #runtimes + */ + public Info withRuntimes(Map runtimes) { + this.runtimes = runtimes; + return this; + } } diff --git a/docker-java-core/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java b/docker-java-core/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java index 8011a2a5e..dad75b360 100644 --- a/docker-java-core/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java +++ b/docker-java-core/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java @@ -5,6 +5,8 @@ import com.github.dockerjava.api.model.AuthConfigurations; import com.github.dockerjava.core.NameParser.HostnameReposName; import com.github.dockerjava.core.NameParser.ReposTag; + +import java.util.Map.Entry; import java.util.Optional; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.SystemUtils; @@ -128,9 +130,11 @@ private static Properties loadIncludedDockerProperties(Properties systemProperti } private static void replaceProperties(Properties properties, Properties replacements) { - for (Object objectKey : properties.keySet()) { - String key = objectKey.toString(); - properties.setProperty(key, replaceProperties(properties.getProperty(key), replacements)); + for (Entry entry : properties.entrySet()) { + final String key = entry.getKey().toString(); + // no entry.getValue here because it does not have the same semantics as getProperty (defaults handling) + final String value = properties.getProperty(key); + entry.setValue(replaceProperties(value, replacements)); } } diff --git a/docker-java-core/src/main/java/com/github/dockerjava/core/command/UpdateContainerCmdImpl.java b/docker-java-core/src/main/java/com/github/dockerjava/core/command/UpdateContainerCmdImpl.java index 14357ba08..47ab710eb 100644 --- a/docker-java-core/src/main/java/com/github/dockerjava/core/command/UpdateContainerCmdImpl.java +++ b/docker-java-core/src/main/java/com/github/dockerjava/core/command/UpdateContainerCmdImpl.java @@ -4,6 +4,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.github.dockerjava.api.command.UpdateContainerCmd; import com.github.dockerjava.api.exception.NotFoundException; +import com.github.dockerjava.api.model.BlkioRateDevice; +import com.github.dockerjava.api.model.BlkioWeightDevice; +import com.github.dockerjava.api.model.Device; +import com.github.dockerjava.api.model.DeviceRequest; +import com.github.dockerjava.api.model.RestartPolicy; +import com.github.dockerjava.api.model.Ulimit; import com.github.dockerjava.api.model.UpdateContainerResponse; import com.github.dockerjava.core.RemoteApiVersion; import org.apache.commons.lang3.builder.EqualsBuilder; @@ -12,6 +18,7 @@ import javax.annotation.CheckForNull; import javax.annotation.Nonnull; +import java.util.List; /** * @author Kanstantsin Shautsou @@ -28,14 +35,38 @@ public class UpdateContainerCmdImpl extends AbstrDockerCmd blkioWeightDevice; + + @JsonProperty("BlkioDeviceReadBps") + private List blkioDeviceReadBps; + + @JsonProperty("BlkioDeviceWriteBps") + private List blkioDeviceWriteBps; + + @JsonProperty("BlkioDeviceReadIOps") + private List blkioDeviceReadIOps; + + @JsonProperty("BlkioDeviceWriteIOps") + private List blkioDeviceWriteIOps; + @JsonProperty("CpuShares") private Integer cpuShares; @JsonProperty("CpuPeriod") - private Integer cpuPeriod; + private Long cpuPeriod; @JsonProperty("CpuQuota") - private Integer cpuQuota; + private Long cpuQuota; + + @JsonProperty("CpuRealtimePeriod") + private Long cpuRealtimePeriod; + + @JsonProperty("CpuRealtimeRuntime") + private Long cpuRealtimeRuntime; + + @JsonProperty("NanoCpus") + private Long nanoCPUs; @JsonProperty("CpusetCpus") private String cpusetCpus; @@ -43,6 +74,18 @@ public class UpdateContainerCmdImpl extends AbstrDockerCmd devices; + + @JsonProperty("DeviceCgroupRules") + private List deviceCgroupRules; + + /** + * @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_40} + */ + @JsonProperty("DeviceRequests") + private List deviceRequests; + @JsonProperty("Memory") private Long memory; @@ -55,11 +98,43 @@ public class UpdateContainerCmdImpl extends AbstrDockerCmd ulimits; + + @JsonProperty("RestartPolicy") + private RestartPolicy restartPolicy; + public UpdateContainerCmdImpl(UpdateContainerCmd.Exec exec, String containerId) { super(exec); withContainerId(containerId); } + /** + * @see #containerId + */ + @CheckForNull + @JsonIgnore + public String getContainerId() { + return containerId; + } + + /** + * @see #containerId + */ + public UpdateContainerCmd withContainerId(@Nonnull String containerId) { + this.containerId = containerId; + return this; + } + /** * @see #blkioWeight */ @@ -77,19 +152,68 @@ public UpdateContainerCmd withBlkioWeight(Integer blkioWeight) { } /** - * @see #containerId + * @see #blkioWeightDevice */ @CheckForNull - @JsonIgnore - public String getContainerId() { - return containerId; + public List getBlkioWeightDevice() { + return blkioWeightDevice; + } + + public UpdateContainerCmd withBlkioWeightDevice(List blkioWeightDevice) { + this.blkioWeightDevice = blkioWeightDevice; + return this; } /** - * @see #containerId + * @see #blkioDeviceReadBps */ - public UpdateContainerCmd withContainerId(@Nonnull String containerId) { - this.containerId = containerId; + @CheckForNull + public List getBlkioDeviceReadBps() { + return blkioDeviceReadBps; + } + + public UpdateContainerCmd withBlkioDeviceReadBps(List blkioDeviceReadBps) { + this.blkioDeviceReadBps = blkioDeviceReadBps; + return this; + } + + /** + * @see #blkioDeviceWriteBps + */ + @CheckForNull + public List getBlkioDeviceWriteBps() { + return blkioDeviceWriteBps; + } + + public UpdateContainerCmd withBlkioDeviceWriteBps(List blkioDeviceWriteBps) { + this.blkioDeviceWriteBps = blkioDeviceWriteBps; + return this; + } + + /** + * @see #blkioDeviceReadIOps + */ + @CheckForNull + public List getBlkioDeviceReadIOps() { + return blkioDeviceReadIOps; + } + + public UpdateContainerCmd withBlkioDeviceReadIOps(List blkioDeviceReadIOps) { + this.blkioDeviceReadIOps = blkioDeviceReadIOps; + return this; + } + + /** + * @see #blkioDeviceWriteIOps + */ + @CheckForNull + public List getBlkioDeviceWriteIOps() { + return blkioDeviceWriteIOps; + } + + @Override + public UpdateContainerCmd withBlkioDeviceWriteIOps(List blkioDeviceWriteIOps) { + this.blkioDeviceWriteIOps = blkioDeviceWriteIOps; return this; } @@ -97,14 +221,14 @@ public UpdateContainerCmd withContainerId(@Nonnull String containerId) { * @see #cpuPeriod */ @CheckForNull - public Integer getCpuPeriod() { + public Long getCpuPeriod() { return cpuPeriod; } /** * @see #cpuPeriod */ - public UpdateContainerCmd withCpuPeriod(Integer cpuPeriod) { + public UpdateContainerCmd withCpuPeriod(Long cpuPeriod) { this.cpuPeriod = cpuPeriod; return this; } @@ -113,14 +237,14 @@ public UpdateContainerCmd withCpuPeriod(Integer cpuPeriod) { * @see #cpuQuota */ @CheckForNull - public Integer getCpuQuota() { + public Long getCpuQuota() { return cpuQuota; } /** * @see #cpuQuota */ - public UpdateContainerCmd withCpuQuota(Integer cpuQuota) { + public UpdateContainerCmd withCpuQuota(Long cpuQuota) { this.cpuQuota = cpuQuota; return this; } @@ -173,6 +297,71 @@ public UpdateContainerCmd withCpuShares(Integer cpuShares) { return this; } + /** + * @see #cpuRealtimePeriod + */ + @CheckForNull + public Long getCpuRealtimePeriod() { + return cpuRealtimePeriod; + } + + public UpdateContainerCmd withCpuRealtimePeriod(Long cpuRealtimePeriod) { + this.cpuRealtimePeriod = cpuRealtimePeriod; + return this; + } + + /** + * @see #cpuRealtimeRuntime + */ + @CheckForNull + public Long getCpuRealtimeRuntime() { + return cpuRealtimeRuntime; + } + + public UpdateContainerCmd withCpuRealtimeRuntime(Long cpuRealtimeRuntime) { + this.cpuRealtimeRuntime = cpuRealtimeRuntime; + return this; + } + + /** + * @see #devices + */ + @CheckForNull + public List getDevices() { + return devices; + } + + public UpdateContainerCmd withDevices(List devices) { + this.devices = devices; + return this; + } + + /** + * @see #deviceCgroupRules + */ + @CheckForNull + public List getDeviceCgroupRules() { + return deviceCgroupRules; + } + + public UpdateContainerCmd withDeviceCgroupRules(List deviceCgroupRules) { + this.deviceCgroupRules = deviceCgroupRules; + return this; + } + + /** + * @see #deviceRequests + */ + @CheckForNull + public List getDeviceRequests() { + return deviceRequests; + } + + public UpdateContainerCmd withDeviceRequests(List deviceRequests) { + this.deviceRequests = deviceRequests; + return this; + } + /** * @see #kernelMemory */ @@ -237,6 +426,84 @@ public UpdateContainerCmd withMemorySwap(Long memorySwap) { return this; } + /** + * @see #nanoCPUs + */ + @CheckForNull + public Long getNanoCPUs() { + return nanoCPUs; + } + + public UpdateContainerCmd withNanoCPUs(Long nanoCPUs) { + this.nanoCPUs = nanoCPUs; + return this; + } + + /** + * @see #oomKillDisable + */ + @CheckForNull + public Boolean getOomKillDisable() { + return oomKillDisable; + } + + public UpdateContainerCmd withOomKillDisable(Boolean oomKillDisable) { + this.oomKillDisable = oomKillDisable; + return this; + } + + /** + * @see #init + */ + @CheckForNull + public Boolean getInit() { + return init; + } + + public UpdateContainerCmd withInit(Boolean init) { + this.init = init; + return this; + } + + /** + * @see #pidsLimit + */ + @CheckForNull + public Long getPidsLimit() { + return pidsLimit; + } + + public UpdateContainerCmd withPidsLimit(Long pidsLimit) { + this.pidsLimit = pidsLimit; + return this; + } + + /** + * @see #ulimits + */ + @CheckForNull + public List getUlimits() { + return ulimits; + } + + public UpdateContainerCmd withUlimits(List ulimits) { + this.ulimits = ulimits; + return this; + } + + /** + * @see #restartPolicy + */ + @CheckForNull + public RestartPolicy getRestartPolicy() { + return restartPolicy; + } + + public UpdateContainerCmd withRestartPolicy(RestartPolicy restartPolicy) { + this.restartPolicy = restartPolicy; + return this; + } + /** * @throws NotFoundException No such container */ diff --git a/docker-java-transport-httpclient5/pom.xml b/docker-java-transport-httpclient5/pom.xml index 48b751d56..0e82715e9 100644 --- a/docker-java-transport-httpclient5/pom.xml +++ b/docker-java-transport-httpclient5/pom.xml @@ -29,13 +29,13 @@ org.apache.httpcomponents.client5 httpclient5 - 5.0.3 + 5.4.3 net.java.dev.jna jna - 5.13.0 + 5.17.0 diff --git a/docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5/ApacheDockerHttpClientImpl.java b/docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5/ApacheDockerHttpClientImpl.java index 4820c65e5..c97a2bc45 100644 --- a/docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5/ApacheDockerHttpClientImpl.java +++ b/docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5/ApacheDockerHttpClientImpl.java @@ -4,31 +4,34 @@ import com.github.dockerjava.transport.NamedPipeSocket; import com.github.dockerjava.transport.SSLConfig; import com.github.dockerjava.transport.UnixSocket; + +import org.apache.hc.client5.http.SystemDefaultDnsResolver; import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase; +import org.apache.hc.client5.http.config.ConnectionConfig; import org.apache.hc.client5.http.config.RequestConfig; +import org.apache.hc.client5.http.impl.DefaultSchemePortResolver; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; -import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator; import org.apache.hc.client5.http.impl.io.ManagedHttpClientConnectionFactory; import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; -import org.apache.hc.client5.http.socket.ConnectionSocketFactory; -import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory; -import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory; +import org.apache.hc.client5.http.io.HttpClientConnectionOperator; +import org.apache.hc.client5.http.ssl.DefaultClientTlsStrategy; +import org.apache.hc.client5.http.ssl.TlsSocketStrategy; +import org.apache.hc.core5.http.ClassicHttpResponse; import org.apache.hc.core5.http.ConnectionClosedException; import org.apache.hc.core5.http.ContentLengthStrategy; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.NameValuePair; -import org.apache.hc.core5.http.config.Registry; -import org.apache.hc.core5.http.config.RegistryBuilder; import org.apache.hc.core5.http.impl.DefaultContentLengthStrategy; -import org.apache.hc.core5.http.impl.io.EmptyInputStream; import org.apache.hc.core5.http.io.SocketConfig; import org.apache.hc.core5.http.io.entity.ByteArrayEntity; +import org.apache.hc.core5.http.io.entity.EmptyInputStream; import org.apache.hc.core5.http.io.entity.InputStreamEntity; -import org.apache.hc.core5.http.protocol.BasicHttpContext; import org.apache.hc.core5.http.protocol.HttpContext; +import org.apache.hc.core5.http.protocol.HttpCoreContext; import org.apache.hc.core5.net.URIAuthority; import org.apache.hc.core5.util.TimeValue; import org.apache.hc.core5.util.Timeout; @@ -38,7 +41,6 @@ import javax.net.ssl.SSLContext; import java.io.IOException; import java.io.InputStream; -import java.net.InetSocketAddress; import java.net.Socket; import java.net.URI; import java.time.Duration; @@ -61,7 +63,13 @@ protected ApacheDockerHttpClientImpl( Duration connectionTimeout, Duration responseTimeout ) { - Registry socketFactoryRegistry = createConnectionSocketFactoryRegistry(sslConfig, dockerHost); + SSLContext sslContext; + try { + sslContext = sslConfig != null ? sslConfig.getSSLContext() : null; + } catch (Exception e) { + throw new RuntimeException(e); + } + HttpClientConnectionOperator connectionOperator = createConnectionOperator(dockerHost, sslContext); switch (dockerHost.getScheme()) { case "unix": @@ -75,7 +83,7 @@ protected ApacheDockerHttpClientImpl( ? rawPath.substring(0, rawPath.length() - 1) : rawPath; host = new HttpHost( - socketFactoryRegistry.lookup("https") != null ? "https" : "http", + sslContext != null ? "https" : "http", dockerHost.getHost(), dockerHost.getPort() ); @@ -85,7 +93,10 @@ protected ApacheDockerHttpClientImpl( } PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager( - socketFactoryRegistry, + connectionOperator, + null, + null, + null, new ManagedHttpClientConnectionFactory( null, null, @@ -109,77 +120,49 @@ protected ApacheDockerHttpClientImpl( .setSoTimeout(Timeout.ZERO_MILLISECONDS) .build() ); - connectionManager.setValidateAfterInactivity(TimeValue.NEG_ONE_SECOND); connectionManager.setMaxTotal(maxConnections); connectionManager.setDefaultMaxPerRoute(maxConnections); - RequestConfig.Builder defaultRequest = RequestConfig.custom(); - if (connectionTimeout != null) { - defaultRequest.setConnectTimeout(connectionTimeout.toNanos(), TimeUnit.NANOSECONDS); - } - if (responseTimeout != null) { - defaultRequest.setResponseTimeout(responseTimeout.toNanos(), TimeUnit.NANOSECONDS); - } + connectionManager.setDefaultConnectionConfig(ConnectionConfig.custom() + .setValidateAfterInactivity(TimeValue.NEG_ONE_SECOND) + .setConnectTimeout(connectionTimeout != null ? Timeout.of(connectionTimeout.toNanos(), TimeUnit.NANOSECONDS) : null) + .build()); httpClient = HttpClients.custom() .setRequestExecutor(new HijackingHttpRequestExecutor(null)) .setConnectionManager(connectionManager) - .setDefaultRequestConfig(defaultRequest.build()) + .setDefaultRequestConfig(RequestConfig.custom() + .setResponseTimeout(responseTimeout != null ? Timeout.of(responseTimeout.toNanos(), TimeUnit.NANOSECONDS) : null) + .build()) .disableConnectionState() .build(); } - private Registry createConnectionSocketFactoryRegistry( - SSLConfig sslConfig, - URI dockerHost + private HttpClientConnectionOperator createConnectionOperator( + URI dockerHost, + SSLContext sslContext ) { - RegistryBuilder socketFactoryRegistryBuilder = RegistryBuilder.create(); - - if (sslConfig != null) { - try { - SSLContext sslContext = sslConfig.getSSLContext(); - if (sslContext != null) { - socketFactoryRegistryBuilder.register("https", new SSLConnectionSocketFactory(sslContext)); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - return socketFactoryRegistryBuilder - .register("tcp", PlainConnectionSocketFactory.INSTANCE) - .register("http", PlainConnectionSocketFactory.INSTANCE) - .register("unix", new ConnectionSocketFactory() { - @Override - public Socket createSocket(HttpContext context) throws IOException { - return UnixSocket.get(dockerHost.getPath()); + String dockerHostScheme = dockerHost.getScheme(); + String dockerHostPath = dockerHost.getPath(); + TlsSocketStrategy tlsSocketStrategy = sslContext != null ? + new DefaultClientTlsStrategy(sslContext) : DefaultClientTlsStrategy.createSystemDefault(); + return new DefaultHttpClientConnectionOperator( + socksProxy -> { + if ("unix".equalsIgnoreCase(dockerHostScheme)) { + return UnixSocket.get(dockerHostPath); + } else if ("npipe".equalsIgnoreCase(dockerHostScheme)) { + return new NamedPipeSocket(dockerHostPath); + } else { + return socksProxy == null ? new Socket() : new Socket(socksProxy); } - - @Override - public Socket connectSocket(TimeValue timeValue, Socket socket, HttpHost httpHost, InetSocketAddress inetSocketAddress, - InetSocketAddress inetSocketAddress1, HttpContext httpContext) throws IOException { - return PlainConnectionSocketFactory.INSTANCE.connectSocket(timeValue, socket, httpHost, inetSocketAddress, - inetSocketAddress1, httpContext); - } - }) - .register("npipe", new ConnectionSocketFactory() { - @Override - public Socket createSocket(HttpContext context) { - return new NamedPipeSocket(dockerHost.getPath()); - } - - @Override - public Socket connectSocket(TimeValue timeValue, Socket socket, HttpHost httpHost, InetSocketAddress inetSocketAddress, - InetSocketAddress inetSocketAddress1, HttpContext httpContext) throws IOException { - return PlainConnectionSocketFactory.INSTANCE.connectSocket(timeValue, socket, httpHost, inetSocketAddress, - inetSocketAddress1, httpContext); - } - }) - .build(); + }, + DefaultSchemePortResolver.INSTANCE, + SystemDefaultDnsResolver.INSTANCE, + name -> "https".equalsIgnoreCase(name) ? tlsSocketStrategy : null); } @Override public Response execute(Request request) { - HttpContext context = new BasicHttpContext(); + HttpContext context = new HttpCoreContext(); HttpUriRequestBase httpUriRequest = new HttpUriRequestBase(request.method(), URI.create(pathPrefix + request.path())); httpUriRequest.setScheme(host.getSchemeName()); httpUriRequest.setAuthority(new URIAuthority(host.getHostName(), host.getPort())); @@ -203,7 +186,7 @@ public Response execute(Request request) { } try { - CloseableHttpResponse response = httpClient.execute(host, httpUriRequest, context); + ClassicHttpResponse response = httpClient.executeOpen(host, httpUriRequest, context); return new ApacheResponse(httpUriRequest, response); } catch (IOException e) { @@ -222,9 +205,9 @@ static class ApacheResponse implements Response { private final HttpUriRequestBase request; - private final CloseableHttpResponse response; + private final ClassicHttpResponse response; - ApacheResponse(HttpUriRequestBase httpUriRequest, CloseableHttpResponse response) { + ApacheResponse(HttpUriRequestBase httpUriRequest, ClassicHttpResponse response) { this.request = httpUriRequest; this.response = response; } diff --git a/docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5/HijackingHttpRequestExecutor.java b/docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5/HijackingHttpRequestExecutor.java index 59888a5dd..df8fbd059 100644 --- a/docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5/HijackingHttpRequestExecutor.java +++ b/docker-java-transport-httpclient5/src/main/java/com/github/dockerjava/httpclient5/HijackingHttpRequestExecutor.java @@ -44,7 +44,7 @@ public ClassicHttpResponse execute( InputStream hijackedInput = (InputStream) context.getAttribute(HIJACKED_INPUT_ATTRIBUTE); if (hijackedInput != null) { - return executeHijacked(request, conn, context, hijackedInput); + return executeHijacked(request, conn, (HttpCoreContext) context, hijackedInput); } return super.execute(request, conn, informationCallback, context); @@ -53,12 +53,12 @@ public ClassicHttpResponse execute( private ClassicHttpResponse executeHijacked( ClassicHttpRequest request, HttpClientConnection conn, - HttpContext context, + HttpCoreContext context, InputStream hijackedInput ) throws HttpException, IOException { try { - context.setAttribute(HttpCoreContext.SSL_SESSION, conn.getSSLSession()); - context.setAttribute(HttpCoreContext.CONNECTION_ENDPOINT, conn.getEndpointDetails()); + context.setSSLSession(conn.getSSLSession()); + context.setEndpointDetails(conn.getEndpointDetails()); final ProtocolVersion transportVersion = request.getVersion(); if (transportVersion != null) { context.setProtocolVersion(transportVersion); diff --git a/docker-java-transport-okhttp/pom.xml b/docker-java-transport-okhttp/pom.xml index df14ad077..3bac0cead 100644 --- a/docker-java-transport-okhttp/pom.xml +++ b/docker-java-transport-okhttp/pom.xml @@ -35,7 +35,7 @@ net.java.dev.jna jna - 5.13.0 + 5.17.0 diff --git a/docker-java-transport-tck/pom.xml b/docker-java-transport-tck/pom.xml index 2e4bd79ce..4d6dd5738 100644 --- a/docker-java-transport-tck/pom.xml +++ b/docker-java-transport-tck/pom.xml @@ -34,7 +34,7 @@ org.assertj assertj-core - 3.24.2 + 3.27.3 diff --git a/docker-java-transport/pom.xml b/docker-java-transport/pom.xml index 2ca377dd6..96f1f850a 100644 --- a/docker-java-transport/pom.xml +++ b/docker-java-transport/pom.xml @@ -30,14 +30,14 @@ org.immutables value - 2.8.2 + 2.10.1 provided net.java.dev.jna jna - 5.13.0 + 5.17.0 provided diff --git a/docker-java/pom.xml b/docker-java/pom.xml index e3c3690f1..e00c974d3 100644 --- a/docker-java/pom.xml +++ b/docker-java/pom.xml @@ -118,30 +118,30 @@ org.awaitility awaitility - 4.0.1 + 4.3.0 test com.fasterxml.jackson.core jackson-databind - - 2.8.8 + + 2.18.3 test com.fasterxml.jackson.core jackson-annotations - - 2.8.8 + + 2.18.3 test org.projectlombok lombok - 1.18.30 + 1.18.38 provided diff --git a/docker-java/src/test/java/com/github/dockerjava/api/command/CommandJSONSamples.java b/docker-java/src/test/java/com/github/dockerjava/api/command/CommandJSONSamples.java index 0cf5141d4..23ef4b7f2 100644 --- a/docker-java/src/test/java/com/github/dockerjava/api/command/CommandJSONSamples.java +++ b/docker-java/src/test/java/com/github/dockerjava/api/command/CommandJSONSamples.java @@ -28,7 +28,9 @@ public enum CommandJSONSamples implements JSONResourceRef { inspectContainerResponse_full_1_21, inspectContainerResponse_full_1_26a, inspectContainerResponse_full_1_26b, - inspectContainerResponse_empty; + inspectContainerResponse_empty, + updateContainerResponse_empty, + updateContainerResponse_warnings; @Override public String getFileName() { diff --git a/docker-java/src/test/java/com/github/dockerjava/api/command/UpdateContainerResponseTest.java b/docker-java/src/test/java/com/github/dockerjava/api/command/UpdateContainerResponseTest.java new file mode 100644 index 000000000..300a5c324 --- /dev/null +++ b/docker-java/src/test/java/com/github/dockerjava/api/command/UpdateContainerResponseTest.java @@ -0,0 +1,33 @@ +package com.github.dockerjava.api.command; + +import com.github.dockerjava.api.model.UpdateContainerResponse; +import org.junit.Test; + +import java.io.IOException; +import java.util.List; + +import static com.github.dockerjava.test.serdes.JSONTestHelper.testRoundTrip; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +public class UpdateContainerResponseTest { + @Test + public void roundTrip_empty() throws IOException { + UpdateContainerResponse response = testRoundTrip(CommandJSONSamples.updateContainerResponse_empty, UpdateContainerResponse.class); + assertNull(response.getWarnings()); + } + + @Test + public void roundTrip_warnings() throws IOException { + UpdateContainerResponse response = testRoundTrip(CommandJSONSamples.updateContainerResponse_warnings, + UpdateContainerResponse.class); + + List warnings = response.getWarnings(); + assertNotNull(warnings); + assertEquals(1, warnings.size()); + + final String warning = warnings.get(0); + assertEquals("Published ports are discarded when using host network mode", warning); + } +} diff --git a/docker-java/src/test/java/com/github/dockerjava/cmd/InspectContainerCmdIT.java b/docker-java/src/test/java/com/github/dockerjava/cmd/InspectContainerCmdIT.java index 54d900db8..cc1468f7f 100644 --- a/docker-java/src/test/java/com/github/dockerjava/cmd/InspectContainerCmdIT.java +++ b/docker-java/src/test/java/com/github/dockerjava/cmd/InspectContainerCmdIT.java @@ -100,9 +100,9 @@ public void inspectContainerWithSize() throws DockerException { // TODO check swarm if (isNotSwarm(dockerRule.getClient())) { assertNotNull(containerInfo.getSizeRootFs()); - assertTrue(containerInfo.getSizeRootFs().intValue() > 0); + assertTrue(containerInfo.getSizeRootFs() > 0L); assertNotNull(containerInfo.getSizeRw()); - assertTrue(containerInfo.getSizeRw().intValue() == 0); + assertEquals(0L, containerInfo.getSizeRw().longValue()); } } diff --git a/docker-java/src/test/java/com/github/dockerjava/cmd/UpdateContainerCmdIT.java b/docker-java/src/test/java/com/github/dockerjava/cmd/UpdateContainerCmdIT.java index e5bb55499..e1e637809 100644 --- a/docker-java/src/test/java/com/github/dockerjava/cmd/UpdateContainerCmdIT.java +++ b/docker-java/src/test/java/com/github/dockerjava/cmd/UpdateContainerCmdIT.java @@ -48,8 +48,8 @@ public void updateContainer() throws DockerException { dockerRule.getClient().updateContainerCmd(containerId) .withBlkioWeight(300) .withCpuShares(512) - .withCpuPeriod(100000) - .withCpuQuota(50000) + .withCpuPeriod(100000L) + .withCpuQuota(50000L) // .withCpusetCpus("0") // depends on env .withCpusetMems("0") // .withMemory(209715200L + 2L) diff --git a/docker-java/src/test/resources/com/github/dockerjava/api/command/updateContainerResponse_empty.json b/docker-java/src/test/resources/com/github/dockerjava/api/command/updateContainerResponse_empty.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/docker-java/src/test/resources/com/github/dockerjava/api/command/updateContainerResponse_empty.json @@ -0,0 +1 @@ +{} diff --git a/docker-java/src/test/resources/com/github/dockerjava/api/command/updateContainerResponse_warnings.json b/docker-java/src/test/resources/com/github/dockerjava/api/command/updateContainerResponse_warnings.json new file mode 100644 index 000000000..edeaedc7a --- /dev/null +++ b/docker-java/src/test/resources/com/github/dockerjava/api/command/updateContainerResponse_warnings.json @@ -0,0 +1,5 @@ +{ + "Warnings": [ + "Published ports are discarded when using host network mode" + ] +} diff --git a/pom.xml b/pom.xml index f58a3d448..603b1ac48 100644 --- a/pom.xml +++ b/pom.xml @@ -58,21 +58,21 @@ 1.8 2.30.1 - 2.10.3 - 2.10.3 + 2.18.3 + 2.18.3 4.5.12 - 1.21 - 2.13.0 - 3.12.0 + 1.27.1 + 2.18.0 + 3.17.0 1.7.30 - 1.76 - 2.6.1 - 19.0 + 1.80 + 2.10.1 + 33.4.6-jre 1.2.3 - 4.1.46.Final + 4.1.119.Final 2.2 1.8 2.3.3 @@ -244,7 +244,7 @@ com.github.siom79.japicmp japicmp-maven-plugin - 0.18.3 + 0.23.1