HADOOP-17801. No error message reported when bucket doesn't exist in S3AFS (#3202)

Contributed by: Mehakmeet Singh.

Change-Id: I26c2a85ef6bbfd1b8269a23fc44d9a55d7fa091c
This commit is contained in:
Mehakmeet Singh 2021-07-16 19:57:00 +05:30 committed by Steve Loughran
parent cd15b0cb8a
commit 14a3e74c5c
No known key found for this signature in database
GPG Key ID: D22CF846DBB162A0
4 changed files with 25 additions and 15 deletions

View File

@ -681,7 +681,8 @@ public class S3AFileSystem extends FileSystem implements StreamCapabilities,
trackDurationOfOperation(getDurationTrackerFactory(),
STORE_EXISTS_PROBE.getSymbol(),
() -> s3.doesBucketExist(bucket)))) {
throw new UnknownStoreException("Bucket " + bucket + " does not exist");
throw new UnknownStoreException("s3a://" + bucket + "/", " Bucket does "
+ "not exist");
}
}
@ -699,7 +700,8 @@ public class S3AFileSystem extends FileSystem implements StreamCapabilities,
trackDurationOfOperation(getDurationTrackerFactory(),
STORE_EXISTS_PROBE.getSymbol(),
() -> s3.doesBucketExistV2(bucket)))) {
throw new UnknownStoreException("Bucket " + bucket + " does not exist");
throw new UnknownStoreException("s3a://" + bucket + "/", " Bucket does "
+ "not exist");
}
}

View File

@ -254,7 +254,7 @@ public final class S3AUtils {
case 404:
if (isUnknownBucket(ase)) {
// this is a missing bucket
ioe = new UnknownStoreException(path, ase);
ioe = new UnknownStoreException(path, message, ase);
} else {
// a normal unknown object
ioe = new FileNotFoundException(message);

View File

@ -18,10 +18,9 @@
package org.apache.hadoop.fs.s3a;
import java.io.IOException;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.fs.PathIOException;
/**
* The bucket or other AWS resource is unknown.
@ -33,23 +32,28 @@ import org.apache.hadoop.classification.InterfaceStability;
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
public class UnknownStoreException extends IOException {
public class UnknownStoreException extends PathIOException {
/**
* Constructor.
* @param message message
*
* @param path path trying to access.
* @param message message.
*/
public UnknownStoreException(final String message) {
this(message, null);
public UnknownStoreException(final String path, final String message) {
this(path, message, null);
}
/**
* Constructor.
* @param message message
* @param cause cause (may be null)
*
* @param path path trying to access.
* @param message message.
* @param cause cause (may be null).
*/
public UnknownStoreException(final String message, Throwable cause) {
super(message);
public UnknownStoreException(String path, final String message,
Throwable cause) {
super(path, message);
if (cause != null) {
initCause(cause);
}

View File

@ -181,8 +181,12 @@ public class TestS3AExceptionTranslation {
private static <E extends Throwable> E verifyTranslated(Class<E> clazz,
AmazonClientException exception) throws Exception {
return verifyExceptionClass(clazz,
translateException("test", "/", exception));
// Verifying that the translated exception have the correct error message.
IOException ioe = translateException("test", "/", exception);
assertExceptionContains(exception.getMessage(), ioe,
"Translated Exception should contain the error message of the "
+ "actual exception");
return verifyExceptionClass(clazz, ioe);
}
private void assertContainsInterrupted(boolean expected, Throwable thrown)