[java-metadata-aggregator] 02/02: MDA-259 - Replace FutureNow with JDK equivalent
Ian Young
ian at iay.org.uk
Tue Oct 18 13:26:28 UTC 2022
This is an automated email from the git hooks/post-receive script.
iay pushed a commit to branch main
in repository java-metadata-aggregator.
View the commit online:
http://git.shibboleth.net/view/?p=java-metadata-aggregator.git;a=commit;h=4c1eba4cf49d12527c625542e0600e53c348e966
commit 4c1eba4cf49d12527c625542e0600e53c348e966
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Tue Oct 18 14:26:24 2022 +0100
MDA-259 - Replace FutureNow with JDK equivalent
https://shibboleth.atlassian.net/browse/MDA-259
---
.../metadata/pipeline/FutureSupport.java | 67 ----------------------
.../metadata/pipeline/SplitMergeStage.java | 11 ++--
2 files changed, 6 insertions(+), 72 deletions(-)
diff --git a/mda-framework/src/main/java/net/shibboleth/metadata/pipeline/FutureSupport.java b/mda-framework/src/main/java/net/shibboleth/metadata/pipeline/FutureSupport.java
index 792d790..520dc60 100644
--- a/mda-framework/src/main/java/net/shibboleth/metadata/pipeline/FutureSupport.java
+++ b/mda-framework/src/main/java/net/shibboleth/metadata/pipeline/FutureSupport.java
@@ -20,11 +20,8 @@ package net.shibboleth.metadata.pipeline;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
import javax.annotation.Nonnull;
-import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.ThreadSafe;
import org.slf4j.Logger;
@@ -38,57 +35,6 @@ import net.shibboleth.metadata.Item;
@ThreadSafe
public final class FutureSupport {
- /**
- * An implementation of {@link Future} that returns a value that is
- * already known.
- *
- * @param <T> type of "future" object to return
- */
- @Immutable
- private static class FutureNow<T> implements Future<T> {
-
- /**
- * Value to be returned.
- */
- private final T value;
-
- /**
- * Constructor.
- *
- * @param t value to be returned
- */
- FutureNow(final T t) {
- value = t;
- }
-
- @Override
- public boolean cancel(final boolean mayInterruptIfRunning) {
- return false;
- }
-
- @Override
- public boolean isCancelled() {
- return false;
- }
-
- @Override
- public boolean isDone() {
- return true;
- }
-
- @Override
- public T get() throws InterruptedException, ExecutionException {
- return value;
- }
-
- @Override
- public T get(final long timeout, final TimeUnit unit) throws InterruptedException,
- ExecutionException, TimeoutException {
- return value;
- }
-
- }
-
/** Class logger. */
private static final Logger LOG = LoggerFactory.getLogger(FutureSupport.class);
@@ -97,19 +43,6 @@ public final class FutureSupport {
}
- /**
- * Returns a {@link Future} containing an already computed value.
- *
- * @param t value to be returned
- * @param <T> type of value to be returned
- *
- * @return {@link Future} returning the passed value
- */
- @Nonnull
- public static <T> Future<T> futureNow(final T t) {
- return new FutureNow<>(t);
- }
-
/**
* Resolves the future value of a {@link Future} collection value.
* @param future {@link Future} value to be resolved
diff --git a/mda-framework/src/main/java/net/shibboleth/metadata/pipeline/SplitMergeStage.java b/mda-framework/src/main/java/net/shibboleth/metadata/pipeline/SplitMergeStage.java
index a09263f..5daa60e 100644
--- a/mda-framework/src/main/java/net/shibboleth/metadata/pipeline/SplitMergeStage.java
+++ b/mda-framework/src/main/java/net/shibboleth/metadata/pipeline/SplitMergeStage.java
@@ -19,6 +19,7 @@ package net.shibboleth.metadata.pipeline;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@@ -241,20 +242,20 @@ public class SplitMergeStage<T> extends AbstractStage<T> {
/**
* Executes a pipeline.
*
- * @param pipeline the pipeline, may be null
+ * @param pipeline the pipeline, may be <code>null</code>
* @param items the collections of items
*
* @return the token representing the background execution of the pipeline
*/
- @Nonnull protected Future<List<Item<T>>> executePipeline(final Pipeline<T> pipeline,
- final List<Item<T>> items) {
+ @Nonnull private Future<List<Item<T>>> executePipeline(@Nullable final Pipeline<T> pipeline,
+ @Nonnull final List<Item<T>> items) {
/*
* If no pipeline has been specified, just return the collection unchanged via
- * a {@link Future}.
+ * an already completed {@link CompletableFuture}.
*/
if (pipeline == null) {
- return FutureSupport.futureNow(items);
+ return CompletableFuture.completedFuture(items);
}
final PipelineCallable<T> callable = new PipelineCallable<>(pipeline, items);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list