saxenapranav commented on code in PR #6699: URL: https://github.com/apache/hadoop/pull/6699#discussion_r1683878338
########## hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystemStore.java: ########## @@ -890,32 +891,37 @@ public AbfsInputStream openFileForRead(Path path, encryptionContext.getBytes(StandardCharsets.UTF_8)); } } else { - AbfsHttpOperation op = client.getPathStatus(relativePath, false, - tracingContext, null).getResult(); - resourceType = op.getResponseHeader( - HttpHeaderConfigurations.X_MS_RESOURCE_TYPE); - contentLength = Long.parseLong( - op.getResponseHeader(HttpHeaderConfigurations.CONTENT_LENGTH)); - eTag = op.getResponseHeader(HttpHeaderConfigurations.ETAG); - /* - * For file created with ENCRYPTION_CONTEXT, client shall receive - * encryptionContext from header field: X_MS_ENCRYPTION_CONTEXT. - */ - if (client.getEncryptionType() == EncryptionType.ENCRYPTION_CONTEXT) { - final String fileEncryptionContext = op.getResponseHeader( - HttpHeaderConfigurations.X_MS_ENCRYPTION_CONTEXT); - if (fileEncryptionContext == null) { - LOG.debug("EncryptionContext missing in GetPathStatus response"); - throw new PathIOException(path.toString(), - "EncryptionContext not present in GetPathStatus response headers"); + if (client.getEncryptionType() == EncryptionType.ENCRYPTION_CONTEXT Review Comment: I completely understand that logic has become bit messy and not easy to read. Have refactored the logic. Hope the new logic is more readable and understandable: ``` if (fileStatus instanceof VersionedFileStatus) { VersionedFileStatus versionedFileStatus = (VersionedFileStatus) fileStatus; path = path.makeQualified(this.uri, path); Preconditions.checkArgument(fileStatus.getPath().equals(path), "Filestatus path [%s] does not match with given path [%s]", fileStatus.getPath(), path); resourceType = fileStatus.isFile() ? FILE : DIRECTORY; contentLength = fileStatus.getLen(); eTag = versionedFileStatus.getVersion(); encryptionContext = versionedFileStatus.getEncryptionContext(); } if (client.getEncryptionType() == EncryptionType.ENCRYPTION_CONTEXT) { if (encryptionContext == null) { PathInformation pathInformation = getPathInformation(relativePath, tracingContext); resourceType = pathInformation.getResourceType(); contentLength = Long.parseLong(pathInformation.getContentLength()); eTag = pathInformation.getETag(); encryptionContext = pathInformation.getEncryptionContext(); if (encryptionContext == null) { LOG.debug("EncryptionContext missing in GetPathStatus response"); throw new PathIOException(path.toString(), "EncryptionContext not present in GetPathStatus response headers"); } } contextEncryptionAdapter = new ContextProviderEncryptionAdapter( client.getEncryptionContextProvider(), getRelativePath(path), encryptionContext.getBytes(StandardCharsets.UTF_8)); } else if (fileStatus == null && !abfsConfiguration.isInputStreamLazyOptimizationEnabled()) { PathInformation pathInformation = getPathInformation(relativePath, tracingContext); resourceType = pathInformation.getResourceType(); contentLength = Long.parseLong(pathInformation.getContentLength()); eTag = pathInformation.getETag(); } if (parseIsDirectory(resourceType)) { throw new AbfsRestOperationException( AzureServiceErrorCode.PATH_NOT_FOUND.getStatusCode(), AzureServiceErrorCode.PATH_NOT_FOUND.getErrorCode(), "openFileForRead must be used with files and not directories", null); } ``` -- 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: common-issues-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org