You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2007/10/02 20:30:40 UTC
DO NOT REPLY [Bug 43537] New: - DefaultCompilerAdapter ignores errors when writing temp file
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43537>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=43537
Summary: DefaultCompilerAdapter ignores errors when writing temp
file
Product: Ant
Version: 1.7.0
Platform: Sun
OS/Version: Solaris
Status: NEW
Severity: normal
Priority: P2
Component: Core tasks
AssignedTo: dev@ant.apache.org
ReportedBy: glenn@fenris.net
javac task
When writing a temporary file that contains the names of the java files to
compile, a PrintWriter is used, presumably to make native EOLs in the file.
However, the checkError method is never called, and a partial list of file names
can be created. This occurred on my system when the file system used by
temporary files was nearly full. It allowed the creation of the temp file, but
couldn't hold all the data. It manifested as not all class files getting created
by the javac task.
Here's a patch that works for me:
--- DefaultCompilerAdapter.java.orig Tue Oct 2 11:12:10 2007
+++ DefaultCompilerAdapter.java Tue Oct 2 11:11:03 2007
@@ -21,10 +21,10 @@
//Java5 style
//import static org.apache.tools.ant.util.StringUtils.LINE_SEP;
+import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
-import java.io.PrintWriter;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Location;
import org.apache.tools.ant.Project;
@@ -462,19 +462,21 @@
*/
if (Commandline.toString(args).length() > 4096
&& firstFileName >= 0) {
- PrintWriter out = null;
+ BufferedWriter out = null;
try {
tmpFile = FILE_UTILS.createTempFile(
"files", "", getJavac().getTempdir());
tmpFile.deleteOnExit();
- out = new PrintWriter(new FileWriter(tmpFile));
+ out = new BufferedWriter(new FileWriter(tmpFile));
+ String lineSeparator = System.getProperty("line.separator");
for (int i = firstFileName; i < args.length; i++) {
if (quoteFiles && args[i].indexOf(" ") > -1) {
args[i] = args[i].replace(File.separatorChar, '/');
- out.println("\"" + args[i] + "\"");
+ out.write("\"" + args[i] + "\"");
} else {
- out.println(args[i]);
+ out.write(args[i]);
}
+ out.write(lineSeparator);
}
out.flush();
commandArray = new String[firstFileName + 1];
@@ -481,7 +483,7 @@
System.arraycopy(args, 0, commandArray, 0, firstFileName);
commandArray[firstFileName] = "@" + tmpFile;
} catch (IOException e) {
- throw new BuildException("Error creating temporary file",
+ throw new BuildException("Error creating temporary file: " + e,
e, location);
} finally {
FileUtils.close(out);
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org