anmolanmol1234 commented on code in PR #8212:
URL: https://github.com/apache/hadoop/pull/8212#discussion_r2740911106


##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystemStore.java:
##########
@@ -890,66 +905,79 @@ public AbfsInputStream openFileForRead(Path path,
       FileStatus fileStatus = parameters.map(OpenFileParameters::getStatus)
           .orElse(null);
       String relativePath = getRelativePath(path);
-      String resourceType, eTag;
-      long contentLength;
+      String resourceType, eTag = EMPTY_STRING;
+      long contentLength = 0;
       ContextEncryptionAdapter contextEncryptionAdapter = 
NoContextEncryptionAdapter.getInstance();
       /*
       * GetPathStatus API has to be called in case of:
-      *   1.  fileStatus is null or not an object of VersionedFileStatus: as 
eTag
-      *       would not be there in the fileStatus object.
+      *   1.  restrictGpsOnOpenFile config is disabled AND fileStatus is null 
or not
+      *       an object of VersionedFileStatus: as eTag would not be there in 
the fileStatus object.
       *   2.  fileStatus is an object of VersionedFileStatus and the object 
doesn't
       *       have encryptionContext field when client's encryptionType is
       *       ENCRYPTION_CONTEXT.
       */
       if ((fileStatus instanceof VersionedFileStatus) && (
-          getClient().getEncryptionType() != EncryptionType.ENCRYPTION_CONTEXT
-              || ((VersionedFileStatus) fileStatus).getEncryptionContext()
-              != null)) {
+              getClient().getEncryptionType() != 
EncryptionType.ENCRYPTION_CONTEXT
+                      || ((VersionedFileStatus) 
fileStatus).getEncryptionContext()
+                      != null)) {
         path = path.makeQualified(this.uri, path);
         Preconditions.checkArgument(fileStatus.getPath().equals(path),
-            String.format(
-                "Filestatus path [%s] does not match with given path [%s]",
-                fileStatus.getPath(), path));
+                String.format(
+                        "Filestatus path [%s] does not match with given path 
[%s]",
+                        fileStatus.getPath(), path));
         resourceType = fileStatus.isFile() ? FILE : DIRECTORY;
         contentLength = fileStatus.getLen();
         eTag = ((VersionedFileStatus) fileStatus).getVersion();
         final String encryptionContext
-            = ((VersionedFileStatus) fileStatus).getEncryptionContext();
+                = ((VersionedFileStatus) fileStatus).getEncryptionContext();
         if (getClient().getEncryptionType() == 
EncryptionType.ENCRYPTION_CONTEXT) {
           contextEncryptionAdapter = new ContextProviderEncryptionAdapter(
-              getClient().getEncryptionContextProvider(), 
getRelativePath(path),
-              encryptionContext.getBytes(StandardCharsets.UTF_8));
+                  getClient().getEncryptionContextProvider(), 
getRelativePath(path),
+                  encryptionContext.getBytes(StandardCharsets.UTF_8));
         }
-      } else {
+        if (parseIsDirectory(resourceType)) {

Review Comment:
   Can be moved to common part as is getting checked in both the cases



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