diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/sftp/SFTPFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/sftp/SFTPFileSystem.java index d91d3914077..6de69fa5e21 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/sftp/SFTPFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/sftp/SFTPFileSystem.java @@ -277,7 +277,7 @@ public class SFTPFileSystem extends FileSystem { // Using default block size since there is no way in SFTP channel to know of // block sizes on server. The assumption could be less than ideal. long blockSize = DEFAULT_BLOCK_SIZE; - long modTime = attr.getMTime() * 1000; // convert to milliseconds + long modTime = attr.getMTime() * 1000L; // convert to milliseconds long accessTime = attr.getATime() * 1000L; FsPermission permission = getPermissions(sftpFile); // not be able to get the real user group name, just use the user and group diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/sftp/TestSFTPFileSystem.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/sftp/TestSFTPFileSystem.java index 9b514e10e5c..3d57dabd86d 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/sftp/TestSFTPFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/sftp/TestSFTPFileSystem.java @@ -319,4 +319,13 @@ public class TestSFTPFileSystem { assertEquals(accessTime1, accessTime2); } + @Test + public void testGetModifyTime() throws IOException { + Path file = touch(localFs, name.getMethodName().toLowerCase() + "1"); + java.io.File localFile = ((LocalFileSystem) localFs).pathToFile(file); + long modifyTime1 = localFile.lastModified(); + long modifyTime2 = sftpFs.getFileStatus(file).getModificationTime(); + assertEquals(modifyTime1, modifyTime2); + } + }