using computeIfAbsent to avoid the duplicate registering of Destinations in the MBean Server
Signed-off-by: Marc-Olivier Fleury <mofleury@gmail.com>
This commit is contained in:
parent
69d52b2263
commit
ebe28c27e4
|
@ -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)
|
HttpDestination newDestination = getTransport().newHttpDestination(o);
|
||||||
{
|
addManaged(newDestination);
|
||||||
destination = transport.newHttpDestination(origin);
|
if (LOG.isDebugEnabled()) {
|
||||||
addManaged(destination);
|
LOG.debug("Created {}", newDestination);
|
||||||
HttpDestination existing = destinations.putIfAbsent(origin, destination);
|
|
||||||
if (existing != null)
|
|
||||||
{
|
|
||||||
removeBean(destination);
|
|
||||||
destination = existing;
|
|
||||||
}
|
}
|
||||||
else
|
return newDestination;
|
||||||
{
|
});
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("Created {}", destination);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return destination;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean removeDestination(HttpDestination destination)
|
protected boolean removeDestination(HttpDestination destination)
|
||||||
|
|
Loading…
Reference in New Issue