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:
parent
cd15b0cb8a
commit
14a3e74c5c
@ -681,7 +681,8 @@ protected void verifyBucketExists()
|
||||
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 @@ protected void verifyBucketExistsV2()
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ public static IOException translateException(@Nullable String operation,
|
||||
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);
|
||||
|
@ -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 @@
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
|
@ -181,8 +181,12 @@ private static AmazonS3Exception createS3Exception(String message, int code,
|
||||
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user