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 Steve Loughran
parent 3ac0f3a0c1
commit 5840df86d7
No known key found for this signature in database
GPG Key ID: D22CF846DBB162A0
2 changed files with 19 additions and 1 deletions

View File

@ -118,7 +118,7 @@ public class AzureBlobFileSystemStore implements Closeable {
private URI uri;
private String userName;
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 XMS_PROPERTIES_ENCODING = "ISO-8859-1";
private static final int LIST_MAX_RESULTS = 500;

View File

@ -122,4 +122,22 @@ public void testAbfsPathWithHost() throws IOException {
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);
}
}