Prevent crash

pull/204/head
M66B 3 years ago
parent e6322b44f7
commit c9836f8006

@ -503,19 +503,28 @@ public class EmailService implements AutoCloseable {
boolean has4 = false; boolean has4 = false;
boolean has6 = false; boolean has6 = false;
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); try {
while (interfaces != null && interfaces.hasMoreElements()) { Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
NetworkInterface ni = interfaces.nextElement(); while (interfaces != null && interfaces.hasMoreElements()) {
for (InterfaceAddress iaddr : ni.getInterfaceAddresses()) { NetworkInterface ni = interfaces.nextElement();
InetAddress addr = iaddr.getAddress(); for (InterfaceAddress iaddr : ni.getInterfaceAddresses()) {
boolean local = (addr.isLoopbackAddress() || addr.isLinkLocalAddress()); InetAddress addr = iaddr.getAddress();
EntityLog.log(context, "Interface=" + ni + " addr=" + addr + " local=" + local); boolean local = (addr.isLoopbackAddress() || addr.isLinkLocalAddress());
if (!local) EntityLog.log(context, "Interface=" + ni + " addr=" + addr + " local=" + local);
if (addr instanceof Inet4Address) if (!local)
has4 = true; if (addr instanceof Inet4Address)
else if (addr instanceof Inet6Address) has4 = true;
has6 = true; else if (addr instanceof Inet6Address)
has6 = true;
}
} }
} catch (Throwable ex2) {
Log.e(ex2);
/*
java.lang.NullPointerException: Attempt to read from field 'java.util.List java.net.NetworkInterface.childs' on a null object reference
at java.net.NetworkInterface.getAll(NetworkInterface.java:498)
at java.net.NetworkInterface.getNetworkInterfaces(NetworkInterface.java:398)
*/
} }
EntityLog.log(context, "Address main=" + main + EntityLog.log(context, "Address main=" + main +

Loading…
Cancel
Save