From: Jeremias Maerki Date: Mon, 27 Jan 2003 09:25:19 +0000 (+0000) Subject: Make sure OutputStream gets closed in case of an Exception X-Git-Tag: Alt-Design-integration-base~141 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d8083ea2caf157b15b963c2534aad13d055e5715;p=xmlgraphics-fop.git Make sure OutputStream gets closed in case of an Exception git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195901 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/apps/CommandLineStarter.java b/src/org/apache/fop/apps/CommandLineStarter.java index 744d54005..befa7010a 100644 --- a/src/org/apache/fop/apps/CommandLineStarter.java +++ b/src/org/apache/fop/apps/CommandLineStarter.java @@ -50,13 +50,16 @@ public class CommandLineStarter extends Starter { driver.setRenderer(commandLineOptions.getRenderer()); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream( commandLineOptions.getOutputFile())); - driver.setOutputStream(bos); - if (driver.getRenderer() != null) { - driver.getRenderer().setOptions( - commandLineOptions.getRendererOptions()); + try { + driver.setOutputStream(bos); + if (driver.getRenderer() != null) { + driver.getRenderer().setOptions( + commandLineOptions.getRendererOptions()); + } + driver.render(parser, inputHandler.getInputSource()); + } finally { + bos.close(); } - driver.render(parser, inputHandler.getInputSource()); - bos.close(); System.exit(0); } catch (Exception e) { if (e instanceof FOPException) {