Skip to content

Commit 8232049

Browse files
committed
Merge branch 'master' into master-vuminhkh
* master: Fix potential NullpointerExceptions Fix changelog Renamed networStats to network Remove "Stats" from "networks" field in statistics Improve JavaDoc and include @checkfornull Deprecate "network" and enable "networks" stats (remote Docker API 1.21)
2 parents 0f65469 + 570fa09 commit 8232049

4 files changed

Lines changed: 42 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
Change Log
22
===
3-
Latest SNAPSHOT (3.0.0-SNAPSHOT)
3+
4+
3.0.0-SNAPSHOT
45
---
56
Notes
67

78
* The upcoming release will contain multiple API breaking changes therefore the major version switch
89

910
All changes
1011

12+
* [#362] (https://github.com/docker-java/docker-java/pull/362) Deprecate "network" and enable "networks" stats (remote Docker API 1.21)
1113
* [#359] (https://github.com/docker-java/docker-java/pull/359) Fix performance issue of build command by adding bulk-read variant of InputStream.read()
1214
* [#357] (https://github.com/docker-java/docker-java/pull/357) Wait container command needs possibility to abort operation
1315
* [#313] (https://github.com/docker-java/docker-java/pull/313) Refactor primitive type fields to be of object type in JSON objects
1416

17+
2.1.3-SNAPSHOT
18+
---
19+
* [#362] (https://github.com/docker-java/docker-java/pull/362) Deprecate "network" and enable "networks" stats (remote Docker API 1.21)
20+
1521
v2.1.2
1622
---
1723
* [#350] (https://github.com/docker-java/docker-java/pull/350) Remove ServiceLoader logic

src/main/java/com/github/dockerjava/api/command/InspectContainerResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ public String getResolvConfPath() {
126126

127127
@JsonIgnore
128128
public VolumeBind[] getVolumes() {
129-
return volumes.getBinds();
129+
return volumes == null ? null : volumes.getBinds();
130130
}
131131

132132
@JsonIgnore
133133
public VolumeRW[] getVolumesRW() {
134-
return volumesRW.getVolumesRW();
134+
return volumesRW == null ? null : volumesRW.getVolumesRW();
135135
}
136136

137137
public String getHostnamePath() {

src/main/java/com/github/dockerjava/api/model/Statistics.java

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import java.util.Map;
44

5+
import javax.annotation.CheckForNull;
6+
57
import org.apache.commons.lang.builder.ToStringBuilder;
68

79
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@@ -19,8 +21,19 @@ public class Statistics {
1921
@JsonProperty("read")
2022
private String read;
2123

24+
/**
25+
* @since Docker Remote API 1.21
26+
*/
27+
@CheckForNull
28+
@JsonProperty("networks")
29+
private Map<String, Object> networks;
30+
31+
/**
32+
* @deprecated as of Docker Remote API 1.21, replaced by {@link #networks}
33+
*/
34+
@Deprecated
2235
@JsonProperty("network")
23-
private Map<String, Object> networkStats;
36+
private Map<String, Object> network;
2437

2538
@JsonProperty("memory_stats")
2639
private Map<String, Object> memoryStats;
@@ -31,8 +44,20 @@ public class Statistics {
3144
@JsonProperty("cpu_stats")
3245
private Map<String, Object> cpuStats;
3346

34-
public Map<String, Object> getNetworkStats() {
35-
return networkStats;
47+
/**
48+
* @since Docker Remote API 1.21
49+
*/
50+
@CheckForNull
51+
public Map<String, Object> getNetworks() {
52+
return networks;
53+
}
54+
55+
/**
56+
* @deprecated as of Docker Remote API 1.21, replaced by {@link #getNetworks()}
57+
*/
58+
@Deprecated
59+
public Map<String, Object> getNetwork() {
60+
return network;
3661
}
3762

3863
public Map<String, Object> getCpuStats() {

src/test/java/com/github/dockerjava/client/AbstractDockerClientTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,13 @@ public static Boolean available(int port) {
178178
*/
179179
public static void assertContainerHasVolumes(InspectContainerResponse inspectContainerResponse,
180180
Volume... expectedVolumes) {
181-
VolumeBind[] volumeBinds = inspectContainerResponse.getVolumes();
182-
LOG.info("Inspect .Volumes = [{}]", Joiner.on(", ").join(volumeBinds));
183181

184182
List<Volume> volumes = new ArrayList<Volume>();
185-
for (VolumeBind bind : volumeBinds) {
186-
volumes.add(new Volume(bind.getContainerPath()));
183+
VolumeBind[] volumeBinds = inspectContainerResponse.getVolumes();
184+
if (volumeBinds != null) {
185+
for (VolumeBind bind : volumeBinds) {
186+
volumes.add(new Volume(bind.getContainerPath()));
187+
}
187188
}
188189
assertThat(volumes, contains(expectedVolumes));
189190
}

0 commit comments

Comments
 (0)