You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by se...@apache.org on 2011/06/22 23:08:23 UTC

svn commit: r1138635 - /mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/impl/NativeFtpFile.java

Author: sebb
Date: Wed Jun 22 21:08:23 2011
New Revision: 1138635

URL: http://svn.apache.org/viewvc?rev=1138635&view=rev
Log:
FTPSERVER-375 - use canonicalPath rather than File to implement equals and hashcode

Modified:
    mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/impl/NativeFtpFile.java

Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/impl/NativeFtpFile.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/impl/NativeFtpFile.java?rev=1138635&r1=1138634&r2=1138635&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/impl/NativeFtpFile.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/impl/NativeFtpFile.java Wed Jun 22 21:08:23 2011
@@ -394,21 +394,25 @@ public class NativeFtpFile implements Ft
         };
     }
 
+    /**
+     * Implements equals by comparing getCanonicalPath() for the underlying file instabnce.
+     * Ignores the fileName and User fields
+     */
     @Override
     public boolean equals(Object obj) {
         if (obj instanceof NativeFtpFile) {
-            File thisCanonicalFile;
-            File otherCanonicalFile;
+            String thisCanonicalPath;
+            String otherCanonicalPath;
             try {
-                thisCanonicalFile = this.file.getCanonicalFile();
-                otherCanonicalFile = ((NativeFtpFile) obj).file
-                        .getCanonicalFile();
+                thisCanonicalPath = this.file.getCanonicalPath();
+                otherCanonicalPath = ((NativeFtpFile) obj).file
+                        .getCanonicalPath();
             } catch (IOException e) {
                 throw new RuntimeException("Failed to get the canonical path",
                         e);
             }
 
-            return thisCanonicalFile.equals(otherCanonicalFile);
+            return thisCanonicalPath.equals(otherCanonicalPath);
         }
         return false;
     }
@@ -416,7 +420,7 @@ public class NativeFtpFile implements Ft
 	@Override
 	public int hashCode() {
 		try {
-			return file.getCanonicalFile().hashCode();
+			return file.getCanonicalPath().hashCode();
 		} catch (IOException e) {
 			return 0;
 		}