diff --git a/common/src/main/java/io/netty/util/NetUtil.java b/common/src/main/java/io/netty/util/NetUtil.java index d4f2354f10..ed48665f42 100644 --- a/common/src/main/java/io/netty/util/NetUtil.java +++ b/common/src/main/java/io/netty/util/NetUtil.java @@ -154,11 +154,14 @@ public final class NetUtil { // Retrieve the list of available network interfaces. List ifaces = new ArrayList(); try { - for (Enumeration i = NetworkInterface.getNetworkInterfaces(); i.hasMoreElements();) { - NetworkInterface iface = i.nextElement(); - // Use the interface with proper INET addresses only. - if (SocketUtils.addressesFromNetworkInterface(iface).hasMoreElements()) { - ifaces.add(iface); + Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); + if (interfaces != null) { + while (interfaces.hasMoreElements()) { + NetworkInterface iface = interfaces.nextElement(); + // Use the interface with proper INET addresses only. + if (SocketUtils.addressesFromNetworkInterface(iface).hasMoreElements()) { + ifaces.add(iface); + } } } } catch (SocketException e) {