ayushtkn commented on a change in pull request #2166:
URL: https://github.com/apache/hadoop/pull/2166#discussion_r459707469



##########
File path: 
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java
##########
@@ -471,7 +473,35 @@ public void write(DataOutput out) throws IOException {
     return statusList.toArray(
         new SnapshottableDirectoryStatus[statusList.size()]);
   }
-  
+
+  /**
+   * List all the snapshots under a snapshottable directory.
+   */
+  public SnapshotStatus[] getSnapshotListing(INodesInPath iip)
+      throws IOException {
+    INodeDirectory srcRoot = getSnapshottableRoot(iip);
+    ReadOnlyList<Snapshot> snapshotList = 
srcRoot.getDirectorySnapshottableFeature().
+        getSnapshotList();
+    if (snapshotList.isEmpty()) {
+      return null;

Review comment:
       Do you want to pass `null`, if there is no snapshots, Can't we pass an 
empty list?
   It might create problem for some client checking the size of the array to 
conclude if there are snapshots or not or performing directly some operations 
without being too smart of having a null check, his code would break will a 
NPE. If there is no strong opposition, we may pass an empty array, I think, but 
I will keep the ball in your court




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



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

Reply via email to