From 3b3c0c4b8790ec4c96072a4704b320812296074b Mon Sep 17 00:00:00 2001
From: bilaharith
Date: Thu, 8 Aug 2019 19:08:04 +0100
Subject: [PATCH] HADOOP-16479. ABFS FileStatus.getModificationTime returns
localized time instead of UTC.
Contributed by Bilahari T H
Change-Id: I532055baaadfd7c324710e4b25f60cdf0378bdc0
---
.../fs/azurebfs/AzureBlobFileSystemStore.java | 2 +-
.../ITestAzureBlobFileSystemFileStatus.java | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystemStore.java b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystemStore.java
index 06a819ac69f..ce0d4112c84 100644
--- a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystemStore.java
+++ b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystemStore.java
@@ -115,7 +115,7 @@ public class AzureBlobFileSystemStore {
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;
diff --git a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemFileStatus.java b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemFileStatus.java
index f5146963304..421fa9a65cc 100644
--- a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemFileStatus.java
+++ b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemFileStatus.java
@@ -122,4 +122,22 @@ public class ITestAzureBlobFileSystemFileStatus extends
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);
+ }
}