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(),
|
trackDurationOfOperation(getDurationTrackerFactory(),
|
||||||
STORE_EXISTS_PROBE.getSymbol(),
|
STORE_EXISTS_PROBE.getSymbol(),
|
||||||
() -> s3.doesBucketExist(bucket)))) {
|
() -> 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(),
|
trackDurationOfOperation(getDurationTrackerFactory(),
|
||||||
STORE_EXISTS_PROBE.getSymbol(),
|
STORE_EXISTS_PROBE.getSymbol(),
|
||||||
() -> s3.doesBucketExistV2(bucket)))) {
|
() -> 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:
|
case 404:
|
||||||
if (isUnknownBucket(ase)) {
|
if (isUnknownBucket(ase)) {
|
||||||
// this is a missing bucket
|
// this is a missing bucket
|
||||||
ioe = new UnknownStoreException(path, ase);
|
ioe = new UnknownStoreException(path, message, ase);
|
||||||
} else {
|
} else {
|
||||||
// a normal unknown object
|
// a normal unknown object
|
||||||
ioe = new FileNotFoundException(message);
|
ioe = new FileNotFoundException(message);
|
||||||
|
@ -18,10 +18,9 @@
|
|||||||
|
|
||||||
package org.apache.hadoop.fs.s3a;
|
package org.apache.hadoop.fs.s3a;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.classification.InterfaceStability;
|
import org.apache.hadoop.classification.InterfaceStability;
|
||||||
|
import org.apache.hadoop.fs.PathIOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The bucket or other AWS resource is unknown.
|
* The bucket or other AWS resource is unknown.
|
||||||
@ -33,23 +32,28 @@
|
|||||||
*/
|
*/
|
||||||
@InterfaceAudience.Public
|
@InterfaceAudience.Public
|
||||||
@InterfaceStability.Evolving
|
@InterfaceStability.Evolving
|
||||||
public class UnknownStoreException extends IOException {
|
public class UnknownStoreException extends PathIOException {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
* @param message message
|
*
|
||||||
|
* @param path path trying to access.
|
||||||
|
* @param message message.
|
||||||
*/
|
*/
|
||||||
public UnknownStoreException(final String message) {
|
public UnknownStoreException(final String path, final String message) {
|
||||||
this(message, null);
|
this(path, message, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* 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) {
|
public UnknownStoreException(String path, final String message,
|
||||||
super(message);
|
Throwable cause) {
|
||||||
|
super(path, message);
|
||||||
if (cause != null) {
|
if (cause != null) {
|
||||||
initCause(cause);
|
initCause(cause);
|
||||||
}
|
}
|
||||||
|
@ -181,8 +181,12 @@ private static AmazonS3Exception createS3Exception(String message, int code,
|
|||||||
|
|
||||||
private static <E extends Throwable> E verifyTranslated(Class<E> clazz,
|
private static <E extends Throwable> E verifyTranslated(Class<E> clazz,
|
||||||
AmazonClientException exception) throws Exception {
|
AmazonClientException exception) throws Exception {
|
||||||
return verifyExceptionClass(clazz,
|
// Verifying that the translated exception have the correct error message.
|
||||||
translateException("test", "/", exception));
|
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)
|
private void assertContainsInterrupted(boolean expected, Throwable thrown)
|
||||||
|
Loading…
Reference in New Issue
Block a user