|
@@ -18,6 +18,7 @@
|
|
|
|
|
|
package org.apache.hadoop.fs.s3a;
|
|
|
|
|
|
+import java.io.EOFException;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InterruptedIOException;
|
|
|
import java.net.SocketTimeoutException;
|
|
@@ -28,6 +29,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import com.amazonaws.AmazonClientException;
|
|
|
import com.amazonaws.AmazonServiceException;
|
|
|
import com.amazonaws.SdkBaseException;
|
|
|
+import com.amazonaws.SdkClientException;
|
|
|
import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughputExceededException;
|
|
|
import com.amazonaws.services.s3.model.AmazonS3Exception;
|
|
|
import org.junit.Assert;
|
|
@@ -163,6 +165,40 @@ public class TestInvoker extends Assert {
|
|
|
ex);
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testExceptionsWithTranslatableMessage() throws Exception {
|
|
|
+ SdkBaseException xmlParsing = new SdkBaseException(EOF_MESSAGE_IN_XML_PARSER);
|
|
|
+ SdkBaseException differentLength = new SdkBaseException(EOF_READ_DIFFERENT_LENGTH);
|
|
|
+
|
|
|
+ verifyTranslated(EOFException.class, xmlParsing);
|
|
|
+ verifyTranslated(EOFException.class, differentLength);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testSdkDifferentLengthExceptionIsTranslatable() throws Throwable {
|
|
|
+ final AtomicInteger counter = new AtomicInteger(0);
|
|
|
+ invoker.retry("test", null, false, () -> {
|
|
|
+ if (counter.incrementAndGet() < ACTIVE_RETRY_LIMIT) {
|
|
|
+ throw new SdkClientException(EOF_READ_DIFFERENT_LENGTH);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ assertEquals(ACTIVE_RETRY_LIMIT, counter.get());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testSdkXmlParsingExceptionIsTranslatable() throws Throwable {
|
|
|
+ final AtomicInteger counter = new AtomicInteger(0);
|
|
|
+ invoker.retry("test", null, false, () -> {
|
|
|
+ if (counter.incrementAndGet() < ACTIVE_RETRY_LIMIT) {
|
|
|
+ throw new SdkClientException(EOF_MESSAGE_IN_XML_PARSER);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ assertEquals(ACTIVE_RETRY_LIMIT, counter.get());
|
|
|
+ }
|
|
|
+
|
|
|
@Test(expected = org.apache.hadoop.net.ConnectTimeoutException.class)
|
|
|
public void testExtractConnectTimeoutException() throws Throwable {
|
|
|
throw extractException("", "",
|