xBis7 commented on code in PR #3746:
URL: https://github.com/apache/ozone/pull/3746#discussion_r984671077


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/handlers/DirectoryEntityHandler.java:
##########
@@ -89,7 +91,15 @@ public DUResponse getDuResponse(
     for (long subdirObjectId: subdirs) {
       NSSummary subdirNSSummary =
               getReconNamespaceSummaryManager().getNSSummary(subdirObjectId);
-      String subdirName = subdirNSSummary.getDirName();
+      // for the subdirName we need the filename, not the key name
+      Path subdirPath = Paths.get(subdirNSSummary.getDirName());
+      Path subdirFileName = subdirPath.getFileName();
+      String subdirName;
+      if (subdirFileName != null) {
+        subdirName = subdirFileName.toString();
+      } else {
+        throw new NullPointerException("Subdirectory file name is null.");
+      }

Review Comment:
   I added the null check to get rid of a `findbugs` error but I also didn't 
want to consume the NPT exception. I can change the exception type to 
`IOException`.
   
   ```
   M D NP: Possible null pointer dereference in 
org.apache.hadoop.ozone.recon.api.handlers.DirectoryEntityHandler.getDuResponse(boolean,
 boolean) due to return value of called method  Dereferenced at 
DirectoryEntityHandler.java:[line 102]
   ```



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

To unsubscribe, e-mail: [email protected]

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