Addresses: Catch a rare (Windows only? IPv6 only?) error

when enumerating network interfaces
This commit is contained in:
zzz
2015-12-13 16:40:42 +00:00
parent 97ae1e5034
commit db86850d15
2 changed files with 17 additions and 1 deletions

View File

@ -131,7 +131,15 @@ public abstract class Addresses {
} }
} }
} }
} catch (SocketException e) {} } catch (SocketException e) {
} catch (java.lang.Error e) {
// Windows, possibly when IPv6 only...
// https://bugs.openjdk.java.net/browse/JDK-8046500
// java.lang.Error: IP Helper Library GetIfTable function failed
// at java.net.NetworkInterface.getAll(Native Method)
// at java.net.NetworkInterface.getNetworkInterfaces(Unknown Source)
// at net.i2p.util.Addresses.getAddresses ...
}
if (includeLoopbackAndWildcard) { if (includeLoopbackAndWildcard) {
if (haveIPv4) if (haveIPv4)

View File

@ -40,6 +40,14 @@ abstract class MTU {
ifcs = NetworkInterface.getNetworkInterfaces(); ifcs = NetworkInterface.getNetworkInterfaces();
} catch (SocketException se) { } catch (SocketException se) {
return 0; return 0;
} catch (java.lang.Error e) {
// Windows, possibly when IPv6 only...
// https://bugs.openjdk.java.net/browse/JDK-8046500
// java.lang.Error: IP Helper Library GetIfTable function failed
// at java.net.NetworkInterface.getAll(Native Method)
// at java.net.NetworkInterface.getNetworkInterfaces(Unknown Source)
// at net.i2p.util.Addresses.getAddresses ...
return 0;
} }
if (ifcs != null) { if (ifcs != null) {
while (ifcs.hasMoreElements()) { while (ifcs.hasMoreElements()) {