Close JSON root context when the writer is closed 80/84980/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 7 Oct 2019 15:19:34 +0000 (17:19 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 7 Oct 2019 16:05:37 +0000 (18:05 +0200)
commitf8e3d9af24d8d5d1eeca6a714d29f9822537a773
treefc0be08cfca94170e6a62a4d68e1cb057ec10371
parent0b99053fc99956133e78cfc5f01d31583ef7eb14
Close JSON root context when the writer is closed

We should be closing the root context when we are closed, not when
a its child is closed -- otherwise it would be impossible to write
multiple children of the root context.

Since we are in the area, also centralize some QName/ContainerNode
creation.

JIRA: YANGTOOLS-1029
Change-Id: I599fb5ad1ad8e36a441dff761984d5406e401d55
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
yang/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JSONStreamWriterContext.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/AbstractComplexJsonTest.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/AnyXmlSupportTest.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/JsonStreamToNormalizedNodeTest.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/NormalizedNodeToJsonStreamTest.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/YT1029Test.java [new file with mode: 0644]