diff options
author | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2022-05-05 12:44:27 +0200 |
---|---|---|
committer | gjoranv <gv@verizonmedia.com> | 2022-06-08 11:45:21 +0200 |
commit | e70380aaa5890d9d3a4c83630f0e49b82093bfc4 (patch) | |
tree | 6983c429696daa2618d77a3e40f31c422903b85a | |
parent | a0c93b2790c150509659182328f5b7d2be0d9756 (diff) |
Remove deprecated APIs exposing Guava types
30 files changed, 25 insertions, 286 deletions
diff --git a/container-core/abi-spec.json b/container-core/abi-spec.json index 8ca6507f73e..845912056c9 100644 --- a/container-core/abi-spec.json +++ b/container-core/abi-spec.json @@ -2850,8 +2850,7 @@ "public void <init>(com.yahoo.processing.Request, com.yahoo.processing.request.ErrorMessage)", "public void mergeWith(com.yahoo.processing.Response)", "public com.yahoo.processing.response.DataList data()", - "public static java.util.concurrent.CompletableFuture recursiveFuture(com.yahoo.processing.response.DataList)", - "public static com.google.common.util.concurrent.ListenableFuture recursiveComplete(com.yahoo.processing.response.DataList)" + "public static java.util.concurrent.CompletableFuture recursiveFuture(com.yahoo.processing.response.DataList)" ], "fields": [] }, @@ -3152,7 +3151,6 @@ "public final java.util.concurrent.CompletableFuture renderResponse(java.io.OutputStream, com.yahoo.processing.Response, com.yahoo.processing.execution.Execution, com.yahoo.processing.Request)", "public void deconstruct()", "public final java.util.concurrent.CompletableFuture renderResponseBeforeHandover(java.io.OutputStream, com.yahoo.processing.Response, com.yahoo.processing.execution.Execution, com.yahoo.processing.Request)", - "public final com.google.common.util.concurrent.ListenableFuture renderBeforeHandover(java.io.OutputStream, com.yahoo.processing.Response, com.yahoo.processing.execution.Execution, com.yahoo.processing.Request)", "public com.yahoo.processing.execution.Execution getExecution()", "public com.yahoo.processing.Response getResponse()", "protected boolean clientClosed()", @@ -3197,8 +3195,7 @@ "public void <init>()", "public com.yahoo.processing.rendering.Renderer clone()", "public void init()", - "public com.google.common.util.concurrent.ListenableFuture render(java.io.OutputStream, com.yahoo.processing.Response, com.yahoo.processing.execution.Execution, com.yahoo.processing.Request)", - "public java.util.concurrent.CompletableFuture renderResponse(java.io.OutputStream, com.yahoo.processing.Response, com.yahoo.processing.execution.Execution, com.yahoo.processing.Request)", + "public abstract java.util.concurrent.CompletableFuture renderResponse(java.io.OutputStream, com.yahoo.processing.Response, com.yahoo.processing.execution.Execution, com.yahoo.processing.Request)", "public abstract java.lang.String getEncoding()", "public abstract java.lang.String getMimeType()", "public bridge synthetic com.yahoo.component.AbstractComponent clone()", @@ -3437,7 +3434,6 @@ "protected void <init>(com.yahoo.processing.Request, com.yahoo.processing.response.IncomingData, boolean, boolean)", "public com.yahoo.processing.Request request()", "public com.yahoo.processing.response.IncomingData incoming()", - "public com.google.common.util.concurrent.ListenableFuture complete()", "public java.util.concurrent.CompletableFuture completeFuture()", "public boolean isOrdered()", "public boolean isStreamed()", @@ -3498,7 +3494,6 @@ "public abstract java.util.List asList()", "public abstract com.yahoo.processing.response.IncomingData incoming()", "public abstract java.util.concurrent.CompletableFuture completeFuture()", - "public abstract com.google.common.util.concurrent.ListenableFuture complete()", "public abstract void addDataListener(java.lang.Runnable)", "public void close()" ], @@ -3517,7 +3512,6 @@ "public void <init>(com.yahoo.processing.response.DataList)", "public final void assignOwner(com.yahoo.processing.response.DataList)", "public com.yahoo.processing.response.DataList getOwner()", - "public com.google.common.util.concurrent.ListenableFuture completed()", "public java.util.concurrent.CompletableFuture completedFuture()", "public synchronized boolean isComplete()", "public synchronized void addLast(com.yahoo.processing.response.Data)", @@ -3582,7 +3576,6 @@ ], "methods": [ "public void <init>(com.yahoo.processing.response.DataList)", - "public com.google.common.util.concurrent.ListenableFuture completed()", "public java.util.concurrent.CompletableFuture completedFuture()", "public com.yahoo.processing.response.DataList getOwner()", "public boolean isComplete()", @@ -3608,7 +3601,6 @@ "methods": [ "public abstract com.yahoo.processing.response.DataList getOwner()", "public abstract java.util.concurrent.CompletableFuture completedFuture()", - "public abstract com.google.common.util.concurrent.ListenableFuture completed()", "public abstract boolean isComplete()", "public abstract void addLast(com.yahoo.processing.response.Data)", "public abstract void add(com.yahoo.processing.response.Data)", diff --git a/container-core/src/main/java/com/yahoo/processing/Response.java b/container-core/src/main/java/com/yahoo/processing/Response.java index cf54d043c5f..59533900a0c 100644 --- a/container-core/src/main/java/com/yahoo/processing/Response.java +++ b/container-core/src/main/java/com/yahoo/processing/Response.java @@ -1,9 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.processing; -import com.google.common.util.concurrent.ListenableFuture; import com.yahoo.component.provider.ListenableFreezableClass; -import com.yahoo.concurrent.CompletableFutures; import com.yahoo.concurrent.SystemTimer; import com.yahoo.processing.execution.ResponseReceiver; import com.yahoo.processing.impl.ProcessingFuture; @@ -102,13 +100,6 @@ public class Response extends ListenableFreezableClass { return new CompleteAllOnGetFuture<D>(futures); } - /** @deprecated Use {@link #recursiveFuture(DataList)} instead */ - @Deprecated(forRemoval = true, since = "7") - @SuppressWarnings("removal") - public static <D extends Data> ListenableFuture<DataList<D>> recursiveComplete(DataList<D> rootDataList) { - return CompletableFutures.toGuavaListenableFuture(recursiveFuture(rootDataList)); - } - @SuppressWarnings("unchecked") private static <D extends Data> void collectCompletionFutures(DataList<D> dataList, List<CompletableFuture<DataList<D>>> futures) { futures.add(dataList.completeFuture()); diff --git a/container-core/src/main/java/com/yahoo/processing/impl/ProcessingFuture.java b/container-core/src/main/java/com/yahoo/processing/impl/ProcessingFuture.java index ab597fffaff..07923de6e09 100644 --- a/container-core/src/main/java/com/yahoo/processing/impl/ProcessingFuture.java +++ b/container-core/src/main/java/com/yahoo/processing/impl/ProcessingFuture.java @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.processing.impl; -import com.google.common.util.concurrent.ListenableFuture; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -14,8 +13,7 @@ import java.util.concurrent.TimeoutException; * * @author bjorncs */ -// TODO Vespa 8 remove ListenableFuture implementation -public abstract class ProcessingFuture<V> extends CompletableFuture<V> implements ListenableFuture<V> { +public abstract class ProcessingFuture<V> extends CompletableFuture<V> { @Override public boolean cancel(boolean mayInterruptIfRunning) { return false; } @Override public boolean isCancelled() { return false; } @@ -23,7 +21,6 @@ public abstract class ProcessingFuture<V> extends CompletableFuture<V> implement @Override public abstract V get() throws InterruptedException, ExecutionException; @Override public abstract V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException; - @Override public void addListener(Runnable listener, Executor executor) { whenCompleteAsync((__, ___) -> listener.run(), executor); } diff --git a/container-core/src/main/java/com/yahoo/processing/rendering/AsynchronousSectionedRenderer.java b/container-core/src/main/java/com/yahoo/processing/rendering/AsynchronousSectionedRenderer.java index bb5fe7a1f76..aa753beb6a7 100644 --- a/container-core/src/main/java/com/yahoo/processing/rendering/AsynchronousSectionedRenderer.java +++ b/container-core/src/main/java/com/yahoo/processing/rendering/AsynchronousSectionedRenderer.java @@ -1,8 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.processing.rendering; -import com.google.common.util.concurrent.ListenableFuture; -import com.yahoo.concurrent.CompletableFutures; import com.yahoo.concurrent.ThreadFactoryFactory; import com.yahoo.jdisc.handler.CompletionHandler; import com.yahoo.jdisc.handler.ContentChannel; @@ -223,15 +221,6 @@ public abstract class AsynchronousSectionedRenderer<RESPONSE extends Response> e return startRender(stream, response, execution, request); } - - /** @deprecated Use {@link #renderResponseBeforeHandover(OutputStream, Response, Execution, Request)} */ - @Deprecated(forRemoval = true, since = "7") - @SuppressWarnings("removal") - public final ListenableFuture<Boolean> renderBeforeHandover(OutputStream stream, RESPONSE response, - Execution execution, Request request) { - return CompletableFutures.toGuavaListenableFuture(renderResponseBeforeHandover(stream, response, execution, request)); - } - private CompletableFuture<Boolean> startRender(OutputStream stream, RESPONSE response, Execution execution, Request request) { this.response = response; diff --git a/container-core/src/main/java/com/yahoo/processing/rendering/Renderer.java b/container-core/src/main/java/com/yahoo/processing/rendering/Renderer.java index 8db4ed4f624..df53ac846f2 100644 --- a/container-core/src/main/java/com/yahoo/processing/rendering/Renderer.java +++ b/container-core/src/main/java/com/yahoo/processing/rendering/Renderer.java @@ -1,9 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.processing.rendering; -import com.google.common.util.concurrent.ListenableFuture; import com.yahoo.component.AbstractComponent; -import com.yahoo.concurrent.CompletableFutures; import com.yahoo.processing.Request; import com.yahoo.processing.Response; import com.yahoo.processing.execution.Execution; @@ -43,17 +41,6 @@ public abstract class Renderer<RESPONSE extends Response> extends AbstractCompon } /** - * @deprecated Use/implement {@link #renderResponse(OutputStream, Response, Execution, Request)} instead. - * Return type changed from {@link ListenableFuture} to {@link CompletableFuture}. - */ - @Deprecated(forRemoval = true, since = "7") - @SuppressWarnings("removal") - public ListenableFuture<Boolean> render(OutputStream stream, RESPONSE response, Execution execution, - Request request) { - return CompletableFutures.toGuavaListenableFuture(renderResponse(stream, response, execution, request)); - } - - /** * Render a response to a stream. The stream also exposes a ByteBuffer API * for efficient transactions to JDisc. The returned future will throw the * exception causing failure wrapped in an ExecutionException if rendering @@ -65,11 +52,8 @@ public abstract class Renderer<RESPONSE extends Response> extends AbstractCompon * @param request the request matching the response * @return a {@link CompletableFuture} containing a boolean where true indicates a successful rendering */ - @SuppressWarnings("removal") - public CompletableFuture<Boolean> renderResponse(OutputStream stream, RESPONSE response, - Execution execution, Request request) { - return CompletableFutures.toCompletableFuture(render(stream, response, execution, request)); - } + public abstract CompletableFuture<Boolean> renderResponse(OutputStream stream, RESPONSE response, + Execution execution, Request request); /** * Name of the output encoding, if applicable. diff --git a/container-core/src/main/java/com/yahoo/processing/response/AbstractDataList.java b/container-core/src/main/java/com/yahoo/processing/response/AbstractDataList.java index b1ce0643487..15b1abc10cd 100644 --- a/container-core/src/main/java/com/yahoo/processing/response/AbstractDataList.java +++ b/container-core/src/main/java/com/yahoo/processing/response/AbstractDataList.java @@ -1,9 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.processing.response; -import com.google.common.util.concurrent.ListenableFuture; import com.yahoo.component.provider.ListenableFreezableClass; -import com.yahoo.concurrent.CompletableFutures; import com.yahoo.processing.Request; import com.yahoo.processing.impl.ProcessingFuture; @@ -92,13 +90,6 @@ public abstract class AbstractDataList<DATATYPE extends Data> extends Listenable return incomingData; } - @Override - @SuppressWarnings("removal") - @Deprecated(forRemoval = true, since = "7") - public ListenableFuture<DataList<DATATYPE>> complete() { - return CompletableFutures.toGuavaListenableFuture(completedFuture); - } - @Override public CompletableFuture<DataList<DATATYPE>> completeFuture() { return completedFuture; } @Override @@ -108,7 +99,7 @@ public abstract class AbstractDataList<DATATYPE extends Data> extends Listenable public boolean isStreamed() { return streamed; } public String toString() { - return super.toString() + (complete().isDone() ? " [completed]" : " [incomplete, " + incoming() + "]"); + return super.toString() + (completeFuture().isDone() ? " [completed]" : " [incomplete, " + incoming() + "]"); } public static final class DrainOnGetFuture<DATATYPE extends Data> extends ProcessingFuture<DataList<DATATYPE>> { diff --git a/container-core/src/main/java/com/yahoo/processing/response/DataList.java b/container-core/src/main/java/com/yahoo/processing/response/DataList.java index dbda8983f12..8c63dd2f7fe 100644 --- a/container-core/src/main/java/com/yahoo/processing/response/DataList.java +++ b/container-core/src/main/java/com/yahoo/processing/response/DataList.java @@ -1,8 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.processing.response; -import com.google.common.util.concurrent.ListenableFuture; - import java.util.List; import java.util.concurrent.CompletableFuture; @@ -74,10 +72,6 @@ public interface DataList<DATATYPE extends Data> extends Data { */ CompletableFuture<DataList<DATATYPE>> completeFuture(); - /** @deprecated Use {@link #completeFuture()} instead */ - @Deprecated(forRemoval = true, since = "7") - ListenableFuture<DataList<DATATYPE>> complete(); - /** * Adds a listener which is invoked every time data is added to this list. * The listener is always invoked on the same thread which is adding the data, diff --git a/container-core/src/main/java/com/yahoo/processing/response/DefaultIncomingData.java b/container-core/src/main/java/com/yahoo/processing/response/DefaultIncomingData.java index 813d6ac54d8..eab033f8bc9 100644 --- a/container-core/src/main/java/com/yahoo/processing/response/DefaultIncomingData.java +++ b/container-core/src/main/java/com/yahoo/processing/response/DefaultIncomingData.java @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.processing.response; -import com.google.common.util.concurrent.ListenableFuture; import com.yahoo.collections.Tuple2; import com.yahoo.concurrent.CompletableFutures; @@ -50,13 +49,6 @@ public class DefaultIncomingData<DATATYPE extends Data> implements IncomingData< return owner; } - @Override - @Deprecated(forRemoval = true, since = "7") - @SuppressWarnings("removal") - public ListenableFuture<DataList<DATATYPE>> completed() { - return CompletableFutures.toGuavaListenableFuture(completionFuture); - } - @Override public CompletableFuture<DataList<DATATYPE>> completedFuture() { return completionFuture; } /** Returns whether the data in this is complete */ diff --git a/container-core/src/main/java/com/yahoo/processing/response/IncomingData.java b/container-core/src/main/java/com/yahoo/processing/response/IncomingData.java index 54ba0fa8031..fc0e6d21e13 100644 --- a/container-core/src/main/java/com/yahoo/processing/response/IncomingData.java +++ b/container-core/src/main/java/com/yahoo/processing/response/IncomingData.java @@ -1,8 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.processing.response; -import com.google.common.util.concurrent.ListenableFuture; -import com.yahoo.concurrent.CompletableFutures; import com.yahoo.processing.impl.ProcessingFuture; import java.util.Collections; @@ -39,10 +37,6 @@ public interface IncomingData<DATATYPE extends Data> { */ CompletableFuture<DataList<DATATYPE>> completedFuture(); - /** @deprecated Use {@link #completedFuture()} instead */ - @Deprecated(forRemoval = true, since = "7") - ListenableFuture<DataList<DATATYPE>> completed(); - /** * Returns whether this is complete */ @@ -114,13 +108,6 @@ public interface IncomingData<DATATYPE extends Data> { completionFuture = new ImmediateFuture<>(owner); } - @Override - @SuppressWarnings("removal") - @Deprecated(forRemoval = true, since = "7") - public ListenableFuture<DataList<DATATYPE>> completed() { - return CompletableFutures.toGuavaListenableFuture(completionFuture); - } - @Override public CompletableFuture<DataList<DATATYPE>> completedFuture() { return completionFuture; } @Override diff --git a/container-core/src/test/java/com/yahoo/processing/ResponseTestCase.java b/container-core/src/test/java/com/yahoo/processing/ResponseTestCase.java index efcf608b6f0..f8cd646909d 100644 --- a/container-core/src/test/java/com/yahoo/processing/ResponseTestCase.java +++ b/container-core/src/test/java/com/yahoo/processing/ResponseTestCase.java @@ -22,7 +22,7 @@ public class ResponseTestCase { * Check the recursive toString printing along the way. * List variable names ends by numbers specifying the index of the list at each level. */ - @SuppressWarnings({"unchecked", "removal"}) + @SuppressWarnings({"unchecked"}) @Test public void testRecursiveCompletionAndToString() throws InterruptedException, ExecutionException { // create lists @@ -68,7 +68,7 @@ public class ResponseTestCase { assertEqualsIgnoreObjectNumbers("Uncompleted tree, incoming complete", uncompletedTreeCompletedIncoming, Responses.recursiveToString(list1)); // complete all - Response.recursiveComplete(list1).get(); + Response.recursiveFuture(list1).get(); assertEqualsIgnoreObjectNumbers("Completed tree", completedTree, Responses.recursiveToString(list1)); } diff --git a/container-core/src/test/java/com/yahoo/processing/execution/test/FutureDataTestCase.java b/container-core/src/test/java/com/yahoo/processing/execution/test/FutureDataTestCase.java index 2fb32271419..7dd043383a1 100644 --- a/container-core/src/test/java/com/yahoo/processing/execution/test/FutureDataTestCase.java +++ b/container-core/src/test/java/com/yahoo/processing/execution/test/FutureDataTestCase.java @@ -25,7 +25,7 @@ import static org.junit.Assert.assertEquals; public class FutureDataTestCase { /** Run a chain which ends in a processor which returns a response containing future data. */ - @SuppressWarnings({"unchecked", "removal"}) + @SuppressWarnings({"unchecked"}) @Test public void testFutureDataPassThrough() throws InterruptedException, ExecutionException, TimeoutException { // Set up @@ -45,14 +45,14 @@ public class FutureDataTestCase { futureDataSource.incomingData.get(0).add(new StringData(request, "d1")); futureDataSource.incomingData.get(0).addLast(new StringData(request, "d2")); assertEquals("New data is not visible because we haven't asked for it", 1, response.data().asList().size()); - response.data().complete().get(1000, TimeUnit.MILLISECONDS); + response.data().completeFuture().get(1000, TimeUnit.MILLISECONDS); assertEquals("Now the data is available", 3, response.data().asList().size()); assertEquals("d1",response.data().get(1).toString().toString()); assertEquals("d2",response.data().get(2).toString().toString()); } /** Federate to one source which returns data immediately and one who return future data */ - @SuppressWarnings({"unchecked", "removal"}) + @SuppressWarnings({"unchecked"}) @Test public void testFederateSyncAndAsyncData() throws InterruptedException, ExecutionException, TimeoutException { // Set up @@ -81,7 +81,7 @@ public class FutureDataTestCase { futureDataSource.incomingData.get(0).add(new StringData(request, "d1")); futureDataSource.incomingData.get(0).addLast(new StringData(request, "d2")); assertEquals("New data is not visible because we haven't asked for it", 0, asyncData.asList().size()); - asyncData.complete().get(1000, TimeUnit.MILLISECONDS); + asyncData.completeFuture().get(1000, TimeUnit.MILLISECONDS); assertEquals("Now the data is available", 2, asyncData.asList().size()); assertEquals("d1",asyncData.get(0).toString().toString()); assertEquals("d2", asyncData.get(1).toString().toString()); @@ -108,7 +108,7 @@ public class FutureDataTestCase { assertEquals("New data is not visible because it is not complete", 0, response.data().asList().size()); futureDataSource.incomingData.get(0).addLast(new StringData(request, "d2")); assertEquals("Not visible because it has not been synced yet", 0, response.data().asList().size()); - response.data().complete().get(1000, TimeUnit.MILLISECONDS); + response.data().completeFuture().get(1000, TimeUnit.MILLISECONDS); assertEquals("Now the data as well as the count is available", 3, response.data().asList().size()); assertEquals("d1",response.data().get(0).toString().toString()); assertEquals("d2",response.data().get(1).toString().toString()); @@ -120,7 +120,7 @@ public class FutureDataTestCase { * When the first of the futures are done one additional chain is to be run. * When both are done another chain is to be run. */ - @SuppressWarnings({"unchecked", "removal"}) + @SuppressWarnings({"unchecked"}) @Test public void testAsyncDataProcessingOfFederatedResult() throws InterruptedException, ExecutionException, TimeoutException { // Set up @@ -154,7 +154,7 @@ public class FutureDataTestCase { // complete async data in source1 futureSource1.incomingData.get(0).addLast(new StringData(request,"source1Data")); assertEquals("Not visible yet", 0, source1Data.asList().size()); - source1Data.complete().get(1000, TimeUnit.MILLISECONDS); + source1Data.completeFuture().get(1000, TimeUnit.MILLISECONDS); assertEquals(2, source1Data.asList().size()); assertEquals("source1Data",source1Data.get(0).toString()); assertEquals("Completion listener chain on this has run", "[source1] Data count: 1", source1Data.get(1).toString()); @@ -164,7 +164,7 @@ public class FutureDataTestCase { futureSource2.incomingData.get(0).addLast(new StringData(request, "source2Data")); assertEquals("Main completion listener has not run", 3, response.data().asList().size()); - Response.recursiveComplete(response.data()).get(); + Response.recursiveFuture(response.data()).get(); assertEquals("Main completion listener has run", 4, response.data().asList().size()); assertEquals("The main data counter saw all sync data, but not source2 data as it executes after this", "[main] Data count: " + (2 + 0 + 3), response.data().get(3).toString()); diff --git a/container-core/src/test/java/com/yahoo/processing/execution/test/StreamingTestCase.java b/container-core/src/test/java/com/yahoo/processing/execution/test/StreamingTestCase.java index bd1307ff77c..d494e774f8e 100644 --- a/container-core/src/test/java/com/yahoo/processing/execution/test/StreamingTestCase.java +++ b/container-core/src/test/java/com/yahoo/processing/execution/test/StreamingTestCase.java @@ -26,7 +26,7 @@ import static org.junit.Assert.assertEquals; public class StreamingTestCase { /** Tests adding a chain which is called every time new data is added to a data list */ - @SuppressWarnings({"unchecked", "removal"}) + @SuppressWarnings({"unchecked"}) @Test public void testStreamingData() throws InterruptedException, ExecutionException, TimeoutException { // Set up @@ -66,7 +66,7 @@ public class StreamingTestCase { assertEquals("We are getting data add events also the last time", 4, streamProcessor.invocationCount); assertEquals("New data is consumed", 4, response.data().asList().size()); - response.data().complete().get(1000, TimeUnit.MILLISECONDS); // no-op here + response.data().completeFuture().get(1000, TimeUnit.MILLISECONDS); // no-op here assertEquals("d1",response.data().get(1).toString().toString()); assertEquals("d2",response.data().get(2).toString().toString()); assertEquals("d3",response.data().get(3).toString().toString()); diff --git a/container-core/src/test/java/com/yahoo/processing/rendering/AsynchronousSectionedRendererTest.java b/container-core/src/test/java/com/yahoo/processing/rendering/AsynchronousSectionedRendererTest.java index a6db21d5094..5dfe29dd4a1 100644 --- a/container-core/src/test/java/com/yahoo/processing/rendering/AsynchronousSectionedRendererTest.java +++ b/container-core/src/test/java/com/yahoo/processing/rendering/AsynchronousSectionedRendererTest.java @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.processing.rendering; -import com.google.common.util.concurrent.ListenableFuture; import com.yahoo.component.provider.ListenableFreezableClass; import com.yahoo.container.jdisc.ContentChannelOutputStream; import com.yahoo.processing.Processor; @@ -23,8 +22,6 @@ import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; -import java.util.concurrent.TimeUnit; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotSame; @@ -403,41 +400,6 @@ public class AsynchronousSectionedRendererTest { } @Override - @SuppressWarnings("removal") - public ListenableFuture<DataList<StringData>> complete() { - return new ListenableFuture<>() { - @Override - public void addListener(Runnable runnable, Executor executor) { - } - - @Override - public boolean cancel(boolean b) { - return false; - } - - @Override - public boolean isCancelled() { - return false; - } - - @Override - public boolean isDone() { - return true; - } - - @Override - public DataList<StringData> get() { - return StringDataList.this; - } - - @Override - public DataList<StringData> get(long l, TimeUnit timeUnit) { - return StringDataList.this; - } - }; - } - - @Override public CompletableFuture<DataList<StringData>> completeFuture() { return CompletableFuture.completedFuture(this); } diff --git a/container-core/src/test/java/com/yahoo/processing/test/documentation/AsyncDataProcessingInitiator.java b/container-core/src/test/java/com/yahoo/processing/test/documentation/AsyncDataProcessingInitiator.java index 21731f7d714..a2a028772e5 100644 --- a/container-core/src/test/java/com/yahoo/processing/test/documentation/AsyncDataProcessingInitiator.java +++ b/container-core/src/test/java/com/yahoo/processing/test/documentation/AsyncDataProcessingInitiator.java @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.processing.test.documentation; -import com.google.common.util.concurrent.MoreExecutors; import com.yahoo.component.chain.Chain; import com.yahoo.processing.Processor; import com.yahoo.processing.Request; @@ -22,13 +21,11 @@ public class AsyncDataProcessingInitiator extends Processor { this.asyncChain=asyncChain; } - @SuppressWarnings({"removal"}) @Override public Response process(Request request, Execution execution) { Response response=execution.process(request); - response.data().complete().addListener(new RunnableExecution(request, - new ExecutionWithResponse(asyncChain, response, execution)), - MoreExecutors.directExecutor()); + response.data().completeFuture().whenComplete((__, ___) -> new RunnableExecution(request, + new ExecutionWithResponse(asyncChain, response, execution)).run()); return response; } diff --git a/container-search/abi-spec.json b/container-search/abi-spec.json index ff89cf432c2..1e205322169 100644 --- a/container-search/abi-spec.json +++ b/container-search/abi-spec.json @@ -4369,8 +4369,6 @@ ], "methods": [ "public void <init>(int, com.yahoo.search.Result, com.yahoo.search.Query, com.yahoo.processing.rendering.Renderer)", - "public com.google.common.util.concurrent.ListenableFuture waitableRender(java.io.OutputStream)", - "public static com.google.common.util.concurrent.ListenableFuture waitableRender(com.yahoo.search.Result, com.yahoo.search.Query, com.yahoo.processing.rendering.Renderer, java.io.OutputStream)", "public java.util.concurrent.CompletableFuture asyncRender(java.io.OutputStream)", "public static java.util.concurrent.CompletableFuture asyncRender(com.yahoo.search.Result, com.yahoo.search.Query, com.yahoo.processing.rendering.Renderer, java.io.OutputStream)", "public void render(java.io.OutputStream, com.yahoo.jdisc.handler.ContentChannel, com.yahoo.jdisc.handler.CompletionHandler)", @@ -7810,7 +7808,6 @@ "public boolean isFillable()", "public java.util.Set getFilled()", "public com.yahoo.processing.response.IncomingData incoming()", - "public com.google.common.util.concurrent.ListenableFuture complete()", "public java.util.concurrent.CompletableFuture completeFuture()", "public void addDataListener(java.lang.Runnable)", "public void close()", diff --git a/container-search/src/main/java/com/yahoo/search/handler/HttpSearchResponse.java b/container-search/src/main/java/com/yahoo/search/handler/HttpSearchResponse.java index 64e7403fa1a..c6906ea7566 100644 --- a/container-search/src/main/java/com/yahoo/search/handler/HttpSearchResponse.java +++ b/container-search/src/main/java/com/yahoo/search/handler/HttpSearchResponse.java @@ -1,9 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.handler; -import com.google.common.util.concurrent.ListenableFuture; import com.yahoo.collections.ListMap; -import com.yahoo.concurrent.CompletableFutures; import com.yahoo.container.handler.Coverage; import com.yahoo.container.handler.Timing; import com.yahoo.container.jdisc.ExtendedResponse; @@ -77,22 +75,6 @@ public class HttpSearchResponse extends ExtendedResponse { } } - /** @deprecated Use {@link #asyncRender(OutputStream)} instead */ - @Deprecated(forRemoval = true, since = "7") - public ListenableFuture<Boolean> waitableRender(OutputStream stream) throws IOException { - return waitableRender(result, query, rendererCopy, stream); - } - - /** @deprecated Use {@link #asyncRender(Result, Query, Renderer, OutputStream)} instead */ - @Deprecated(forRemoval = true, since = "7") - @SuppressWarnings("removal") - public static ListenableFuture<Boolean> waitableRender(Result result, - Query query, - Renderer<Result> renderer, - OutputStream stream) throws IOException { - return CompletableFutures.toGuavaListenableFuture(asyncRender(result, query, renderer, stream)); - } - public CompletableFuture<Boolean> asyncRender(OutputStream stream) { return asyncRender(result, query, rendererCopy, stream); } diff --git a/container-search/src/main/java/com/yahoo/search/result/HitGroup.java b/container-search/src/main/java/com/yahoo/search/result/HitGroup.java index 7096d937959..9699e9a7448 100644 --- a/container-search/src/main/java/com/yahoo/search/result/HitGroup.java +++ b/container-search/src/main/java/com/yahoo/search/result/HitGroup.java @@ -3,9 +3,7 @@ package com.yahoo.search.result; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; -import com.google.common.util.concurrent.ListenableFuture; import com.yahoo.collections.ListenableArrayList; -import com.yahoo.concurrent.CompletableFutures; import com.yahoo.net.URI; import com.yahoo.prelude.fastsearch.SortDataHitSorter; import com.yahoo.processing.response.ArrayDataList; @@ -964,13 +962,6 @@ public class HitGroup extends Hit implements DataList<Hit>, Cloneable, Iterable< @Override public IncomingData<Hit> incoming() { return incomingHits; } - @Override - @SuppressWarnings("removal") - @Deprecated(forRemoval = true, since = "7") - public ListenableFuture<DataList<Hit>> complete() { - return CompletableFutures.toGuavaListenableFuture(completedFuture); - } - @Override public CompletableFuture<DataList<Hit>> completeFuture() { return completedFuture; } @Override diff --git a/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java b/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java index 3236cbd5bbc..bad3cc7284d 100644 --- a/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java @@ -3,7 +3,6 @@ package com.yahoo.search.rendering; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.google.common.util.concurrent.ListenableFuture; import com.yahoo.component.ComponentId; import com.yahoo.component.chain.Chain; import com.yahoo.container.QrSearchersConfig; diff --git a/container-search/src/test/java/com/yahoo/search/searchchain/test/FutureDataTestCase.java b/container-search/src/test/java/com/yahoo/search/searchchain/test/FutureDataTestCase.java index 2426b18f018..15517270cb9 100644 --- a/container-search/src/test/java/com/yahoo/search/searchchain/test/FutureDataTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/searchchain/test/FutureDataTestCase.java @@ -32,7 +32,6 @@ import static org.junit.Assert.assertTrue; */ public class FutureDataTestCase { - @SuppressWarnings("removal") @Test public void testAsyncFederation() throws InterruptedException, ExecutionException { // Setup environment @@ -73,13 +72,12 @@ public class FutureDataTestCase { asyncProviderSearcher.simulateOneHitIOComplete(new Hit("async:1")); asyncProviderSearcher.simulateAllHitsIOComplete(); assertEquals("Got no async data yet, as we haven't pulled it", 0, asyncGroup.size()); - asyncGroup.complete().get(); + asyncGroup.completeFuture().get(); assertEquals("Completed, so we have the data", 2, asyncGroup.size()); assertEquals("async:0", asyncGroup.get(0).getId().toString()); assertEquals("async:1", asyncGroup.get(1).getId().toString()); } - @SuppressWarnings("removal") @Test public void testFutureData() throws InterruptedException, ExecutionException, TimeoutException { // Set up @@ -104,7 +102,7 @@ public class FutureDataTestCase { // Results with future hit groups will be passed to rendering directly and start rendering immediately. // For this test we block and wait for the data instead: - result.hits().complete().get(1000, TimeUnit.MILLISECONDS); + result.hits().completeFuture().get(1000, TimeUnit.MILLISECONDS); assertEquals(2, result.hits().getConcreteSize()); } diff --git a/documentapi/abi-spec.json b/documentapi/abi-spec.json index 7b865378dd5..2d4453d05de 100644 --- a/documentapi/abi-spec.json +++ b/documentapi/abi-spec.json @@ -3343,4 +3343,4 @@ ], "fields": [] } -} +}
\ No newline at end of file diff --git a/jdisc_core/abi-spec.json b/jdisc_core/abi-spec.json index 06e76f88898..d43c3e03e8f 100644 --- a/jdisc_core/abi-spec.json +++ b/jdisc_core/abi-spec.json @@ -32,7 +32,6 @@ ], "methods": [ "public abstract com.yahoo.jdisc.handler.RequestHandler resolveHandler(com.yahoo.jdisc.Request)", - "public java.lang.Object getInstance(com.google.inject.Key)", "public abstract java.lang.Object getInstance(java.lang.Class)" ], "fields": [] diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/Container.java b/jdisc_core/src/main/java/com/yahoo/jdisc/Container.java index e96f7f08fe8..b6deda58226 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/Container.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/Container.java @@ -2,7 +2,6 @@ package com.yahoo.jdisc; import com.google.inject.ConfigurationException; -import com.google.inject.Key; import com.google.inject.ProvisionException; import com.yahoo.jdisc.application.Application; import com.yahoo.jdisc.application.BindingSet; @@ -41,20 +40,6 @@ public interface Container extends SharedResource, Timer { RequestHandler resolveHandler(Request request); /** - * Returns the appropriate instance for the given injection key. When feasible, avoid using this method in favor - * of having Guice inject your dependencies ahead of time. - * - * @param key The key of the instance to return. - * @param <T> The class of the instance to return. - * @return The appropriate instance of the given class. - * @throws ConfigurationException If this injector cannot find or create the provider. - * @throws ProvisionException If there was a runtime failure while providing an instance. - * @deprecated Use {@link #getInstance(Class)} instead. - */ - @Deprecated(forRemoval = true, since = "7") // TODO Vespa 8 remove - default <T> T getInstance(Key<T> key) { throw new UnsupportedOperationException(); } - - /** * Returns the appropriate instance for the given injection type. When feasible, avoid using this method in * favor of having Guice inject your dependencies ahead of time. * diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/core/ContainerSnapshot.java b/jdisc_core/src/main/java/com/yahoo/jdisc/core/ContainerSnapshot.java index 808c8e89b1b..8367ea13a1a 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/core/ContainerSnapshot.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/core/ContainerSnapshot.java @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.jdisc.core; -import com.google.inject.Key; import com.yahoo.jdisc.AbstractResource; import com.yahoo.jdisc.Container; import com.yahoo.jdisc.Request; @@ -37,14 +36,6 @@ class ContainerSnapshot extends AbstractResource implements Container { this.containerReference = container.refer(context); } - /** @deprecated Use {@link #getInstance(Class)} instead. */ - @Override - @Deprecated(forRemoval = true, since = "7") // TODO Vespa 8 remove - @SuppressWarnings("removal") - public <T> T getInstance(Key<T> key) { - return container.guiceInjector().getInstance(key); - } - @Override public <T> T getInstance(Class<T> type) { return container.guiceInjector().getInstance(type); diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/FastContentOutputStream.java b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/FastContentOutputStream.java index e001db2ab81..e344dc6a159 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/FastContentOutputStream.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/FastContentOutputStream.java @@ -12,7 +12,7 @@ import java.util.concurrent.TimeoutException; /** * <p>This class extends the {@link AbstractContentOutputStream}, and forwards all write() and close() calls to a {@link * FastContentWriter}. This means that once {@link #close()} has been called, the asynchronous completion of all pending - * operations can be awaited using the ListenableFuture interface of this class. Any asynchronous failure will be + * operations can be awaited using the {@link Future} interface of this class. Any asynchronous failure will be * rethrown when calling either of the get() methods on this class.</p> * <p>Please notice that the Future implementation of this class will NEVER complete unless {@link #close()} has been * called.</p> diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/FastContentWriter.java b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/FastContentWriter.java index 7c278c67d59..fefd2ee6ee7 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/FastContentWriter.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/FastContentWriter.java @@ -11,7 +11,7 @@ import java.util.concurrent.atomic.AtomicInteger; /** * <p>This class provides a non-blocking, awaitable <em>write</em>-interface to a {@link ContentChannel}. - * The ListenableFuture<Boolean> interface can be used to await + * The {@link CompletableFuture<Boolean>} interface can be used to await * the asynchronous completion of all pending operations. Any asynchronous * failure will be rethrown when calling either of the get() methods on * this class.</p> diff --git a/searchlib/abi-spec.json b/searchlib/abi-spec.json index 3081c88ec99..cb1e4f83144 100644 --- a/searchlib/abi-spec.json +++ b/searchlib/abi-spec.json @@ -1460,9 +1460,7 @@ "public void <init>(java.util.Collection, java.util.Map)", "public void <init>(java.util.Map)", "public void <init>(java.util.Map, java.util.Map)", - "protected void <init>(com.google.common.collect.ImmutableMap, java.util.Map)", "public com.yahoo.searchlib.rankingexpression.ExpressionFunction getFunction(java.lang.String)", - "protected com.google.common.collect.ImmutableMap functions()", "protected java.util.Map getFunctions()", "public java.lang.String getBinding(java.lang.String)", "public com.yahoo.searchlib.rankingexpression.rule.FunctionReferenceContext withBindings(java.util.Map)", @@ -1627,7 +1625,6 @@ "public void <init>(java.util.Collection, java.util.Map, com.yahoo.tensor.evaluation.TypeContext)", "public void <init>(java.util.Map, java.util.Map, java.util.Map)", "public void <init>(java.util.Map, java.util.Map, java.util.Optional, java.util.Map)", - "public void <init>(com.google.common.collect.ImmutableMap, java.util.Map, java.util.Map)", "public java.util.Optional typeContext()", "public void addFunctionSerialization(java.lang.String, java.lang.String)", "public void addArgumentTypeSerialization(java.lang.String, java.lang.String, com.yahoo.tensor.TensorType)", diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/FunctionReferenceContext.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/FunctionReferenceContext.java index 287bc2655f5..96f0fa033d6 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/FunctionReferenceContext.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/FunctionReferenceContext.java @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchlib.rankingexpression.rule; -import com.google.common.collect.ImmutableMap; import com.yahoo.searchlib.rankingexpression.ExpressionFunction; import java.util.Collection; @@ -48,12 +47,6 @@ public class FunctionReferenceContext { this.bindings.putAll(bindings); } - /** @deprecated Use {@link #FunctionReferenceContext(Map, Map)} instead */ - @Deprecated(forRemoval = true, since = "7") - protected FunctionReferenceContext(ImmutableMap<String, ExpressionFunction> functions, Map<String, String> bindings) { - this((Map<String, ExpressionFunction>)functions, bindings); - } - private static Map<String, ExpressionFunction> toMap(Collection<ExpressionFunction> list) { Map<String, ExpressionFunction> mapBuilder = new HashMap<>(); for (ExpressionFunction function : list) @@ -64,10 +57,6 @@ public class FunctionReferenceContext { /** Returns a function or null if it isn't defined in this context */ public ExpressionFunction getFunction(String name) { return functions.get(name); } - /** @deprecated Use {@link #getFunctions()} instead */ - @Deprecated(forRemoval = true, since = "7") - protected ImmutableMap<String, ExpressionFunction> functions() { return ImmutableMap.copyOf(functions); } - protected Map<String, ExpressionFunction> getFunctions() { return functions; } /** Returns the resolution of an identifier, or null if it isn't defined in this context */ diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/SerializationContext.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/SerializationContext.java index d0a8e812091..5e5f7be7001 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/SerializationContext.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/SerializationContext.java @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchlib.rankingexpression.rule; -import com.google.common.collect.ImmutableMap; import com.yahoo.searchlib.rankingexpression.ExpressionFunction; import com.yahoo.searchlib.rankingexpression.RankingExpression; import com.yahoo.searchlib.rankingexpression.Reference; @@ -90,13 +89,6 @@ public class SerializationContext extends FunctionReferenceContext { this.serializedFunctions = serializedFunctions; } - /** @deprecated Use {@link #SerializationContext(Map, Map, Optional, Map) instead}*/ - @Deprecated(forRemoval = true, since = "7") - public SerializationContext(ImmutableMap<String,ExpressionFunction> functions, Map<String, String> bindings, - Map<String, String> serializedFunctions) { - this((Map<String, ExpressionFunction>)functions, bindings, serializedFunctions); - } - /** Returns the type context of this, if it is able to resolve types. */ public Optional<TypeContext<Reference>> typeContext() { return typeContext; } diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/TensorFunctionNode.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/TensorFunctionNode.java index 7b68ad7e2af..1b72213d5ff 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/TensorFunctionNode.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/TensorFunctionNode.java @@ -2,7 +2,6 @@ package com.yahoo.searchlib.rankingexpression.rule; import com.yahoo.api.annotations.Beta; -import com.google.common.collect.ImmutableMap; import com.yahoo.searchlib.rankingexpression.ExpressionFunction; import com.yahoo.searchlib.rankingexpression.Reference; import com.yahoo.searchlib.rankingexpression.evaluation.Context; @@ -342,13 +341,6 @@ public class TensorFunctionNode extends CompositeNode { return wrappedSerializationContext.typeContext(); } - /** @deprecated Use {@link #getFunctions()} instead */ - @SuppressWarnings("removal") - @Deprecated(forRemoval = true, since = "7") - protected ImmutableMap<String, ExpressionFunction> functions() { - return ImmutableMap.copyOf(wrappedSerializationContext.getFunctions()); - } - @Override protected Map<String, ExpressionFunction> getFunctions() { return wrappedSerializationContext.getFunctions(); } diff --git a/vespajlib/src/main/java/com/yahoo/concurrent/CompletableFutures.java b/vespajlib/src/main/java/com/yahoo/concurrent/CompletableFutures.java index a1235c3821d..2e14b532b35 100644 --- a/vespajlib/src/main/java/com/yahoo/concurrent/CompletableFutures.java +++ b/vespajlib/src/main/java/com/yahoo/concurrent/CompletableFutures.java @@ -1,13 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.concurrent; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.SettableFuture; -import com.yahoo.yolean.UncheckedInterruptedException; - import java.util.ArrayList; import java.util.List; -import java.util.concurrent.CancellationException; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -87,48 +82,4 @@ public class CompletableFutures { return results; }); } - - /** - * Helper for migrating from {@link ListenableFuture} to {@link CompletableFuture} in Vespa public apis - * @deprecated to be removed in Vespa 8 - */ - @SuppressWarnings("unchecked") - @Deprecated(forRemoval = true, since = "7") - public static <V> ListenableFuture<V> toGuavaListenableFuture(CompletableFuture<V> future) { - if (future instanceof ListenableFuture) { - return ((ListenableFuture<V>) future); - } - SettableFuture<V> guavaFuture = SettableFuture.create(); - future.whenComplete((result, error) -> { - if (result != null) guavaFuture.set(result); - else if (error instanceof CancellationException) guavaFuture.setException(error); - else guavaFuture.cancel(true); - }); - return guavaFuture; - } - - /** - * Helper for migrating from {@link ListenableFuture} to {@link CompletableFuture} in Vespa public apis - * @deprecated to be removed in Vespa 8 - */ - @Deprecated(forRemoval = true, since = "7") - public static <V> CompletableFuture<V> toCompletableFuture(ListenableFuture<V> guavaFuture) { - CompletableFuture<V> future = new CompletableFuture<>(); - guavaFuture.addListener( - () -> { - if (guavaFuture.isCancelled()) future.cancel(true); - try { - V value = guavaFuture.get(); - future.complete(value); - } catch (InterruptedException e) { - // Should not happens since listener is invoked after future is complete - throw new UncheckedInterruptedException(e); - } catch (ExecutionException e) { - future.completeExceptionally(e.getCause()); - } - }, - Runnable::run); - return future; - } - } |