@@ -1808,14 +1808,19 @@ private void writeResourceAs(final DocumentImpl resource, final DBBroker broker,
1808
1808
outputProperties .setProperty ("omit-xml-declaration" , "no" );
1809
1809
}
1810
1810
1811
- final OutputStreamWriter writer = new OutputStreamWriter (response .getOutputStream (), encoding );
1812
- sax .setOutput (writer , outputProperties );
1813
- serializer .setSAXHandlers (sax , sax );
1811
+ try {
1812
+ final OutputStreamWriter writer = new OutputStreamWriter (response .getOutputStream (), encoding );
1813
+ sax .setOutput (writer , outputProperties );
1814
+ serializer .setSAXHandlers (sax , sax );
1814
1815
1815
- serializer .toSAX (resource );
1816
+ serializer .toSAX (resource );
1816
1817
1817
- writer .flush ();
1818
- writer .close (); // DO NOT use in try-write-resources, otherwise ther response stream is always closed, and we can't report the errors
1818
+ // writer.flush(); // Not needed, because close() will flush the stream.
1819
+ writer .close (); // DO NOT use in try-with-resources, otherwise the response stream is always closed, and we can't report the errors
1820
+ } catch (org .eclipse .jetty .io .EofException connectionInterrupted ) {
1821
+ // Don't throw the EofException, which is caused by the client hanging up.
1822
+ LOG .info ("Ignored EofException while writing response to ReST client: {}" , connectionInterrupted .getMessage ());
1823
+ }
1819
1824
} catch (final SAXException saxe ) {
1820
1825
LOG .warn (saxe );
1821
1826
throw new BadRequestException ("Error while serializing XML: " + saxe .getMessage ());
0 commit comments