Cache QNames obtained from binding classes 29/21729/1
authorRobert Varga <rovarga@cisco.com>
Wed, 3 Jun 2015 09:30:32 +0000 (11:30 +0200)
committerRobert Varga <rovarga@cisco.com>
Wed, 3 Jun 2015 09:30:32 +0000 (11:30 +0200)
Traces indicate we have a rogue QNameModule coming from this path, make
sure to squash it to a cached one.

Change-Id: I80f72ae0d4b80f35edc97060734fcc8df9c028c0
Signed-off-by: Robert Varga <rovarga@cisco.com>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/LocRibWriter.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AbstractRIBSupport.java

index a3cbb83c6aeafc798c24bbb2889e3c1c2cf8990e..f441539878f2cb66945608384dd03b04bec88429 100644 (file)
@@ -58,6 +58,7 @@ final class LocRibWriter implements AutoCloseable, DOMDataTreeChangeListener {
     private static final Logger LOG = LoggerFactory.getLogger(LocRibWriter.class);
 
     private static final LeafNode<Boolean> ATTRIBUTES_UPTODATE_TRUE = ImmutableNodes.leafNode(QName.create(Attributes.QNAME, "uptodate"), Boolean.TRUE);
+    private static final NodeIdentifier ROUTES_IDENTIFIER = new NodeIdentifier(Routes.QNAME);
 
     private final Map<PathArgument, AbstractRouteEntry> routeEntries = new HashMap<>();
     private final YangInstanceIdentifier locRibTarget;
@@ -168,7 +169,7 @@ final class LocRibWriter implements AutoCloseable, DOMDataTreeChangeListener {
                 value = null;
             }
 
-            final YangInstanceIdentifier writePath = this.ribSupport.routePath(this.locRibTarget.node(Routes.QNAME), e.getKey().getRouteId());
+            final YangInstanceIdentifier writePath = this.ribSupport.routePath(this.locRibTarget.node(ROUTES_IDENTIFIER), e.getKey().getRouteId());
             if (value != null) {
                 LOG.debug("Write route to LocRib {}", value);
                 tx.put(LogicalDatastoreType.OPERATIONAL, writePath, value);
index c14db983bbf19fb7bb503c58eb198b5940ac7c30..dac9d2a2df01d9df3d0865b0c46075e66740bc0a 100644 (file)
@@ -71,13 +71,13 @@ public abstract class AbstractRIBSupport implements RIBSupport {
      * @param listClass Binding class of the route list, nust not be null;
      */
     protected AbstractRIBSupport(final Class<? extends Routes> cazeClass, final Class<? extends DataObject> containerClass, final Class<? extends Route> listClass) {
-        final QName qname = BindingReflections.findQName(containerClass);
+        final QName qname = QName.cachedReference(BindingReflections.findQName(containerClass));
         this.routesContainerIdentifier = new NodeIdentifier(qname);
         this.routeAttributesIdentifier = new NodeIdentifier(QName.cachedReference(QName.create(qname, Attributes.QNAME.getLocalName())));
         this.cazeClass = Preconditions.checkNotNull(cazeClass);
         this.containerClass = Preconditions.checkNotNull(containerClass);
         this.listClass = Preconditions.checkNotNull(listClass);
-        this.routesListIdentifier = new NodeIdentifier(BindingReflections.findQName(listClass));
+        this.routesListIdentifier = new NodeIdentifier(QName.cachedReference(BindingReflections.findQName(listClass)));
     }
 
     @Override