Skip to content

Commit

Permalink
Fixes jetty#8723: Provide a thread-safe way to modify HttpClient prox…
Browse files Browse the repository at this point in the history
…ies at runtime.
  • Loading branch information
cowwoc committed Oct 24, 2022
1 parent 660093f commit a675845
Showing 1 changed file with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.util.List;
import java.util.Set;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import org.eclipse.jetty.http.HttpScheme;
import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.util.HostPort;
Expand All @@ -37,16 +39,35 @@
*/
public class ProxyConfiguration
{
private final List<Proxy> proxies = new ArrayList<>();
private final BlockingQueue<Proxy> proxies = new LinkedBlockingQueue<>();

/**
* Adds a proxy.
*
* @param proxy a proxy
* @throws NullPointerException if {@code proxy} is null
*/
public void addProxy(Proxy proxy)
{
if (proxy == null)
throw new NullPointerException("proxy may not be null");
proxies.add(proxy);
}

public List<Proxy> getProxies()
/**
* Removes a proxy.
*
* @param proxy a proxy
* @return true if a match is found
*/
public boolean removeProxy(Proxy proxy)
{
return proxies;
return proxies.remove(proxy);
}

public Proxy match(Origin origin)
{
for (Proxy proxy : getProxies())
for (Proxy proxy : proxies)
{
if (proxy.matches(origin))
return proxy;
Expand Down

0 comments on commit a675845

Please sign in to comment.