Resolver implements AutoCloseable
This commit is contained in:
parent
f52f1de8ad
commit
f2705e4574
@ -50,11 +50,6 @@ public class CacheResolver implements Resolver, AutoCloseable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class CachedPacket {
|
private class CachedPacket {
|
||||||
final Packet response;
|
final Packet response;
|
||||||
final long receivedSeconds, expiredSeconds;
|
final long receivedSeconds, expiredSeconds;
|
||||||
|
@ -23,4 +23,10 @@ public class DelegatingQueueProcessingResolver extends AbstractQueueProcessingRe
|
|||||||
public Packet resolve(final Packet request) throws Exception {
|
public Packet resolve(final Packet request) throws Exception {
|
||||||
return delegate.resolve(request);
|
return delegate.resolve(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
super.close();
|
||||||
|
delegate.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import java.util.concurrent.Executor;
|
|||||||
*
|
*
|
||||||
* Ideally, implementations provide optimized versions of both the in-line and async call.
|
* Ideally, implementations provide optimized versions of both the in-line and async call.
|
||||||
*/
|
*/
|
||||||
public interface Resolver {
|
public interface Resolver extends AutoCloseable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This must return immediately and resolve the DNS query in the background, using the given executor
|
* This must return immediately and resolve the DNS query in the background, using the given executor
|
||||||
@ -45,6 +45,10 @@ public interface Resolver {
|
|||||||
return resolveAsync(new BaseRequestResponse(request), Runnable::run).get().getResponse();
|
return resolveAsync(new BaseRequestResponse(request), Runnable::run).get().getResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default void close() {
|
||||||
|
// do nothing by default
|
||||||
|
}
|
||||||
|
|
||||||
ServiceLoader<Services> services = ServiceLoader.load(Services.class);
|
ServiceLoader<Services> services = ServiceLoader.load(Services.class);
|
||||||
|
|
||||||
static Resolver of(final ParsedUrl parsedUrl) {
|
static Resolver of(final ParsedUrl parsedUrl) {
|
||||||
|
Loading…
Reference in New Issue
Block a user