Catch duplicate instantiation of statements 78/103278/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 15 Nov 2022 22:30:15 +0000 (23:30 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 16 Nov 2022 19:00:19 +0000 (20:00 +0100)
commite61839fde9cd9e34ae6c273aa997174314daf47c
treefa1b5f805dab3e3e61f2a58b51dd9da877f8b3f9
parent4250a6d3da8ade65a2980ac4ca5cdd278b67af71
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>
(cherry picked from commit a14125cf6968d126396fc19849b63c29e4f865f6)
parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/InferredStatementContext.java