commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gwenaël Le Roux (JIRA) <j...@apache.org>
Subject [jira] Issue Comment Edited: (IO-217) FileUtils.copyDirectoryToDirectory makes infinite loops
Date Sat, 07 Aug 2010 10:58:15 GMT

    [ https://issues.apache.org/jira/browse/IO-217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12896245#action_12896245
] 

Gwenaël Le Roux edited comment on IO-217 at 8/7/10 6:57 AM:
------------------------------------------------------------

This issue is not reproduced on revision 982449 (trunk). An exception is throwned because
the source and the target directories are the same, and no infinite loop is run. 
The aim of this issue (ie throwing an exception or creating a directory D:\a\a as required)
should be precised by project leaders.

The following code extract is testing the new execution.

    public void testCopyDirectoryToItself() throws Exception {
        File sourceDir = new File(getTestDirectory(), "source");
        if (!sourceDir.exists())
            sourceDir.mkdirs();

        File childDir = new File(sourceDir, "child");
        if (!childDir.exists())
            childDir.mkdirs();
        File file = new File(sourceDir, "file");
        createFile(file, 12345);

        try {
            FileUtils.copyDirectory(sourceDir, sourceDir);
            fail();
        } catch( IOException ex) {          
        }
    }

Hope this could help.


      was (Author: gwen):
    This issue is not reproduced on revision 982449 (trunk). An exception is throwned because
the source and the target directories are the same, and no infinite loop is run. 
The aim of this issue (ie throwing an exception or creating a directory D:\a\a as required)
should be precised by project leaders.

The following code extract is testing the new execution.

    /**
     * Test for IO-217
     */
    public void testCopyDirectoryToItself() throws Exception {
        File sourceDir = new File(getTestDirectory(), "source");
        if (!sourceDir.exists())
            sourceDir.mkdirs();

        File childDir = new File(sourceDir, "child");
        if (!childDir.exists())
            childDir.mkdirs();
        File file = new File(sourceDir, "file");
        createFile(file, 12345);

        try {
            FileUtils.copyDirectory(sourceDir, sourceDir);
            fail();
        } catch( IOException ex) {          
        }
    }

Hope this could help.

  
> FileUtils.copyDirectoryToDirectory makes infinite loops
> -------------------------------------------------------
>
>                 Key: IO-217
>                 URL: https://issues.apache.org/jira/browse/IO-217
>             Project: Commons IO
>          Issue Type: Bug
>    Affects Versions: 1.4
>         Environment: Windows XP
>            Reporter: tora yamada
>             Fix For: 2.0
>
>
> When using FileUtils.copyDirectoryToDirectory, infinite loops has occurred.
> -- detail --
> src directory :  D:\a
> dest directory : D:\a
> call : FileUtils.copyDirectoryToDirectory(new File("D:\a"), new File("D:\a"));
> expected result : directory D:\a\a will be created
> actual result      : D:\a\a\a\a.......   was created
> i guess FileUtils.copyDirectoryToDirectory causes of this result.
> ("destDir.mkdir()" is done before "srcDir.listFiles()")
> am i calling wrong method?
> thank you.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message