Catch NPE from NetworkInterface.getByInetAddress().

This commit is contained in:
akwizgran
2023-08-24 15:53:00 +01:00
parent b68d24dca5
commit cc47c8522a

View File

@@ -201,6 +201,7 @@ class AndroidLanTcpPlugin extends LanTcpPlugin {
@Nullable @Nullable
private InetAddress getIpv6AddressForInterface(InetAddress ipv4) { private InetAddress getIpv6AddressForInterface(InetAddress ipv4) {
try { try {
// We may get an NPE from getByInetAddress() on Android 11
NetworkInterface iface = NetworkInterface.getByInetAddress(ipv4); NetworkInterface iface = NetworkInterface.getByInetAddress(ipv4);
if (iface == null) return null; if (iface == null) return null;
for (InetAddress addr : list(iface.getInetAddresses())) { for (InetAddress addr : list(iface.getInetAddresses())) {
@@ -208,7 +209,7 @@ class AndroidLanTcpPlugin extends LanTcpPlugin {
} }
// No suitable address // No suitable address
return null; return null;
} catch (SocketException e) { } catch (SocketException | NullPointerException e) {
logException(LOG, WARNING, e); logException(LOG, WARNING, e);
return null; return null;
} }