X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Ffcp%2Fquelaton%2FClientGetCommandImpl.java;h=575d94b353b885b8929e1671d5a907f8bc214d28;hb=24c7c279c67bd5fe34bfef81e1ab936d7b555b3a;hp=98c416fef582a843aed1e376615dac7585f41ec3;hpb=4cdde96468f8c85dc449bad7dc72780e5275e040;p=jFCPlib.git diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/ClientGetCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/ClientGetCommandImpl.java index 98c416f..575d94b 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/ClientGetCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/ClientGetCommandImpl.java @@ -4,7 +4,6 @@ import java.io.IOException; import java.io.InputStream; import java.util.Optional; import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -16,6 +15,10 @@ import net.pterodactylus.fcp.GetFailed; import net.pterodactylus.fcp.Priority; import net.pterodactylus.fcp.ReturnType; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.ListeningExecutorService; +import com.google.common.util.concurrent.MoreExecutors; + /** * Implementation of the {@link ClientGetCommand}. * @@ -23,7 +26,7 @@ import net.pterodactylus.fcp.ReturnType; */ class ClientGetCommandImpl implements ClientGetCommand { - private final ExecutorService threadPool; + private final ListeningExecutorService threadPool; private final ConnectionSupplier connectionSupplier; private boolean ignoreDataStore; @@ -34,7 +37,7 @@ class ClientGetCommandImpl implements ClientGetCommand { private boolean global; public ClientGetCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier) { - this.threadPool = threadPool; + this.threadPool = MoreExecutors.listeningDecorator(threadPool); this.connectionSupplier = connectionSupplier; } @@ -75,7 +78,7 @@ class ClientGetCommandImpl implements ClientGetCommand { } @Override - public Future> uri(String uri) { + public ListenableFuture> uri(String uri) { ClientGet clientGet = createClientGetCommand(uri); return threadPool.submit(() -> new ClientGetReplySequence().send(clientGet).get()); } @@ -173,7 +176,7 @@ class ClientGetCommandImpl implements ClientGetCommand { } @Override - public Future> send(FcpMessage fcpMessage) throws IOException { + public ListenableFuture> send(FcpMessage fcpMessage) throws IOException { identifier.set(fcpMessage.getField("Identifier")); return super.send(fcpMessage); }