pgaref commented on a change in pull request #1161:
URL: https://github.com/apache/hive/pull/1161#discussion_r451489258



##########
File path: common/src/java/org/apache/hadoop/hive/conf/Validator.java
##########
@@ -357,14 +357,15 @@ public String validate(String value) {
       final Path path = FileSystems.getDefault().getPath(value);
       if (path == null && value != null) {
         return String.format("Path '%s' provided could not be located.", 
value);
-      }
-      final boolean isDir = Files.isDirectory(path);
-      final boolean isWritable = Files.isWritable(path);
-      if (!isDir) {
-        return String.format("Path '%s' provided is not a directory.", value);
-      }
-      if (!isWritable) {
-        return String.format("Path '%s' provided is not writable.", value);
+      } else if (path != null) {
+        final boolean isDir = Files.isDirectory(path);
+        final boolean isWritable = Files.isWritable(path);
+        if (!isDir) {
+          return String.format("Path '%s' provided is not a directory.", 
value);
+        }
+        if (!isWritable) {
+          return String.format("Path '%s' provided is not writable.", value);
+        }
       }
       return null;

Review comment:
       Refactored the code to return early when the argument is actually null, 
the following logic is now simplified to Null and non null path




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