mirror of https://github.com/apache/activemq.git
Guard against null return value from
java.net.NetworkInterface.getNetworkInterfaces().
This commit is contained in:
parent
fa8b4c5215
commit
d292372902
|
@ -345,20 +345,22 @@ public class MulticastDiscoveryAgent implements DiscoveryAgent, Runnable {
|
||||||
private NetworkInterface findNetworkInterface() throws SocketException {
|
private NetworkInterface findNetworkInterface() throws SocketException {
|
||||||
Enumeration<NetworkInterface> ifcs = NetworkInterface.getNetworkInterfaces();
|
Enumeration<NetworkInterface> ifcs = NetworkInterface.getNetworkInterfaces();
|
||||||
List<NetworkInterface> possibles = new ArrayList<NetworkInterface>();
|
List<NetworkInterface> possibles = new ArrayList<NetworkInterface>();
|
||||||
while (ifcs.hasMoreElements()) {
|
if (ifcs != null) {
|
||||||
NetworkInterface ni = ifcs.nextElement();
|
while (ifcs.hasMoreElements()) {
|
||||||
try {
|
NetworkInterface ni = ifcs.nextElement();
|
||||||
if (ni.supportsMulticast()
|
try {
|
||||||
&& ni.isUp()) {
|
if (ni.supportsMulticast()
|
||||||
for (InterfaceAddress ia : ni.getInterfaceAddresses()) {
|
&& ni.isUp()) {
|
||||||
if (ia != null && ia.getAddress() instanceof java.net.Inet4Address
|
for (InterfaceAddress ia : ni.getInterfaceAddresses()) {
|
||||||
&& !ia.getAddress().isLoopbackAddress()
|
if (ia != null && ia.getAddress() instanceof java.net.Inet4Address
|
||||||
&& (ni.getDisplayName()==null || !ni.getDisplayName().startsWith("vnic"))) {
|
&& !ia.getAddress().isLoopbackAddress()
|
||||||
possibles.add(ni);
|
&& (ni.getDisplayName()==null || !ni.getDisplayName().startsWith("vnic"))) {
|
||||||
|
possibles.add(ni);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (SocketException ignored) {}
|
||||||
} catch (SocketException ignored) {}
|
}
|
||||||
}
|
}
|
||||||
return possibles.isEmpty() ? null : possibles.get(possibles.size() - 1);
|
return possibles.isEmpty() ? null : possibles.get(possibles.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue