commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] Commented: (IO-157) [FileUtils] Return target File from copyFileToDirectory()
Date Sun, 07 Mar 2010 13:21:27 GMT

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

Sebb commented on IO-157:
-------------------------

Sometimes what is obvious is not true ;-)

I decided to to test IO 2.0 with the test cases from IO 1.4.

Create the jars:

- mvn jar:test-jar in IO 1.4
- mvn jar:jar in IO 2.0

Then use JUnit command-line mode:

{code}
set CLASSPATH=junit-3.8.2.jar;commons-io-1.4-tests.jar;commons-io-2.0-SNAPSHOT.jar
java junit.textui.TestRunner org.apache.commons.io.FileUtilsTestCase
....
There were 2 errors:
1) testCopyFile1ToDir(org.apache.commons.io.FileUtilsTestCase)java.lang.NoSuchMethodError:

    org.apache.commons.io.FileUtils.copyFileToDirectory(Ljava/io/File;Ljava/io/File;)V
        at org.apache.commons.io.FileUtilsTestCase.testCopyFile1ToDir(FileUtilsTestCase.java:881)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2) testCopyFile2ToDir(org.apache.commons.io.FileUtilsTestCase)java.lang.NoSuchMethodError:

    org.apache.commons.io.FileUtils.copyFileToDirectory(Ljava/io/File;Ljava/io/File;)V
        at org.apache.commons.io.FileUtilsTestCase.testCopyFile2ToDir(FileUtilsTestCase.java:906)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
{code}

Oops!

The return type IS part of the signature that the JVM looks for when resolving method calls.

So the jar is clearly not a drop-in replacement for IO 1.4

Note: the same test ran fine with commons-io-1.4.jar (as expected).

However, the suggestion still has merit.

> [FileUtils] Return target File from copyFileToDirectory()
> ---------------------------------------------------------
>
>                 Key: IO-157
>                 URL: https://issues.apache.org/jira/browse/IO-157
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>    Affects Versions: 1.4
>            Reporter: Kenny MacLeod
>            Assignee: Niall Pemberton
>            Priority: Minor
>             Fix For: 2.0
>
>
> It would be useful if the FileUtils.copyFileToDirectory() method returned the target
file to which it does the copy.  Currently, it creates the target File object, passes it to
copyFile(), and discards the reference.  This could just be returned from the method instead.

-- 
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