Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.4.6
-
Labels:None
-
Environment:plexus-utils 1.0.4
-
Testcase included:yes
-
Number of attachments :
Description
Using copyFile zeros out the file is the source file is the same as destination file.
To reproduce, runs the following test case:
public void testCopyFileOnSameFile() throws IOException { String content= "ggrgreeeeeeeeeeeeeeeeeeeeeeeoierjgioejrgiojregioejrgufcdxivbsdibgfizgerfyaezgv!zeez"; final File theFile = File.createTempFile( "test", ".txt"); FileUtils.fileAppend( theFile.getAbsolutePath(), content); assertTrue( theFile.length() > 0); // Now copy file over itself FileUtils.copyFile( theFile, theFile); // This should not fail assertTrue( theFile.length() > 0); }
Expected behavior is to do nothing and leave the file as it is.
Issue Links
- is related to
-
MEAR-49
if an artifact in the list of ear modules already exists in the ear, the ear mojo will copy it on top of itself, zeroing out the file
-
Added check to FileUtils.copyFile( final File source, final File destination ) to see if source == destination.
Added test to FileUtilsTest named testCopyFileOnSameFile().
Before the check was added, the test fails. Afterwards, the test passes.