Browse Source

check error on remaining PrintWriter instances

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@793528 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
ddf5cd73c9
9 changed files with 42 additions and 3 deletions
  1. +5
    -0
      WHATSNEW
  2. +4
    -0
      src/main/org/apache/tools/ant/taskdefs/AntStructure.java
  3. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Exec.java
  4. +6
    -0
      src/main/org/apache/tools/ant/taskdefs/Jar.java
  5. +3
    -0
      src/main/org/apache/tools/ant/taskdefs/ManifestTask.java
  6. +4
    -0
      src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java
  7. +3
    -0
      src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
  8. +6
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java
  9. +10
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java

+ 5
- 0
WHATSNEW View File

@@ -392,6 +392,11 @@ Fixed bugs:
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


+ 4
- 0
src/main/org/apache/tools/ant/taskdefs/AntStructure.java View File

@@ -117,6 +117,10 @@ public class AntStructure extends Task {

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());


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Exec.java View File

@@ -232,7 +232,7 @@ public class Exec extends Task {
*/
protected void logFlush() {
if (fos != null) {
fos.close();
fos.close();
}
}



+ 6
- 0
src/main/org/apache/tools/ant/taskdefs/Jar.java View File

@@ -539,6 +539,9 @@ public class Jar extends Zip {
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 @@ public class Jar extends Zip {
}
}

if (writer.checkError()) {
throw new IOException("Encountered an error writing jar index");
}
writer.close();
ByteArrayInputStream bais =
new ByteArrayInputStream(baos.toByteArray());


+ 3
- 0
src/main/org/apache/tools/ant/taskdefs/ManifestTask.java View File

@@ -251,6 +251,9 @@ public class ManifestTask extends Task {
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());


+ 4
- 0
src/main/org/apache/tools/ant/taskdefs/cvslib/ChangeLogTask.java View File

@@ -471,6 +471,10 @@ public class ChangeLogTask extends AbstractCvsTask {
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) {


+ 3
- 0
src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java View File

@@ -445,6 +445,9 @@ public class CvsTagDiff extends AbstractCvsTask {
}
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);


+ 6
- 1
src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java View File

@@ -791,8 +791,10 @@ public class NetRexxC extends MatchingTask {

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 @@ public class NetRexxC extends MatchingTask {
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);


+ 10
- 1
src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java View File

@@ -455,6 +455,7 @@ public class JDependTask extends Task {
}

FileWriter fw = null;
PrintWriter pw = null;
if (getOutputFile() != null) {
try {
fw = new FileWriter(getOutputFile().getPath());
@@ -464,7 +465,8 @@ public class JDependTask extends Task {
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 @@ public class JDependTask extends Task {
}

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;


Loading…
Cancel
Save