From 1e0ec227ea53a758677a80ef0c4c14c36957befe Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Mon, 1 May 2023 10:08:48 +0100 Subject: [PATCH] Update XmlFactory.java --- .../jackson/dataformat/xml/XmlFactory.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/fasterxml/jackson/dataformat/xml/XmlFactory.java b/src/main/java/com/fasterxml/jackson/dataformat/xml/XmlFactory.java index 4d4cca644..055e2a03f 100644 --- a/src/main/java/com/fasterxml/jackson/dataformat/xml/XmlFactory.java +++ b/src/main/java/com/fasterxml/jackson/dataformat/xml/XmlFactory.java @@ -519,9 +519,21 @@ public ToXmlGenerator createGenerator(OutputStream out, JsonEncoding enc) throws } /** - * @param out - * @param encoding - * @return + * Method for constructing a {@link ToXmlGenerator} for writing XML content + * using specified output stream. + * Encoding to use must be specified. + *

+ * Underlying stream is NOT owned by the generator constructed, + * so that generator will NOT close the output stream when + * {@link ToXmlGenerator#close} is called (unless auto-closing + * feature, + * {@link com.fasterxml.jackson.core.JsonGenerator.Feature#AUTO_CLOSE_TARGET} + * is enabled). + * Using application needs to close it explicitly if this is the case. + * + * @param out OutputStream to use for writing JSON content + * @param encoding Character encoding to use + * @return a {@link ToXmlGenerator} instance * @throws IOException * @since 2.16 */ @@ -537,6 +549,7 @@ public ToXmlGenerator createGenerator(OutputStream out, String encoding) throws @Override public ToXmlGenerator createGenerator(Writer out) throws IOException { + super.createGenerator(out); final IOContext ctxt = _createContext(_createContentReference(out), false); return new ToXmlGenerator(ctxt, _generatorFeatures, _xmlGeneratorFeatures,