RESOLVED - issue BATCH-448: StaxEventItemWriter creates invalid xml for zero row documents

http://jira.springframework.org/browse/BATCH-448

added empty character event before writing the end tag manually
This commit is contained in:
robokaso
2008-03-13 13:21:03 +00:00
parent d7e08ae574
commit cc39916c19
2 changed files with 7 additions and 0 deletions

View File

@@ -316,7 +316,13 @@ public class StaxEventItemWriter extends ExecutionContextUserSupport implements
// writer.writeEndDocument(); <- this doesn't work after restart
// we need to write end tag of the root element manually
//harmless event to close the root tag if there were no items
XMLEventFactory factory = XMLEventFactory.newInstance();
writer.add(factory.createCharacters(""));
writer.flush();
ByteBuffer bbuf = ByteBuffer.wrap(("</" + getRootTagName() + ">").getBytes());
try {
channel.write(bbuf);