diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-05-16 12:32:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-16 12:32:32 +0200 |
commit | 3b4bd2b886ce72375b740d41206e15f18b9f68b5 (patch) | |
tree | 7d2bc91cd37b890b3a5caffe4e3acbde6bf49811 /messagebus | |
parent | ff6e80f8ecc40a4021710cb4b3fd3b756cf7685d (diff) | |
parent | 9b20a49bd89f9801d7a708fc700ae7f35483d8aa (diff) |
Merge pull request #9435 from vespa-engine/balder/ensure-we-do-not-drop-close-destroy-on-exception-or-create-some-that-we-do-not-destroy
- Use double checked locking to ensure that we do not create Policies…
Diffstat (limited to 'messagebus')
-rwxr-xr-x | messagebus/src/main/java/com/yahoo/messagebus/ProtocolRepository.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/messagebus/src/main/java/com/yahoo/messagebus/ProtocolRepository.java b/messagebus/src/main/java/com/yahoo/messagebus/ProtocolRepository.java index ad26475bf74..102e0be923d 100755 --- a/messagebus/src/main/java/com/yahoo/messagebus/ProtocolRepository.java +++ b/messagebus/src/main/java/com/yahoo/messagebus/ProtocolRepository.java @@ -28,7 +28,7 @@ public class ProtocolRepository { */ public void putProtocol(Protocol protocol) { if (protocols.put(protocol.getName(), protocol) != null) { - routingPolicyCache.clear(); + clearPolicyCache(); } } @@ -72,6 +72,10 @@ public class ProtocolRepository { return ret; } synchronized (this) { + ret = routingPolicyCache.get(cacheKey); + if (ret != null) { + return ret; + } Protocol protocol = getProtocol(protocolName); if (protocol == null) { log.log(LogLevel.ERROR, "Protocol '" + protocolName + "' not supported."); @@ -81,6 +85,9 @@ public class ProtocolRepository { ret = protocol.createPolicy(policyName, policyParam); } catch (RuntimeException e) { log.log(LogLevel.ERROR, "Protcol '" + protocolName + "' threw an exception: " + e.getMessage(), e); + if (ret != null) { + ret.destroy(); + } return null; } if (ret == null) { |