Catch duplicate instantiation of statements 50/102550/7
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 15 Nov 2022 22:30:15 +0000 (23:30 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 15 Nov 2022 22:33:04 +0000 (23:33 +0100)
commita14125cf6968d126396fc19849b63c29e4f865f6
treec0e4b307f2875d17308364279d7badcfa3c286d7
parent4ecf78a50f2e638ffd182aca0efb2dcfbf2140dd
Catch duplicate instantiation of statements

The problem here is that during tryToReusePrototype() we are copying
child statements, which in turn are triggering onStatementAdded(). For
unique statements this incurs a SchemaTreeNamespace requirement on the
target leaf -- which is satisified via requestSchemaTreeChild() and
recorded in substatements (as partial materialization) and it is also
recorded in the schema tree namespace. When this happens, though,
effectiveCopy() does not notice the statement has already been copied
and copies it again, and thus ends up colliding in the schema tree
namespace -- pointing to the same statement as the source of the
problem.

Update effectiveCopy() to re-examing substatements to see if they
reflect partial materialization and pick copied statement from there.

JIRA: YANGTOOLS-1445
Change-Id: Ic184f872bf21e3e3c112b4fb5960fbe44262c77e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/InferredStatementContext.java