Skip to content

Commit ff5a0c8

Browse files
authored
Bugfix: Treating npe at networks mapping when network hasn't a gateway ip mageddo#580 (mageddo#592)
* treating npe at network without gateway ip mapping * release notes * [Gradle Release Plugin] - new version commit: '3.30.5-snapshot'.
1 parent 97f2824 commit ff5a0c8

File tree

6 files changed

+62
-1
lines changed

6 files changed

+62
-1
lines changed

RELEASE-NOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 3.30.5
2+
* Bugfix: Treating npe at networks mapping when network hasn't a gateway ip #580.
3+
14
## 3.30.4
25
* Adjusting binary generation to compatibility. #586
36

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=3.30.4-snapshot
1+
version=3.30.5-snapshot

src/main/java/com/mageddo/dnsproxyserver/solver/docker/dataprovider/mapper/NetworkMapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ static IP findGatewayIp(com.github.dockerjava.api.model.Network network, IP.Vers
4646
.getConfig()
4747
.stream()
4848
.map(com.github.dockerjava.api.model.Network.Ipam.Config::getGateway)
49+
.filter(Objects::nonNull)
4950
.map(NetworkMapper::extractIpIfNeedledWhenGatewayIsSubnet)
5051
.map(IP::of)
5152
.filter(it -> it.version() == version)

src/test/java/com/mageddo/dnsproxyserver/solver/docker/dataprovider/mapper/NetworkMapperTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,18 @@ void mustExtractIpWhenASubnetIsSetAtIpv6TheGatewayIp(){
9595
assertEquals("[172.19.0.1, fddb:21e4:36d4:2:0:0:0:1]", network.getGateways().toString());
9696
}
9797

98+
@Test
99+
void mustMapFromCustomNetworkWithoutGateway(){
100+
101+
// arrange
102+
final var dockerNetwork = NetworkTemplates.buildCustomIpv4NetworkWithoutGateway();
103+
104+
// act
105+
final var network = NetworkMapper.of(dockerNetwork);
106+
107+
// assert
108+
assertNotNull(network);
109+
assertFalse(network.hasAnyGateway());
110+
}
111+
98112
}

src/test/java/testing/templates/docker/NetworkTemplates.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,8 @@ public static Network buildHostNetworkWithNoIpam() {
4747
public static Network buildBridgeWithSubnetIPAtGatewayProp() {
4848
return JsonUtils.readValue(readString("/templates/docker/network/004.json"), Network.class);
4949
}
50+
51+
public static Network buildCustomIpv4NetworkWithoutGateway() {
52+
return JsonUtils.readValue(readString("/templates/docker/network/005.json"), Network.class);
53+
}
5054
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"Name": "tmp_my_network",
3+
"Id": "4832d0e4bb48513ee3fde20aaecfaf6b8ac83476d4365f82fae4001517b20cce",
4+
"Created": "2024-10-31T14:47:27.608173734-03:00",
5+
"Scope": "local",
6+
"Driver": "bridge",
7+
"EnableIPv6": false,
8+
"IPAM": {
9+
"Driver": "default",
10+
"Options": null,
11+
"Config": [
12+
{
13+
"Subnet": "171.18.0.0/16"
14+
}
15+
]
16+
},
17+
"Internal": false,
18+
"Attachable": false,
19+
"Ingress": false,
20+
"ConfigFrom": {
21+
"Network": ""
22+
},
23+
"ConfigOnly": false,
24+
"Containers": {
25+
"2343a2ab9f8f1898674f349e21316593f31fce539b2b804d7e97cc16d3bf8a3b": {
26+
"Name": "tmp-dns-proxy-1",
27+
"EndpointID": "a809c879ba3dc31d0c387f47eb4f817745534bcf4cf7385a9916832452db4bae",
28+
"MacAddress": "02:42:ab:12:00:0a",
29+
"IPv4Address": "171.18.0.10/16",
30+
"IPv6Address": ""
31+
}
32+
},
33+
"Options": {},
34+
"Labels": {
35+
"com.docker.compose.network": "my_network",
36+
"com.docker.compose.project": "tmp",
37+
"com.docker.compose.version": "2.26.1"
38+
}
39+
}

0 commit comments

Comments
 (0)