X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Ffcp%2Fquelaton%2FClientGetCommandImpl.java;h=5137c96a8ba2f55bf78bfb71d539db0f60680041;hb=e3f3a4323df8d53a0a59c2e4369abbcd8d60b940;hp=575d94b353b885b8929e1671d5a907f8bc214d28;hpb=f5ba10406d666197d448956e4340254c4f5593b6;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 575d94b..5137c96 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/ClientGetCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/ClientGetCommandImpl.java @@ -78,9 +78,9 @@ class ClientGetCommandImpl implements ClientGetCommand { } @Override - public ListenableFuture> uri(String uri) { + public Executable> uri(String uri) { ClientGet clientGet = createClientGetCommand(uri); - return threadPool.submit(() -> new ClientGetReplySequence().send(clientGet).get()); + return () -> threadPool.submit(() -> new ClientGetReplySequence().send(clientGet).get()); } private ClientGet createClientGetCommand(String uri) { @@ -109,7 +109,6 @@ class ClientGetCommandImpl implements ClientGetCommand { private class ClientGetReplySequence extends FcpReplySequence> { - private final AtomicReference identifier = new AtomicReference<>(); private final AtomicBoolean finished = new AtomicBoolean(); private final AtomicBoolean failed = new AtomicBoolean(); @@ -148,39 +147,24 @@ class ClientGetCommandImpl implements ClientGetCommand { @Override protected void consumeAllData(AllData allData) { - if (allData.getIdentifier().equals(identifier.get())) { - synchronized (this) { - contentType = allData.getContentType(); - dataLength = allData.getDataLength(); - try { - payload = new TempInputStream(allData.getPayloadInputStream(), dataLength); - finished.set(true); - } catch (IOException e) { - // TODO – logging - failed.set(true); - } + synchronized (this) { + contentType = allData.getContentType(); + dataLength = allData.getDataLength(); + try { + payload = new TempInputStream(allData.getPayloadInputStream(), dataLength); + finished.set(true); + } catch (IOException e) { + // TODO – logging + failed.set(true); } } } @Override protected void consumeGetFailed(GetFailed getFailed) { - if (getFailed.getIdentifier().equals(identifier.get())) { - failed.set(true); - } - } - - @Override - protected void consumeConnectionClosed(Throwable throwable) { failed.set(true); } - @Override - public ListenableFuture> send(FcpMessage fcpMessage) throws IOException { - identifier.set(fcpMessage.getField("Identifier")); - return super.send(fcpMessage); - } - } }