Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-1404

Protect against ArrayIndexOutOfBoundsException when calling InetAddress.getLocalHost

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Done
    • Major
    • 3.0.2, 3.1
    • None
    • None

    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

          Activity

            People

              rhn-engineering-bban Bela Ban
              rh-ee-galder Galder ZamarreƱo
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: