Allow shared JSONNNSWriter use 35/63335/4
authorStephen Kitt <skitt@redhat.com>
Wed, 20 Sep 2017 14:33:05 +0000 (16:33 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 4 Oct 2017 03:53:08 +0000 (05:53 +0200)
commit3b56649b16a40841ff0caef191da42a0d9e73a16
treeadfaf2c3da42e9bb554f1b69bc29e00604caf306
parent1a79a27329b0875c81ea52edc21a5ac1c768d1bb
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>
yang/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JSONNormalizedNodeStreamWriter.java