Skip to content

Commit

Permalink
works except for NPE not being thrown
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Crawford <[email protected]>
  • Loading branch information
stephen-crawford committed Jan 31, 2024
1 parent bce5460 commit 2b8f9fa
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import java.net.UnknownHostException;
import java.util.concurrent.CompletableFuture;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.junit.Before;
import org.junit.Test;

Expand Down Expand Up @@ -238,7 +240,7 @@ final void verifyOriginalContext(User user) {
}

@SuppressWarnings({ "rawtypes", "unchecked" })
final CompletableFuture<TransportResponse> completableRequestDecorate(
final void completableRequestDecorate(
AsyncSender sender,
Connection connection,
String action,
Expand All @@ -247,11 +249,17 @@ final CompletableFuture<TransportResponse> completableRequestDecorate(
TransportResponseHandler handler,
DiscoveryNode localNode
) {
CompletableFuture<TransportResponse> future = new CompletableFuture<>();
securityInterceptor.sendRequestDecorate(sender, connection, action, request, options, handler, localNode);
future.thenRun(() -> { verifyOriginalContext(user); });
future.complete(null);
return future;

ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();

singleThreadExecutor.execute(() -> {
try {
securityInterceptor.sendRequestDecorate(sender, connection, action, request, options, handler, localNode);
verifyOriginalContext(user);
} finally {
singleThreadExecutor.shutdown();
}
});
}

@Test
Expand Down

0 comments on commit 2b8f9fa

Please sign in to comment.