Skip to content

Commit

Permalink
[maven] when downloading a dependency, avoid to loose a correct class…
Browse files Browse the repository at this point in the history
…loader in down chain
  • Loading branch information
rmannibucau committed May 13, 2024
1 parent 25f80c4 commit 185baa4
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ForkJoinPool;
Expand Down Expand Up @@ -81,7 +84,15 @@ public Thread newThread(final Runnable r) {
if (followRedirects != null && !followRedirects.isBlank()) {
builder.followRedirects(HttpClient.Redirect.valueOf(followRedirects));
}
return builder.build();
return new DelegatingClient(builder.build()) {
@Override
public <T> CompletableFuture<HttpResponse<T>> sendAsync(final HttpRequest request, final HttpResponse.BodyHandler<T> responseBodyHandler) {
return delegate.sendAsync(request, responseBodyHandler)
// enforce the right classloader
.whenCompleteAsync((r, t) -> {
}, delegate.executor().orElseGet(ForkJoinPool::commonPool));
}
};
}

private boolean isMaven() {
Expand Down

0 comments on commit 185baa4

Please sign in to comment.