smengcl commented on a change in pull request #1270: HDFS-14718. HttpFS: Sort 
response by key names as WebHDFS does
URL: https://github.com/apache/hadoop/pull/1270#discussion_r313218951
 
 

 ##########
 File path: 
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/FSOperations.java
 ##########
 @@ -280,14 +279,14 @@ private static Map contentSummaryToJSON(ContentSummary 
contentSummary) {
    */
   @SuppressWarnings({"unchecked"})
   private static Map quotaUsageToJSON(QuotaUsage quotaUsage) {
-    Map response = new LinkedHashMap();
+    Map response = new TreeMap();
     Map quotaUsageMap = quotaUsageToMap(quotaUsage);
     response.put(HttpFSFileSystem.QUOTA_USAGE_JSON, quotaUsageMap);
     return response;
   }
 
   private static Map<String, Object> quotaUsageToMap(QuotaUsage quotaUsage) {
-    Map<String, Object> result = new LinkedHashMap<>();
+    Map<String, Object> result = new TreeMap<>();
 
 Review comment:
   I haven't found any existing unit tests that compares the order of the 
response JSON of WebHDFS and HttpFS. e.g. `BaseTestHttpFSWith#testQuotaUsage` 
checks the the correctness of output from DFS/HttpFS but doesn't care about the 
order.
   That might be something we want to do with a new unit test class. Or is 
there one test class that does this already?
   
   Initially I was just looking at output for LISTSTATUS. I discovered that 
WebHDFS responds with sorted keys, but HttpFS doesn't. Then I found other 
responses from HttpFS also aren't sorted but WebHDFS does. So I extended the 
scope of this jira.

----------------------------------------------------------------
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]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to