Skip to content
This repository was archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
Revert "HADOOP-17306. RawLocalFileSystem's lastModifiedTime() looses …
Browse files Browse the repository at this point in the history
…milli seconds in JDK < 10.b09 (apache#2387)"

This reverts commit 553e27e.
  • Loading branch information
jbrennan333 committed Nov 5, 2020
1 parent fe53f58 commit a314873
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,7 @@ public class RawLocalFileSystem extends FileSystem {
public static void useStatIfAvailable() {
useDeprecatedFileStatus = !Stat.isAvailable();
}

@VisibleForTesting
static void setUseDeprecatedFileStatus(boolean useDeprecatedFileStatus) {
RawLocalFileSystem.useDeprecatedFileStatus = useDeprecatedFileStatus;
}


public RawLocalFileSystem() {
workingDir = getInitialWorkingDirectory();
}
Expand Down Expand Up @@ -698,8 +693,8 @@ private static long getLastAccessTime(File f) throws IOException {
DeprecatedRawLocalFileStatus(File f, long defaultBlockSize, FileSystem fs)
throws IOException {
super(f.length(), f.isDirectory(), 1, defaultBlockSize,
Files.getLastModifiedTime(f.toPath()).toMillis(),
getLastAccessTime(f),null, null, null,
f.lastModified(), getLastAccessTime(f),
null, null, null,
new Path(f.getPath()).makeQualified(fs.getUri(),
fs.getWorkingDirectory()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.apache.hadoop.fs;

import java.io.File;
import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.test.GenericTestUtils;
Expand Down Expand Up @@ -168,28 +167,4 @@ public void testPermission() throws Exception {
}
}

@Test
public void testMTimeAtime() throws IOException {
RawLocalFileSystem.setUseDeprecatedFileStatus(true);
try {
Path testDir = getTestBaseDir();
String testFilename = "testmtime";
Path path = new Path(testDir, testFilename);
Path file = new Path(path, "file");
fs.create(file);
long now = System.currentTimeMillis();
long mtime = (now % 1000 == 0) ? now + 1 : now;
long atime = (now % 1000 == 0) ? now + 2 : now;
fs.setTimes(file, mtime, atime);
FileStatus fileStatus = fs.getFileStatus(file);
if (!Shell.MAC) {
// HADOOP-17306 ; Skip MacOS because HFS+ does not support
// milliseconds for mtime.
assertEquals(mtime, fileStatus.getModificationTime());
}
assertEquals(atime, fileStatus.getAccessTime());
} finally {
RawLocalFileSystem.useStatIfAvailable();
}
}
}

0 comments on commit a314873

Please sign in to comment.