7
7
*/
8
8
package org .elasticsearch .repositories .s3 ;
9
9
10
- import com .amazonaws .AmazonClientException ;
11
10
import com .amazonaws .services .s3 .model .AmazonS3Exception ;
12
11
import com .amazonaws .services .s3 .model .GetObjectRequest ;
13
12
import com .amazonaws .services .s3 .model .InitiateMultipartUploadRequest ;
26
25
import org .elasticsearch .common .settings .SecureSettings ;
27
26
import org .elasticsearch .common .settings .Settings ;
28
27
import org .elasticsearch .common .util .BigArrays ;
28
+ import org .elasticsearch .common .util .concurrent .UncategorizedExecutionException ;
29
29
import org .elasticsearch .core .Booleans ;
30
30
import org .elasticsearch .core .TimeValue ;
31
31
import org .elasticsearch .indices .recovery .RecoverySettings ;
44
44
import java .io .IOException ;
45
45
import java .util .Collection ;
46
46
import java .util .List ;
47
+ import java .util .concurrent .ExecutionException ;
47
48
import java .util .concurrent .TimeUnit ;
48
49
import java .util .concurrent .atomic .AtomicLong ;
49
50
50
51
import static org .elasticsearch .repositories .blobstore .BlobStoreTestUtil .randomPurpose ;
51
52
import static org .hamcrest .Matchers .allOf ;
52
53
import static org .hamcrest .Matchers .blankOrNullString ;
54
+ import static org .hamcrest .Matchers .containsString ;
53
55
import static org .hamcrest .Matchers .equalTo ;
54
56
import static org .hamcrest .Matchers .greaterThanOrEqualTo ;
55
57
import static org .hamcrest .Matchers .hasSize ;
@@ -226,7 +228,6 @@ List<MultipartUpload> listMultipartUploads() {
226
228
}
227
229
}
228
230
229
- @ AwaitsFix (bugUrl = "https://github.com/elastic/elasticsearch/issues/106457" )
230
231
public void testReadFromPositionLargerThanBlobLength () {
231
232
final var blobName = randomIdentifier ();
232
233
final var blobBytes = randomBytesReference (randomIntBetween (100 , 2_000 ));
@@ -239,9 +240,26 @@ public void testReadFromPositionLargerThanBlobLength() {
239
240
240
241
long position = randomLongBetween (blobBytes .length (), Long .MAX_VALUE - 1L );
241
242
long length = randomLongBetween (1L , Long .MAX_VALUE - position );
242
- var exception = expectThrows (AmazonClientException .class , () -> readBlob (repository , blobName , position , length ));
243
243
244
- assertThat (exception , instanceOf (AmazonS3Exception .class ));
245
- assertThat (((AmazonS3Exception ) exception ).getStatusCode (), equalTo (RestStatus .REQUESTED_RANGE_NOT_SATISFIED .getStatus ()));
244
+ var exception = expectThrows (UncategorizedExecutionException .class , () -> readBlob (repository , blobName , position , length ));
245
+ assertThat (exception .getCause (), instanceOf (ExecutionException .class ));
246
+ assertThat (exception .getCause ().getCause (), instanceOf (IOException .class ));
247
+ assertThat (
248
+ exception .getCause ().getCause ().getMessage (),
249
+ containsString (
250
+ "Requested range [start="
251
+ + position
252
+ + ", end="
253
+ + (position + length - 1L )
254
+ + ", currentOffset=0] cannot be satisfied for blob object ["
255
+ + repository .basePath ().buildAsString ()
256
+ + blobName
257
+ + ']'
258
+ )
259
+ );
260
+ assertThat (
261
+ asInstanceOf (AmazonS3Exception .class , exception .getRootCause ()).getStatusCode (),
262
+ equalTo (RestStatus .REQUESTED_RANGE_NOT_SATISFIED .getStatus ())
263
+ );
246
264
}
247
265
}
0 commit comments