From 2ce6cc4849308e8247585e46553ba38d7f252659 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 13 Jul 2001 13:06:17 +0000 Subject: [PATCH] forgot to check a package for missing close() calls on LogOutputStreams. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269340 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/taskdefs/rmic/KaffeRmic.java | 7 ++++--- .../apache/tools/ant/taskdefs/rmic/SunRmic.java | 14 ++++++++++---- .../org/apache/tools/ant/taskdefs/rmic/WLRmic.java | 5 +++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java b/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java index 635bf86fd..3af225aee 100644 --- a/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java +++ b/src/main/org/apache/tools/ant/taskdefs/rmic/KaffeRmic.java @@ -77,10 +77,10 @@ public class KaffeRmic extends DefaultRmicAdapter { PrintStream err = System.err; PrintStream out = System.out; + // the project log + PrintStream logstr = + new PrintStream(new LogOutputStream(getRmic(), Project.MSG_WARN)); try { - // the project log - PrintStream logstr = - new PrintStream(new LogOutputStream(getRmic(), Project.MSG_WARN)); System.setOut(logstr); System.setErr(logstr); @@ -106,6 +106,7 @@ public class KaffeRmic extends DefaultRmicAdapter { } finally { System.setErr(err); System.setOut(out); + logstr.close(); } } } diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java b/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java index 9cb7aa87a..9eeaa7e43 100644 --- a/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java +++ b/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java @@ -74,11 +74,11 @@ public class SunRmic extends DefaultRmicAdapter { getRmic().log("Using SUN rmic compiler", Project.MSG_VERBOSE); Commandline cmd = setupRmicCommand(); - try { - // Create an instance of the rmic, redirecting output to - // the project log - OutputStream logstr = new LogOutputStream(getRmic(), Project.MSG_WARN); + // Create an instance of the rmic, redirecting output to + // the project log + LogOutputStream logstr = new LogOutputStream(getRmic(), Project.MSG_WARN); + try { Class c = Class.forName("sun.rmi.rmic.Main"); Constructor cons = c.getConstructor(new Class[] { OutputStream.class, String.class }); @@ -100,6 +100,12 @@ public class SunRmic extends DefaultRmicAdapter { } else { throw new BuildException("Error starting SUN rmic: ", ex, getRmic().getLocation()); } + } finally { + try { + logstr.close(); + } catch (IOException e) { + throw new BuildException(e); + } } } } diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java b/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java index 18494f88d..4ce5befc5 100644 --- a/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java +++ b/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java @@ -78,9 +78,9 @@ public class WLRmic extends DefaultRmicAdapter { PrintStream err = System.err; PrintStream out = System.out; + PrintStream logstr = + new PrintStream(new LogOutputStream(getRmic(), Project.MSG_WARN)); try { - PrintStream logstr = - new PrintStream(new LogOutputStream(getRmic(), Project.MSG_WARN)); System.setOut(logstr); System.setErr(logstr); @@ -104,6 +104,7 @@ public class WLRmic extends DefaultRmicAdapter { } finally { System.setErr(err); System.setOut(out); + logstr.close(); } }