Bug 54393

Summary: FixCRLF is not creating unique file names
Product: Ant Reporter: Jan Stolze <jan.stolze>
Component: Core tasksAssignee: Ant Notifications List <notifications>
Status: RESOLVED FIXED    
Severity: normal CC: jglick
Priority: P2 Keywords: PatchAvailable
Version: 1.7.1   
Target Milestone: 1.9.3   
Hardware: PC   
OS: Windows XP   
Attachments: Patched version

Description Jan Stolze 2013-01-09 12:22:31 UTC
FixCRLF is not creating unique file names, which gives complication when building several projects at the same time, like we do using Hudson. 

Proposed fix in FixCRLF file should be:

The 
private void processFile(String file) throws BuildException
method should use the following call on FILE_UTILS.createTempFile:

File tmpFile = FILE_UTILS.createTempFile("fixcrlf", "", null, true, true);

so last argument changed into true here, which causes Java to create a unique temporary file.
Comment 1 Jan Stolze 2013-01-10 08:49:43 UTC
Another change has to be made as well in the same method namely the following:

FILE_UTILS.copyFile(srcFile,
  		    tmpFile,
		    null,
		    fcv,
		    true,
		    false,
		    encoding,
		    outputEncoding == null ? encoding : outputEncoding,
		    getProject());

here the first boolean argument has changed from false to true in order to override the temporary file with the contents of the src file.
Comment 2 Jesse Glick 2013-01-10 16:49:50 UTC
By the way actual patches (diff -u format) are preferred to verbal descriptions of what you would change.
Comment 3 Jan Stolze 2013-01-11 06:33:01 UTC
Index: FixCRLF.java
===================================================================
--- FixCRLF.java	(revision 1431908)
+++ FixCRLF.java	(working copy)
@@ -352,9 +352,9 @@
             fcv = new Vector<FilterChain>(1);
             fcv.add(fc);
         }
-        File tmpFile = FILE_UTILS.createTempFile("fixcrlf", "", null, true, false);
+        File tmpFile = FILE_UTILS.createTempFile("fixcrlf", "", null, true, true);
         try {
-            FILE_UTILS.copyFile(srcFile, tmpFile, null, fcv, false, false,
+            FILE_UTILS.copyFile(srcFile, tmpFile, null, fcv, true, false,
                 encoding, outputEncoding == null ? encoding : outputEncoding,
                 getProject());
Comment 4 Jan Stolze 2013-01-11 06:36:34 UTC
Created attachment 29845 [details]
Patched version
Comment 5 Stefan Bodewig 2013-09-20 18:23:23 UTC
patch applied with svn revision 1525078, thanks