Description
All calls to InetAddress.getLocalHost should be replaced with this code in order to avoid a rather annoying issue with OSX 10.7 and (at least) java version "1.6.0_26":
InetAddress addr; try { addr = InetAddress.getLocalHost(); System.out.println("With localhost access: " + addr); } catch (ArrayIndexOutOfBoundsException e) { addr = InetAddress.getByName(null); System.out.println("With reverse lookup: " + addr); }
The exception is:
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 at java.net.InetAddress.getLocalHost(InetAddress.java:1356)
For more info, see http://stackoverflow.com/questions/7892609/inetaddress-getlocalhost-resolution-on-osx-lion-when-offline
Attachments
Issue Links
- relates to
-
AS7-3223 Protect against ArrayIndexOutOfBoundsException when calling InetAddress.getLocalHost
- Resolved