|
18 | 18 |
|
19 | 19 | package org.apache.hadoop.fs.s3a; |
20 | 20 |
|
| 21 | +import java.io.EOFException; |
21 | 22 | import java.io.IOException; |
22 | 23 | import java.io.InterruptedIOException; |
23 | 24 | import java.net.SocketTimeoutException; |
|
28 | 29 | import com.amazonaws.AmazonClientException; |
29 | 30 | import com.amazonaws.AmazonServiceException; |
30 | 31 | import com.amazonaws.SdkBaseException; |
| 32 | +import com.amazonaws.SdkClientException; |
31 | 33 | import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughputExceededException; |
32 | 34 | import com.amazonaws.services.s3.model.AmazonS3Exception; |
33 | 35 | import org.junit.Assert; |
@@ -163,6 +165,40 @@ public void test500isStatus500Exception() throws Exception { |
163 | 165 | ex); |
164 | 166 | } |
165 | 167 |
|
| 168 | + @Test |
| 169 | + public void testExceptionsWithTranslatableMessage() throws Exception { |
| 170 | + SdkBaseException xmlParsing = new SdkBaseException(EOF_MESSAGE_IN_XML_PARSER); |
| 171 | + SdkBaseException differentLength = new SdkBaseException(EOF_READ_DIFFERENT_LENGTH); |
| 172 | + |
| 173 | + verifyTranslated(EOFException.class, xmlParsing); |
| 174 | + verifyTranslated(EOFException.class, differentLength); |
| 175 | + } |
| 176 | + |
| 177 | + |
| 178 | + @Test |
| 179 | + public void testSdkDifferentLengthExceptionIsTranslatable() throws Throwable { |
| 180 | + final AtomicInteger counter = new AtomicInteger(0); |
| 181 | + invoker.retry("test", null, false, () -> { |
| 182 | + if (counter.incrementAndGet() < ACTIVE_RETRY_LIMIT) { |
| 183 | + throw new SdkClientException(EOF_READ_DIFFERENT_LENGTH); |
| 184 | + } |
| 185 | + }); |
| 186 | + |
| 187 | + assertEquals(ACTIVE_RETRY_LIMIT, counter.get()); |
| 188 | + } |
| 189 | + |
| 190 | + @Test |
| 191 | + public void testSdkXmlParsingExceptionIsTranslatable() throws Throwable { |
| 192 | + final AtomicInteger counter = new AtomicInteger(0); |
| 193 | + invoker.retry("test", null, false, () -> { |
| 194 | + if (counter.incrementAndGet() < ACTIVE_RETRY_LIMIT) { |
| 195 | + throw new SdkClientException(EOF_MESSAGE_IN_XML_PARSER); |
| 196 | + } |
| 197 | + }); |
| 198 | + |
| 199 | + assertEquals(ACTIVE_RETRY_LIMIT, counter.get()); |
| 200 | + } |
| 201 | + |
166 | 202 | @Test(expected = org.apache.hadoop.net.ConnectTimeoutException.class) |
167 | 203 | public void testExtractConnectTimeoutException() throws Throwable { |
168 | 204 | throw extractException("", "", |
|
0 commit comments