Skip to content

Commit

Permalink
[ignore] port rev 11291 (bugfix: InternalXMLSerializer must close str…
Browse files Browse the repository at this point in the history
…eam on endDocument())

port rev 11292 (bugfix: move temp file creation to startDocument(), IOException now throw as SAXException)

svn path=/releases/eXist-1.4/; revision=11706
  • Loading branch information
shabanovd committed Apr 25, 2010
1 parent a35b14e commit c67e120
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/org/exist/xmldb/RemoteXMLResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -323,33 +323,45 @@ private class InternalXMLSerializer
extends SAXSerializer
{
File tmpfile=null;
OutputStreamWriter writer = null;

public InternalXMLSerializer() {
super();
}

public void startDocument() throws SAXException {
try {
File tmpfile=File.createTempFile("eXistRXR", ".xml");
tmpfile.deleteOnExit();
FileOutputStream fos=new FileOutputStream(tmpfile);
BufferedOutputStream bos=new BufferedOutputStream(fos);
OutputStreamWriter writer=new OutputStreamWriter(bos,"UTF-8");
writer=new OutputStreamWriter(bos,"UTF-8");
setOutput(writer, emptyProperties);
} catch(IOException ioe) {
// Don't know where to report!!!
throw new SAXException("Unable to create temp file for serialization data",ioe);
}

super.startDocument();
}

/**
* @see org.xml.sax.DocumentHandler#endDocument()
*/
public void endDocument()
throws SAXException
public void endDocument() throws SAXException
{
super.endDocument();
try {
setContent(tmpfile);
} catch(XMLDBException xe) {
throw new SAXException("Unable to close temp file containing serialized data",xe);
}

try {
if (writer != null)
writer.close();
} catch (IOException e) {
throw new SAXException("Unable to close temp file containing serialized data",e);
}
}
}

Expand Down

0 comments on commit c67e120

Please sign in to comment.