anmolanmol1234 commented on code in PR #8212:
URL: https://github.com/apache/hadoop/pull/8212#discussion_r2741002477
##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsInputStream.java:
##########
@@ -561,11 +578,55 @@ protected int readInternal(final long position, final
byte[] b, final int offset
}
}
+ String getRelativePath(final Path path) {
+ Preconditions.checkNotNull(path, "path");
+ String relPath = path.toUri().getPath();
+ if (relPath.isEmpty()) {
+ // This means that path passed by user is absolute path of root without
"/" at end.
+ relPath = ROOT_PATH;
+ }
+ return relPath;
+ }
+
+ /**
+ * Creates an exception indicating that a read operation was attempted on a
directory.
+ *
+ * @return an {@link AbfsRestOperationException} indicating the operation is
not permitted on a directory
+ */
+ private IOException directoryReadException() {
+ return new AbfsRestOperationException(
+ AzureServiceErrorCode.PATH_NOT_FOUND.getStatusCode(),
+ AzureServiceErrorCode.PATH_NOT_FOUND.getErrorCode(),
+ readOnDirectoryErrorMsg,
+ null);
+ }
+
+ /**
+ * Checks if the current path is a directory (for both implicit and
explicit) in FNS account.
+ * If the path is a directory, throws an exception indicating that read
operations are not permitted.
+ *
+ * @throws IOException if the path is a directory or if there is an error
accessing the path status
+ */
+ private void checkIfDirPathInFNS() throws IOException {
+ AbfsHttpOperation gpsOp = client.getPathStatus(
+ getRelativePath(new Path(path)),
+ false,
+ tracingContext,
+ contextEncryptionAdapter).getResult();
+
+ String resourceType =
Review Comment:
use client.checkIsDir method which handles null case as well
--
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]