FULL PRODUCT VERSION :
openjdk version "1.7.0-alpha"
OpenJDK Runtime Environment (build 1.7.0-alpha-106)
OpenJDK 64-Bit Server VM (build 19.0-b05, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Various Linux systems e.g. Ubuntu 10.04 or Gentoo Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
A nameserver which is accessible via IPv6 is required to reproduce this bug.
A DESCRIPTION OF THE PROBLEM :
Linux systems don't require and moreover don't allow to use IPv6 literal host names within delimiting brackets for nameservers in /etc/resolv.conf. So IPv6 entries have the form:
nameserver 2001:0db8:85a3:08d3:1319:8a2e:0370:7344
When trying to use a nameserver via IPv6 a NumberFormatException is thrown.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Setup a Linux system with IPv6 and a nameserver via IPv6.
2. Compile the provided NSLookup Class
3. Run the application e.g. via java NSLookup A openjdk.org
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected output: openjdk.org: 192.9.170.173
ACTUAL -
A NumberFormatException is thrown.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NumberFormatException: For input string: "0db8:85a3:08d3:1319:8a2e:0370:7344"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:481)
at java.lang.Integer.parseInt(Integer.java:514)
at com.sun.jndi.dns.DnsClient.<init>(DnsClient.java:122)
at com.sun.jndi.dns.Resolver.<init>(Resolver.java:61)
at com.sun.jndi.dns.DnsContext.getResolver(DnsContext.java:570)
at com.sun.jndi.dns.DnsContext.c_getAttributes(DnsContext.java:430)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_getAttributes(ComponentDirContext.java:231)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:139)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:127)
at javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:140)
at NSLookup.main(NSLookup.java:14)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.naming.directory.*;
import java.util.Hashtable;
public class NSLookup {
public static void main(String[] args) {
if (args.length != 2) {
System.out.println("We need 2 arguments: <TYPE> <DOMAIN>");
return;
}
try {
Hashtable<String,String> env = new Hashtable<String,String>();
env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
DirContext context = new InitialDirContext(env);
Attributes dnsLookup = context.getAttributes(args[1], new String[]{args[0]});
Attribute records = dnsLookup.get(args[0]);
if (records == null) {
System.out.println("No " + args[0] + " record found for domain: " + args[1]);
return;
}
for (int i = 0; i < records.size(); i++) {
System.out.println(args[1] + ": " + records.get(i));
}
context.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
See the discussion of net-dev mailing list:
http://mail.openjdk.java.net/pipermail/net-dev/2010-October/002258.html