Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,25 @@ public Class<IRepository> getSupportedDataType() {
@Override
public IMessageBody serialize(IRepository repository, Charset charset) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance();
XMLStreamWriter xmlStreamWriter;
XMLStreamWriter xmlStreamWriter = null;
try {
String encoding = charset == null ? null : charset.name();
xmlStreamWriter = xmlOutputFactory.createXMLStreamWriter(outputStream, encoding);
xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(outputStream, encoding);
xmlStreamWriter.writeStartDocument(null, encoding);
new RepositorySerializer().serializeRepository(repository, xmlStreamWriter, getSupportedContentType());
xmlStreamWriter.writeEndDocument();
xmlStreamWriter.flush();
return new ByteArrayMessageBody(getSupportedContentType(), outputStream.toByteArray());
} catch (XMLStreamException e) {
throw new ContentHandlerException("Error serializing repository", e); //$NON-NLS-1$
} finally {
if (xmlStreamWriter != null) {
try {
xmlStreamWriter.close();
} catch (XMLStreamException e) {
// ignore
}
}
}
}

Expand Down