HADOOP-16479. ABFS FileStatus.getModificationTime returns localized time instead of UTC.

Contributed by Bilahari T H

Change-Id: I532055baaadfd7c324710e4b25f60cdf0378bdc0
This commit is contained in:
bilaharith 2019-08-08 19:08:04 +01:00 committed by Thomas Marquardt
parent ce23e971b4
commit 3b3c0c4b87
2 changed files with 19 additions and 1 deletions

View File

@ -115,7 +115,7 @@ public class AzureBlobFileSystemStore {
private URI uri; private URI uri;
private String userName; private String userName;
private String primaryUserGroup; private String primaryUserGroup;
private static final String DATE_TIME_PATTERN = "E, dd MMM yyyy HH:mm:ss 'GMT'"; private static final String DATE_TIME_PATTERN = "E, dd MMM yyyy HH:mm:ss z";
private static final String TOKEN_DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"; private static final String TOKEN_DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'";
private static final String XMS_PROPERTIES_ENCODING = "ISO-8859-1"; private static final String XMS_PROPERTIES_ENCODING = "ISO-8859-1";
private static final int LIST_MAX_RESULTS = 500; private static final int LIST_MAX_RESULTS = 500;

View File

@ -122,4 +122,22 @@ public class ITestAzureBlobFileSystemFileStatus extends
assertEquals(pathWithHost2.getName(), fileStatus2.getPath().getName()); assertEquals(pathWithHost2.getName(), fileStatus2.getPath().getName());
} }
@Test
public void testLastModifiedTime() throws IOException {
AzureBlobFileSystem fs = this.getFileSystem();
Path testFilePath = new Path("childfile1.txt");
long createStartTime = System.currentTimeMillis();
long minCreateStartTime = (createStartTime / 1000) * 1000 - 1;
// Dividing and multiplying by 1000 to make last 3 digits 0.
// It is observed that modification time is returned with last 3
// digits 0 always.
fs.create(testFilePath);
long createEndTime = System.currentTimeMillis();
FileStatus fStat = fs.getFileStatus(testFilePath);
long lastModifiedTime = fStat.getModificationTime();
assertTrue("lastModifiedTime should be after minCreateStartTime",
minCreateStartTime < lastModifiedTime);
assertTrue("lastModifiedTime should be before createEndTime",
createEndTime > lastModifiedTime);
}
} }