Skip to content

Commit 42fabc0

Browse files
committed
<fix>[network]: Fix potential npe in DhcpExtension
Resolves: ZSTAC-82118 Change-Id: I6eebb6113683c708656dc531059ab5c665ef56a3
1 parent 765d1de commit 42fabc0

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

network/src/main/java/org/zstack/network/service/DhcpExtension.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,13 @@ private DhcpStruct getDhcpStruct(VmInstanceInventory vm, List<VmInstanceSpec.Hos
155155
String hostname = CollectionUtils.find(hostNames, new Function<String, HostName>() {
156156
@Override
157157
public String call(HostName arg) {
158-
return arg.getL3NetworkUuid().equals(l3.getUuid()) ? arg.getHostname() : null;
158+
if (arg == null || l3 == null) {
159+
return null;
160+
}
161+
if (Objects.equals(arg.getL3NetworkUuid(), l3.getUuid())) {
162+
return arg.getHostname();
163+
}
164+
return null;
159165
}
160166
});
161167
if (hostname != null && l3.getDnsDomain() != null) {

0 commit comments

Comments
 (0)