Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.proofpoint.http.client.jetty;

import com.google.common.util.concurrent.ForwardingListenableFuture.SimpleForwardingListenableFuture;
import com.proofpoint.http.client.HttpClient;

import static com.google.common.util.concurrent.Futures.immediateFailedFuture;

public class FailedHttpResponseFuture<T>
extends SimpleForwardingListenableFuture<T>
implements HttpClient.HttpResponseFuture<T>
{
public FailedHttpResponseFuture(Throwable throwable)
{
super(immediateFailedFuture(throwable));
}

@Override
public String getState()
{
return "FAILED";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler;
import org.eclipse.jetty.util.thread.Scheduler;
import org.eclipse.jetty.util.thread.Sweeper;
import org.weakref.jmx.Flatten;
import org.weakref.jmx.Managed;
import org.weakref.jmx.Nested;
Expand Down Expand Up @@ -88,7 +87,6 @@ public class JettyHttpClient
};

private static final String PLATFORM_STATS_KEY = "platform_stats";
private static final long SWEEP_PERIOD_MILLIS = 5000;

private static final AtomicLong NAME_COUNTER = new AtomicLong();
private static final JettyHttpClientOptions DEFAULT_CLIENT_OPTIONS =
Expand Down Expand Up @@ -249,12 +247,6 @@ public JettyHttpClient(
httpClient.getScheduler(),
config.getConnectTimeout().toMillis()));

// Jetty client connections can sometimes get stuck while closing which reduces
// the available connections. The Jetty Sweeper periodically scans the active
// connection pool looking for connections in the closed state, and if a connection
// is observed in the closed state multiple times, it logs, and destroys the connection.
httpClient.addBean(new Sweeper(httpClient.getScheduler(), SWEEP_PERIOD_MILLIS), true);

try {
this.httpClient.start();

Expand Down Expand Up @@ -478,7 +470,12 @@ public <T, E extends Exception> HttpResponseFuture<T> executeAsync(Request reque
requireNonNull(responseHandler, "responseHandler is null");
AtomicLong bytesWritten = new AtomicLong(0);

request = applyRequestFilters(request);
try {
request = applyRequestFilters(request);
}
catch (RuntimeException e) {
return new FailedHttpResponseFuture<>(e);
}

HttpRequest jettyRequest = buildJettyRequest(request, bytesWritten);

Expand Down