Merge pull request #4109 from mofleury/jetty-9.4.x
Support meaningful JMX ObjectNames for HttpDestinations by avoiding race condition at creation
This commit is contained in:
commit
72d1a297a0
|
@ -540,24 +540,14 @@ public class HttpClient extends ContainerLifeCycle
|
||||||
port = normalizePort(scheme, port);
|
port = normalizePort(scheme, port);
|
||||||
|
|
||||||
Origin origin = new Origin(scheme, host, port);
|
Origin origin = new Origin(scheme, host, port);
|
||||||
HttpDestination destination = destinations.get(origin);
|
return destinations.computeIfAbsent(origin, o ->
|
||||||
if (destination == null)
|
|
||||||
{
|
{
|
||||||
destination = transport.newHttpDestination(origin);
|
HttpDestination newDestination = getTransport().newHttpDestination(o);
|
||||||
addManaged(destination);
|
addManaged(newDestination);
|
||||||
HttpDestination existing = destinations.putIfAbsent(origin, destination);
|
if (LOG.isDebugEnabled())
|
||||||
if (existing != null)
|
LOG.debug("Created {}", newDestination);
|
||||||
{
|
return newDestination;
|
||||||
removeBean(destination);
|
});
|
||||||
destination = existing;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("Created {}", destination);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return destination;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean removeDestination(HttpDestination destination)
|
protected boolean removeDestination(HttpDestination destination)
|
||||||
|
|
Loading…
Reference in New Issue