steveloughran commented on code in PR #7312:
URL: https://github.com/apache/hadoop/pull/7312#discussion_r1926796422
##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/contracts/services/AzureServiceErrorCode.java:
##########
@@ -58,7 +58,8 @@ public enum AzureServiceErrorCode {
ACCOUNT_REQUIRES_HTTPS("AccountRequiresHttps",
HttpURLConnection.HTTP_BAD_REQUEST, null),
MD5_MISMATCH("Md5Mismatch", HttpURLConnection.HTTP_BAD_REQUEST,
"The MD5 value specified in the request did not match with the MD5
value calculated by the server."),
- UNKNOWN(null, -1, null);
+ UNKNOWN(null, -1, null),
+ UNAUTHORIZED_BLOB_OVERWRITE("UnauthorizedBlobOverwrite",
HttpURLConnection.HTTP_FORBIDDEN, "This request is not authorized to perform
blob overwrites.");
Review Comment:
nit: split the line with the text on the line below
##########
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsDfsClient.java:
##########
@@ -613,6 +615,11 @@ public AbfsClientRenameResult renamePath(
throw e;
}
+ if(op.getResult().getStorageErrorCode()
+ .equals(UNAUTHORIZED_BLOB_OVERWRITE.getErrorCode())){
+ throw new FileAlreadyExistsException("File already exists.");
Review Comment:
Can you add a comment explaining why, e.g
```
Write permission checks can happen before probes for validity
of the operation -if there is a path at the destination
it may be rejected with a authorization failure.
Catch and translate. See HADOOP-19393.
```
##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemDelegationSAS.java:
##########
@@ -213,6 +214,24 @@ public void testReadAndWrite() throws Exception {
}
}
+ @Test
+ public void checkExceptionForRenameOverwrites() throws Exception {
+ final AzureBlobFileSystem fs = getFileSystem();
+
+ Path src = new Path("a/b/f1.txt");
+ Path dest = new Path("a/b/f2.txt");
+ touch(src);
+ touch(dest);
+
+ try {
Review Comment:
use LambdaTestUtils.intercept, e.g
```
intercept(FileAlreadyExistsException.class, () -> fs.rename(src, dest));
```
--
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]