aboutsummaryrefslogtreecommitdiffstats
path: root/src/org
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2003-01-27 09:25:19 +0000
committerJeremias Maerki <jeremias@apache.org>2003-01-27 09:25:19 +0000
commitd8083ea2caf157b15b963c2534aad13d055e5715 (patch)
tree3fc8fadc53444b77c1e8eb330d206fd1039e23e2 /src/org
parent771585692a28aaa50326e5c31967539a1dfc8844 (diff)
downloadxmlgraphics-fop-d8083ea2caf157b15b963c2534aad13d055e5715.tar.gz
xmlgraphics-fop-d8083ea2caf157b15b963c2534aad13d055e5715.zip
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
Diffstat (limited to 'src/org')
-rw-r--r--src/org/apache/fop/apps/CommandLineStarter.java15
1 files changed, 9 insertions, 6 deletions
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) {