Recheck fields when cleaning up listeners 72/93472/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 29 Oct 2020 16:51:17 +0000 (17:51 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 29 Oct 2020 19:47:59 +0000 (20:47 +0100)
We may end up in a situation where we trigger multiple times, in
which case we can end up with mutated state and therefore cannot
rely on fields being non-null.

JIRA: YANGTOOLS-1155
Change-Id: I5607843d1e02483faa387a5630f3c4c06a3be62a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 1105cf5bc00628ee6dc2d86dce1ef4225050a5ba)

yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SimpleNamespaceContext.java

index 0442329dd6aaa12b81bceaa82d9fdfa045541ea5..0e619a78d935ba9e022a837c2dbeef36ef9bdba5 100644 (file)
@@ -47,7 +47,7 @@ final class SimpleNamespaceContext<K, V, N extends IdentifierNamespace<K, V>>
 
         if (listeners != null) {
             notifyListeners(storage, listeners.iterator(), value);
-            if (listeners.isEmpty()) {
+            if (listeners != null && listeners.isEmpty()) {
                 listeners = null;
             }
         }
@@ -59,7 +59,7 @@ final class SimpleNamespaceContext<K, V, N extends IdentifierNamespace<K, V>>
                     it.remove();
                 }
             }
-            if (predicateListeners.isEmpty()) {
+            if (predicateListeners != null && predicateListeners.isEmpty()) {
                 predicateListeners = null;
             }
         }