Bug 54393 - FixCRLF is not creating unique file names
Summary: FixCRLF is not creating unique file names
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.7.1
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: 1.9.3
Assignee: Ant Notifications List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2013-01-09 12:22 UTC by Jan Stolze
Modified: 2013-09-20 18:23 UTC (History)
1 user (show)



Attachments
Patched version (22.21 KB, application/octet-stream)
2013-01-11 06:36 UTC, Jan Stolze
Details

Note You need to log in before you can comment on or make changes to this bug.
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