Skip to content

Replace custom Future implementations by CompletableFuture #32512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions buildSrc/src/main/resources/forbidden/es-server-signatures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ java.util.concurrent.Executors#newScheduledThreadPool(int)
java.util.concurrent.Executors#defaultThreadFactory()
java.util.concurrent.Executors#privilegedThreadFactory()

@defaultMessage use org.elasticsearch.common.util.concurrent.BaseFuture or one of its subclasses instead

java.util.concurrent.CompletableFuture#<init>()
java.util.concurrent.CompletableFuture#allOf(java.util.concurrent.CompletableFuture[])
java.util.concurrent.CompletableFuture#anyOf(java.util.concurrent.CompletableFuture[])
java.util.concurrent.CompletableFuture#supplyAsync(java.util.function.Supplier)
java.util.concurrent.CompletableFuture#supplyAsync(java.util.function.Supplier, java.util.concurrent.Executor)
java.util.concurrent.CompletableFuture#runAsync(java.lang.Runnable)
java.util.concurrent.CompletableFuture#runAsync(java.lang.Runnable, java.util.concurrent.Executor)
java.util.concurrent.CompletableFuture#completedFuture(java.lang.Object)
java.util.concurrent.CompletableFuture#failedFuture(java.lang.Throwable)

org.elasticsearch.common.util.concurrent.BaseFuture#toCompletableFuture()

java.lang.Character#codePointBefore(char[],int) @ Implicit start offset is error-prone when the char[] is a buffer and the first chars are random chars
java.lang.Character#codePointAt(char[],int) @ Implicit end offset is error-prone when the char[] is a buffer and the last chars are random chars

Expand Down
5 changes: 5 additions & 0 deletions docs/changelog/32512.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 32512
summary: Replace custom Future implementations by `CompletableFuture`
area: Infra/Core
type: enhancement
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
*/
package org.elasticsearch.grok;

import org.elasticsearch.common.util.concurrent.BaseFuture;
import org.elasticsearch.test.ESTestCase;
import org.mockito.Mockito;

import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.elasticsearch.test.ESTestCase;
import org.mockito.Mockito;

import static org.hamcrest.Matchers.is;
import static org.mockito.Matchers.any;
Expand Down Expand Up @@ -84,7 +85,7 @@ public void testIdleIfNothingRegistered() throws Exception {
(delay, command) -> threadPool.schedule(command, delay, TimeUnit.MILLISECONDS));
// Periodic action is not scheduled because no thread is registered
verifyZeroInteractions(threadPool);
CompletableFuture<Runnable> commandFuture = new CompletableFuture<>();
BaseFuture<Runnable> commandFuture = new BaseFuture<>();
// Periodic action is scheduled because a thread is registered
doAnswer(invocationOnMock -> {
commandFuture.complete((Runnable) invocationOnMock.getArguments()[0]);
Expand Down
Loading