Skip to content

Commit 0ad4f4e

Browse files
banseok1216fmbenhassine
authored andcommitted
Reinstate inadvertently removed protected method in StaxEventItemWriter
Signed-off-by: banseok1216 <bansuk1216@naver.com>
1 parent 7fe0541 commit 0ad4f4e

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

spring-batch-infrastructure/src/main/java/org/springframework/batch/infrastructure/item/xml/StaxEventItemWriter.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ public void close(@Nullable StaxWriterCallback footerCallback, List<QName> unclo
834834
footerCallback.write(footerCallbackWriter);
835835
}
836836
delegateEventWriter.flush();
837-
endDocument();
837+
endDocument(delegateEventWriter);
838838
}
839839
catch (IOException e) {
840840
throw new ItemStreamException("Failed to write footer items", e);
@@ -893,7 +893,7 @@ private void closeStream() {
893893
* @throws XMLStreamException thrown if error occurs.
894894
*/
895895
@SuppressWarnings("DataFlowIssue")
896-
private void endDocument() throws XMLStreamException {
896+
private void writeEndRootElement() throws XMLStreamException {
897897

898898
// writer.writeEndDocument(); <- this doesn't work after restart
899899
// we need to write end tag of the root element manually
@@ -925,4 +925,14 @@ private void setPosition(long newPosition) {
925925

926926
}
927927

928+
/**
929+
* Writes the EndDocument tag manually.
930+
* @param writer XML event writer
931+
* @throws XMLStreamException thrown if error occurs.
932+
*/
933+
protected void endDocument(XMLEventWriter writer) throws XMLStreamException {
934+
Assert.state(this.state != null, "OutputState is not initialized");
935+
this.state.writeEndRootElement();
936+
}
937+
928938
}

0 commit comments

Comments
 (0)