]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Make sure OutputStream gets closed in case of an Exception
authorJeremias Maerki <jeremias@apache.org>
Mon, 27 Jan 2003 09:25:19 +0000 (09:25 +0000)
committerJeremias Maerki <jeremias@apache.org>
Mon, 27 Jan 2003 09:25:19 +0000 (09:25 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195901 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/apps/CommandLineStarter.java

index 744d5400549028a99e9ad99576449d1d4bbb0103..befa7010aedf6469ffcabd76b4e6d4b47c652523 100644 (file)
@@ -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) {