Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.1.x' into 3.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
lorban committed Dec 13, 2023
2 parents a1f9887 + cf96e55 commit fc37930
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!groovy

def oss = ["linux"]
def jdks = ["jdk11", "jdk17"]
def jdks = ["jdk11", "jdk17", "jdk21"]

def builds = [:]
for (def os in oss) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.time.Duration;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.EventListener;
Expand Down Expand Up @@ -207,6 +206,14 @@ public CompletableFuture<Void> begin() {
.thenCompose(v -> CompletableFuture.allOf(responses));
})
.thenRun(this::fireCompleteEvent)
// HttpClient cannot be stopped from one of its own threads.
.whenCompleteAsync((r, x) -> {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("stopping http clients");
}
Collection<HttpClient> clients = getBeans(HttpClient.class);
clients.forEach(this::stopHttpClient);
}, executorService)
// Call halt() even if previous stages failed.
.whenCompleteAsync((r, x) -> halt(), executorService);
}
Expand Down Expand Up @@ -235,8 +242,6 @@ private CompletableFuture<Void> process() {
// The method returns a CompletableFuture, but the implementation
// uses Callbacks that need to reference the innermost CompletableFuture.

HttpClient[] clients = new HttpClient[config.getUsersPerThread()];

Callback.Completable anyFailure = new Callback.Completable();

// This is the callback to use for warmup iterations.
Expand Down Expand Up @@ -267,6 +272,7 @@ private CompletableFuture<Void> process() {
}

Collection<Connection.Listener> connectionListeners = getBeans(Connection.Listener.class);
HttpClient[] clients = new HttpClient[config.getUsersPerThread()];
for (int i = 0; i < clients.length; ++i) {
HttpClient client = clients[i] = newHttpClient(getConfig());
connectionListeners.forEach(client::addBean);
Expand Down Expand Up @@ -386,14 +392,7 @@ private CompletableFuture<Void> process() {
LOGGER.debug("sender thread failed: {}", threadName, x);
}
}
})
// HttpClient cannot be stopped from one of its own threads.
.whenCompleteAsync((r, x) -> {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("stopping http clients");
}
Arrays.stream(clients).forEach(this::stopHttpClient);
}, executorService);
});
}

protected HttpClient newHttpClient(Config config) {
Expand Down

0 comments on commit fc37930

Please sign in to comment.