[
https://issues.apache.org/jira/browse/HADOOP-17306?focusedWorklogId=502003&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-502003
]
ASF GitHub Bot logged work on HADOOP-17306:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 19/Oct/20 05:25
Start Date: 19/Oct/20 05:25
Worklog Time Spent: 10m
Work Description: aajisaka commented on a change in pull request #2387:
URL: https://github.com/apache/hadoop/pull/2387#discussion_r507473450
##########
File path:
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestRawLocalFileSystemContract.java
##########
@@ -203,4 +203,27 @@ 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 ; JDK-8177809 not fixed in MacOs
+ assertEquals(mtime, fileStatus.getModificationTime());
Review comment:
HFS+ does not support milliseconds for mtime, so we have to skip this.
In contrast, APFS supports nanoseconds and JDK-8177809 is fixed if the
filesystem is APFS.
```
➜ hadoop git:(trunk) uname -a
Darwin <snip> 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT
2020; root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64
➜ hadoop git:(trunk) jshell
| Welcome to JShell -- Version 11.0.8
| For an introduction type: /help intro
jshell> Files.getLastModifiedTime(Paths.get("./pom.xml"))
$1 ==> 2020-10-19T04:51:58.69531Z
jshell> new File("./pom.xml").lastModified()
$1 ==> 1603083118695
```
Would you update the comment like "Skip MacOS because HFS+ does not support
milliseconds for mtime." ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 502003)
Time Spent: 50m (was: 40m)
> RawLocalFileSystem's lastModifiedTime() looses milli seconds in JDK < 10.b09
> ----------------------------------------------------------------------------
>
> Key: HADOOP-17306
> URL: https://issues.apache.org/jira/browse/HADOOP-17306
> Project: Hadoop Common
> Issue Type: Bug
> Components: fs
> Reporter: Vinayakumar B
> Assignee: Vinayakumar B
> Priority: Major
> Labels: pull-request-available
> Time Spent: 50m
> Remaining Estimate: 0h
>
> RawLocalFileSystem's FileStatus uses {{File.lastModified()}} api from JDK.
> This api looses milliseconds due to JDK bug.
> [https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8177809]
> This bug fixed in JDK 10 b09 onwards and still exists in JDK 8 which is still
> being used in many productions.
> Apparently, {{Files.getLastModifiedTime()}} from java's nio package returns
> correct time.
> Use {{Files.getLastModifiedTime()}} instead of {{File.lastModified}} as
> workaround.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]