BUG-7222: Fix clustering BGPPeer NPE
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / PolicyDatabase.java
index f93cfabe694a3e8bf7020c3cde1d001da4e90b1d..a376928fc2a0d7a1dc38e55d9921130ebed943c2 100644 (file)
@@ -39,6 +39,14 @@ final class PolicyDatabase {
     }
 
     AbstractImportPolicy importPolicyForRole(final PeerRole peerRole) {
-        return this.importPolicies.get(peerRole);
+        /*
+         * TODO: this solution does not share equivalent attributes across
+         *       multiple peers. If we need to do that, consider carefully:
+         *       - whether the interner should be shared with RIBSupportContextImpl.writeRoutes()
+         *       - lookup/update contention of both the cache and the interner
+         *       - ability to share resulting attributes across import policies
+         *       - ability to share resulting attributes with export policies
+         */
+        return new CachingImportPolicy(importPolicies.get(peerRole));
     }
 }