[jboss-jira] [JBoss JIRA] (JGRP-1404) Protect against ArrayIndexOutOfBoundsException when calling InetAddress.getLocalHost

Galder Zamarreño (Created) (JIRA) jira-events at lists.jboss.org
Fri Dec 23 06:08:09 EST 2011


Protect against ArrayIndexOutOfBoundsException when calling InetAddress.getLocalHost
------------------------------------------------------------------------------------

                 Key: JGRP-1404
                 URL: https://issues.jboss.org/browse/JGRP-1404
             Project: JGroups
          Issue Type: Enhancement
            Reporter: Galder Zamarreño
            Assignee: Bela Ban
             Fix For: 2.12.3, 3.0.2


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":

{code}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);
}{code}

The exception is:

{code}Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
    at java.net.InetAddress.getLocalHost(InetAddress.java:1356){code}

For more info, see http://stackoverflow.com/questions/7892609/inetaddress-getlocalhost-resolution-on-osx-lion-when-offline

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the jboss-jira mailing list