Merged branch 'jetty-9.3.x' into 'master'.
This commit is contained in:
commit
fe62dd7c42
|
@ -498,24 +498,18 @@ public class HttpClient extends ContainerLifeCycle
|
|||
if (destination == null)
|
||||
{
|
||||
destination = transport.newHttpDestination(origin);
|
||||
if (isRunning())
|
||||
addManaged(destination);
|
||||
HttpDestination existing = destinations.putIfAbsent(origin, destination);
|
||||
if (existing != null)
|
||||
{
|
||||
HttpDestination existing = destinations.putIfAbsent(origin, destination);
|
||||
if (existing != null)
|
||||
{
|
||||
destination = existing;
|
||||
}
|
||||
else
|
||||
{
|
||||
addManaged(destination);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Created {}", destination);
|
||||
}
|
||||
|
||||
if (!isRunning())
|
||||
removeDestination(destination);
|
||||
removeBean(destination);
|
||||
destination = existing;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Created {}", destination);
|
||||
}
|
||||
|
||||
}
|
||||
return destination;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.eclipse.jetty.util.thread.Sweeper;
|
|||
@ManagedObject
|
||||
public abstract class PoolingHttpDestination<C extends Connection> extends HttpDestination implements Callback
|
||||
{
|
||||
private final DuplexConnectionPool connectionPool;
|
||||
private DuplexConnectionPool connectionPool;
|
||||
|
||||
public PoolingHttpDestination(HttpClient client, Origin origin)
|
||||
{
|
||||
|
@ -44,6 +44,29 @@ public abstract class PoolingHttpDestination<C extends Connection> extends HttpD
|
|||
sweeper.offer(connectionPool);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
HttpClient client = getHttpClient();
|
||||
this.connectionPool = newConnectionPool(client);
|
||||
addBean(connectionPool);
|
||||
super.doStart();
|
||||
Sweeper sweeper = client.getBean(Sweeper.class);
|
||||
if (sweeper != null)
|
||||
sweeper.offer(connectionPool);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() throws Exception
|
||||
{
|
||||
HttpClient client = getHttpClient();
|
||||
Sweeper sweeper = client.getBean(Sweeper.class);
|
||||
if (sweeper != null)
|
||||
sweeper.remove(connectionPool);
|
||||
super.doStop();
|
||||
removeBean(connectionPool);
|
||||
}
|
||||
|
||||
protected DuplexConnectionPool newConnectionPool(HttpClient client)
|
||||
{
|
||||
return new DuplexConnectionPool(this, client.getMaxConnectionsPerDestination(), this);
|
||||
|
|
Loading…
Reference in New Issue