locked
InetAddress.getAllByName() failing on one computer

    Pregunta

  • Hi;

     

    This is happening on just one computer - one of our customers. For the program: 

    Code Snippet

      System.out.println("starting test...");

      System.out.println("calling getLocalHost()");
      InetAddress addr = InetAddress.getLocalHost();
      System.out.println("addr = " + addr);

      System.out.println("calling getHostName()");
      String name = addr.getHostName();
      System.out.println("host name = " + name);

      System.out.println("calling getAllByName()");
      InetAddress[] allIP = InetAddress.getAllByName(name);
      System.out.println("getAllByName = " + allIP);

      System.out.println("done");

     

    We get the output:

    Code Snippet

    starting test...

    calling getLocalHost()

    addr = 12SANW-100140.us01/172.16.5.214

    calling getHostName()

    host name = 12SANW-100140.us01

    calling getAllByName()

    java.net.UnknownHostException

        at java.net.InetAddress.getAllByName(String hostname)

        at JSharpPart.Class1.test()

        at GetHostTest.Program.Main(String[] args)

     

    The J# code is called from a C# console application. Any idea why this fails? It should be impossible for it to fail I would think.

     

    ??? - thanks - dave

    miércoles, 25 de abril de 2007 19:21

Respuestas

  • Found the problem - if the first character of the machine name is a digit then J# assumes it's an IP address, not a name and then throws an exception when it cannot parse 1dave as an IP address.

     

    Please consider fixing this as it's a hard to resolve bug.

     

    thanks - dave

    viernes, 27 de abril de 2007 21:10