You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by ng...@apache.org on 2013/08/12 00:16:37 UTC

[42/50] [abbrv] git commit: FTPSERVER-375 - use canonicalPath rather than File to implement equals and hashcode

FTPSERVER-375 - use canonicalPath rather than File to implement equals and hashcode

git-svn-id: https://svn.apache.org/repos/asf/mina/ftpserver/trunk@1138635 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/mina-ftpserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-ftpserver/commit/46484938
Tree: http://git-wip-us.apache.org/repos/asf/mina-ftpserver/tree/46484938
Diff: http://git-wip-us.apache.org/repos/asf/mina-ftpserver/diff/46484938

Branch: refs/heads/trunk
Commit: 46484938383bf5a78dc9f5311d2e926f6f4e1860
Parents: 25e4d86
Author: Sebastian Bazley <se...@apache.org>
Authored: Wed Jun 22 21:08:23 2011 +0000
Committer: Sebastian Bazley <se...@apache.org>
Committed: Wed Jun 22 21:08:23 2011 +0000

----------------------------------------------------------------------
 .../filesystem/nativefs/impl/NativeFtpFile.java   | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-ftpserver/blob/46484938/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/impl/NativeFtpFile.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/impl/NativeFtpFile.java b/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/impl/NativeFtpFile.java
index 4052ff6..3d1bf3c 100644
--- a/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/impl/NativeFtpFile.java
+++ b/core/src/main/java/org/apache/ftpserver/filesystem/nativefs/impl/NativeFtpFile.java
@@ -394,21 +394,25 @@ public class NativeFtpFile implements FtpFile {
         };
     }
 
+    /**
+     * 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 FtpFile {
 	@Override
 	public int hashCode() {
 		try {
-			return file.getCanonicalFile().hashCode();
+			return file.getCanonicalPath().hashCode();
 		} catch (IOException e) {
 			return 0;
 		}