Use CompletedFuture from core

This commit is contained in:
Oleg Kalnichevski 2024-06-27 09:54:40 +02:00
parent a0bf57b837
commit e45345876e
2 changed files with 5 additions and 2 deletions

View File

@ -33,8 +33,8 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import org.apache.hc.client5.http.async.AsyncExecCallback; import org.apache.hc.client5.http.async.AsyncExecCallback;
import org.apache.hc.client5.http.impl.Operations;
import org.apache.hc.client5.http.schedule.SchedulingStrategy; import org.apache.hc.client5.http.schedule.SchedulingStrategy;
import org.apache.hc.core5.concurrent.CompletedFuture;
import org.apache.hc.core5.http.EntityDetails; import org.apache.hc.core5.http.EntityDetails;
import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.HttpResponse;
@ -70,7 +70,7 @@ class DefaultAsyncCacheRevalidator extends CacheRevalidatorBase {
public Future<?> schedule(final Runnable command, final TimeValue timeValue) throws RejectedExecutionException { public Future<?> schedule(final Runnable command, final TimeValue timeValue) throws RejectedExecutionException {
if (timeValue.toMilliseconds() <= 0) { if (timeValue.toMilliseconds() <= 0) {
command.run(); command.run();
return new Operations.CompletedFuture<Void>(null); return new CompletedFuture<>(null);
} }
return executor.schedule(command, timeValue); return executor.schedule(command, timeValue);
} }

View File

@ -48,7 +48,10 @@ public final class Operations {
* The outcome of the future cannot be altered and it cannot be cancelled. * The outcome of the future cannot be altered and it cannot be cancelled.
* *
* @param <T> operation result representation. * @param <T> operation result representation.
*
* @deprecated Use {@link org.apache.hc.core5.concurrent.CompletedFuture}.
*/ */
@Deprecated
public static class CompletedFuture<T> implements Future<T> { public static class CompletedFuture<T> implements Future<T> {
private final T result; private final T result;