LookupAsynch.setDefaultCache(new Cache(), DClass.IN);
// reset cache between usages of the asynchronous lookuper
LookupAsynch.getDefaultCache(DClass.IN).clearCache();
try {
ExtendedNonblockingResolver resolver;
if (getDnsServiceMockStyle() == FAKE_SERVER) {
NonblockingResolver nonblockingResolver = new NonblockingResolver("127.0.0.1");
resolver = ExtendedNonblockingResolver.newInstance(new NonblockingResolver[] {nonblockingResolver});
nonblockingResolver.setPort(FAKE_SERVER_PORT);
nonblockingResolver.setTCP(false);
} else if (getDnsServiceMockStyle() == REAL_SERVER) {
resolver = ExtendedNonblockingResolver.newInstance();
Resolver[] resolvers = resolver.getResolvers();
for (int i = 0; i < resolvers.length; i++) {
resolvers[i].setTCP(false);
}
} else {
throw new IllegalStateException("DnsServiceMockStyle "+getDnsServiceMockStyle()+" is not supported when STAGED_EXECUTOR_DNSJNIO executor style is used");