Author: bodewig
Date: Mon Jul 13 10:08:35 2009
New Revision: 793528
URL: http://svn.apache.org/viewvc?rev=793528&view=rev
Log:
check error on remaining PrintWriter instances
Modified:
ant/core/trunk/WHATSNEW
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Exec.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Jar.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ManifestTask.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java
Modified: ant/core/trunk/WHATSNEW
URL:
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=793528&r1=793527&r2=793528&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Mon Jul 13 10:08:35 2009
@@ -392,6 +392,11 @@
which confused some untar implementations.
Bugzilla Report 47421.
+ * various places where unchecked PrintWriters could hide exceptions
+ have been revisited to now check the error status or not use a
+ PrintWriter at all.
+ Bugzilla Report 43537.
+
Other changes:
--------------
* The get task now also follows redirects from http to https
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/AntStructure.java?rev=793528&r1=793527&r2=793528&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/AntStructure.java Mon
Jul 13 10:08:35 2009
@@ -117,6 +117,10 @@
printer.printTail(out);
+ if (out.checkError()) {
+ throw new IOException("Encountered an error writing Ant"
+ + " structure");
+ }
} catch (IOException ioe) {
throw new BuildException("Error writing "
+ output.getAbsolutePath(), ioe,
getLocation());
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Exec.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Exec.java?rev=793528&r1=793527&r2=793528&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Exec.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Exec.java Mon Jul 13
10:08:35 2009
@@ -232,7 +232,7 @@
*/
protected void logFlush() {
if (fos != null) {
- fos.close();
+ fos.close();
}
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Jar.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Jar.java?rev=793528&r1=793527&r2=793528&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Jar.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Jar.java Mon Jul 13
10:08:35 2009
@@ -539,6 +539,9 @@
OutputStreamWriter osw = new OutputStreamWriter(baos,
Manifest.JAR_ENCODING);
PrintWriter writer = new PrintWriter(osw);
manifest.write(writer);
+ if (writer.checkError()) {
+ throw new IOException("Encountered an error writing the manifest");
+ }
writer.close();
ByteArrayInputStream bais =
@@ -626,6 +629,9 @@
}
}
+ if (writer.checkError()) {
+ throw new IOException("Encountered an error writing jar index");
+ }
writer.close();
ByteArrayInputStream bais =
new ByteArrayInputStream(baos.toByteArray());
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ManifestTask.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ManifestTask.java?rev=793528&r1=793527&r2=793528&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ManifestTask.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ManifestTask.java Mon
Jul 13 10:08:35 2009
@@ -251,6 +251,9 @@
OutputStreamWriter osw = new OutputStreamWriter(fos,
Manifest.JAR_ENCODING);
w = new PrintWriter(osw);
toWrite.write(w);
+ if (w.checkError()) {
+ throw new IOException("Encountered an error writing manifest");
+ }
} catch (IOException e) {
throw new BuildException("Failed to write " + manifestFile,
e, getLocation());
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java?rev=793528&r1=793527&r2=793528&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java
Mon Jul 13 10:08:35 2009
@@ -471,6 +471,10 @@
final ChangeLogWriter serializer = new ChangeLogWriter();
serializer.printChangeLog(writer, entrySet);
+
+ if (writer.checkError()) {
+ throw new IOException("Encountered an error writing
changelog");
+ }
} catch (final UnsupportedEncodingException uee) {
getProject().log(uee.toString(), Project.MSG_ERR);
} catch (final IOException ioe) {
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java?rev=793528&r1=793527&r2=793528&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
Mon Jul 13 10:08:35 2009
@@ -445,6 +445,9 @@
}
DOM_WRITER.closeElement(root, writer, 0, "\t", true);
writer.flush();
+ if (writer.checkError()) {
+ throw new IOException("Encountered an error writing tagdiff");
+ }
writer.close();
} catch (UnsupportedEncodingException uee) {
log(uee.toString(), Project.MSG_ERR);
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java?rev=793528&r1=793527&r2=793528&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java
Mon Jul 13 10:08:35 2009
@@ -791,8 +791,10 @@
try {
StringWriter out = new StringWriter();
+ PrintWriter w = null;
int rc =
- COM.ibm.netrexx.process.NetRexxC.main(new Rexx(compileArgs),
new PrintWriter(out));
+ COM.ibm.netrexx.process.NetRexxC.main(new Rexx(compileArgs),
+ w = new
PrintWriter(out));
String sdir = srcDir.getAbsolutePath();
String ddir = destDir.getAbsolutePath();
boolean doReplace = !(sdir.equals(ddir));
@@ -839,6 +841,9 @@
throw new BuildException("Compile failed, messages should "
+ "have been provided.");
}
+ if (w.checkError()) {
+ throw new IOException("Encountered an error");
+ }
} catch (IOException ioe) {
throw new BuildException("Unexpected IOException while "
+ "playing with Strings", ioe);
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java?rev=793528&r1=793527&r2=793528&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java
Mon Jul 13 10:08:35 2009
@@ -455,6 +455,7 @@
}
FileWriter fw = null;
+ PrintWriter pw = null;
if (getOutputFile() != null) {
try {
fw = new FileWriter(getOutputFile().getPath());
@@ -464,7 +465,8 @@
log(msg);
throw new BuildException(msg);
}
- jdepend.setWriter(new PrintWriter(fw));
+ pw = new PrintWriter(fw);
+ jdepend.setWriter(pw);
log("Output to be stored in " + getOutputFile().getPath());
}
@@ -550,7 +552,14 @@
}
jdepend.analyze();
+ if (pw.checkError()) {
+ throw new IOException("Encountered an error writing JDepend"
+ + " output");
+ }
+ } catch (IOException ex) {
+ throw new BuildException(ex);
} finally {
+ FileUtils.close(pw);
FileUtils.close(fw);
}
return SUCCESS;