You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2011/06/19 12:34:48 UTC

[jira] [Commented] (FTPSERVER-375) [FindBugs] NativeFtpFile implements equals(), but does not - hashCode()

    [ https://issues.apache.org/jira/browse/FTPSERVER-375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13051666#comment-13051666 ] 

Sebb commented on FTPSERVER-375:
--------------------------------

file.getCanonicalPath().hashCode() would do just as well here and in equals(), and avoids creating the File object.

However, both of these methods may involve file access, so may be slow.

Also, the canonical name may depend on whether the file exists or not - see the Javadoc [1]

Seems risky to me to use a base for the hashcode which may vary.

As the originator wrote - does the class need an equals() method?

[1] http://download.oracle.com/javase/6/docs/api/java/io/File.html#getCanonicalPath()

> [FindBugs] NativeFtpFile implements equals(), but does not - hashCode()
> -----------------------------------------------------------------------
>
>                 Key: FTPSERVER-375
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-375
>             Project: FtpServer
>          Issue Type: Wish
>          Components: Core
>            Reporter: Sergey Vladimirov
>            Priority: Minor
>              Labels: equality, findbugs
>             Fix For: 1.0.6, 1.1.0
>
>
> In fact, i can't find why it need to implement equals() in first place. If for any map - then hashCode() will also be required. For example, this.file.getCanonicalFile().hashCode()
> Anyway, could we please have a comment why do we need equals() method? :)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira