Allow shared JSONNNSWriter use 28/63928/4
authorStephen Kitt <skitt@redhat.com>
Wed, 20 Sep 2017 14:33:05 +0000 (16:33 +0200)
committerRobert Varga <nite@hq.sk>
Fri, 2 Feb 2018 15:20:01 +0000 (15:20 +0000)
commit94f5aaa2a0c1dc256891a0e66404e9d2c6549ed9
tree0aeb79c6a7f6400d19341af7eeb1a0a3327d945c
parentdd6442e7eb7dbe9ba102dcd9abb494610c0fcf52
Allow shared JSONNNSWriter use

JSONNormalizedNodeStreamWriter.createNestedWriter() gives the
impression that it can be used with an externally-controlled
JsonWriter, e.g. to build a JSON document containing several
serialised NormalizedNode instances. However, since it closes the
JsonWriter when closed itself, it limits the possible uses: currently,
a writer ends up having the same lifetime as a JsonWriter, even though
it doesn’t really have the same scope (because of the SchemaPath in
particular).

This patch changes the behaviour so that the provided JsonWriter has
an independent lifecycle (and needs to be closed by callers). I will
follow up with patches to the few users in ODL.

Change-Id: I9c597fe96937867cffdcbeeddd4b1507de20f2ee
Signed-off-by: Stephen Kitt <skitt@redhat.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3b56649b16a40841ff0caef191da42a0d9e73a16)
yang/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JSONNormalizedNodeStreamWriter.java