[yangtools-dev] Stream writer problem after upgrade yangtools to 4.0.2


Robert Varga <nite@...>
 

On 19/11/2019 09:33, Richard Kosegi wrote:
Hi yangtools devs,

after upgraded jsonrpc to use yangtools 4.0.2, following code no longer
works as it used to:

NormalizedNode<?,?> data = ....
StringWriter writer = new StringWriter();
JsonWriter jsonWriter = JsonWriterFactory.createJsonWriter(writer);
NormalizedNodeStreamWriter jsonStream =
JSONNormalizedNodeStreamWriter.createExclusiveWriter(codecFactory,
schemaPath,null,jsonWriter);
NormalizedNodeWriter nodeWriter =
NormalizedNodeWriter.forStreamWriter(jsonStream);
nodeWriter.write(data);
nodeWriter.flush();
String jsonValue = writer.toString()

jsonValue string is missing ending "}"

Is this bug or is there a way to force NormalizedNodeWriter to emit it?
NormalizedNodeWriter is a java.io. Closeable -- hence you should be
really closing it, which solves the problem.

Bye,
Robert