Fixed HttpDestination lifecycle.
This commit is contained in:
parent
3fc6320881
commit
03b994a32c
|
@ -498,24 +498,18 @@ public class HttpClient extends ContainerLifeCycle
|
||||||
if (destination == null)
|
if (destination == null)
|
||||||
{
|
{
|
||||||
destination = transport.newHttpDestination(origin);
|
destination = transport.newHttpDestination(origin);
|
||||||
if (isRunning())
|
addManaged(destination);
|
||||||
|
HttpDestination existing = destinations.putIfAbsent(origin, destination);
|
||||||
|
if (existing != null)
|
||||||
{
|
{
|
||||||
HttpDestination existing = destinations.putIfAbsent(origin, destination);
|
removeBean(destination);
|
||||||
if (existing != null)
|
destination = existing;
|
||||||
{
|
}
|
||||||
destination = existing;
|
else
|
||||||
}
|
{
|
||||||
else
|
if (LOG.isDebugEnabled())
|
||||||
{
|
LOG.debug("Created {}", destination);
|
||||||
addManaged(destination);
|
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("Created {}", destination);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isRunning())
|
|
||||||
removeDestination(destination);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.eclipse.jetty.util.thread.Sweeper;
|
||||||
@ManagedObject
|
@ManagedObject
|
||||||
public abstract class PoolingHttpDestination<C extends Connection> extends HttpDestination implements Callback
|
public abstract class PoolingHttpDestination<C extends Connection> extends HttpDestination implements Callback
|
||||||
{
|
{
|
||||||
private final DuplexConnectionPool connectionPool;
|
private DuplexConnectionPool connectionPool;
|
||||||
|
|
||||||
public PoolingHttpDestination(HttpClient client, Origin origin)
|
public PoolingHttpDestination(HttpClient client, Origin origin)
|
||||||
{
|
{
|
||||||
|
@ -44,6 +44,29 @@ public abstract class PoolingHttpDestination<C extends Connection> extends HttpD
|
||||||
sweeper.offer(connectionPool);
|
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)
|
protected DuplexConnectionPool newConnectionPool(HttpClient client)
|
||||||
{
|
{
|
||||||
return new DuplexConnectionPool(this, client.getMaxConnectionsPerDestination(), this);
|
return new DuplexConnectionPool(this, client.getMaxConnectionsPerDestination(), this);
|
||||||
|
|
Loading…
Reference in New Issue