|
11 | 11 |
|
12 | 12 | import software.amazon.awssdk.core.ResponseInputStream; |
13 | 13 | import software.amazon.awssdk.http.AbortableInputStream; |
| 14 | +import software.amazon.awssdk.services.s3.S3Client; |
14 | 15 | import software.amazon.awssdk.services.s3.model.GetObjectRequest; |
| 16 | +import software.amazon.awssdk.services.s3.model.GetObjectResponse; |
| 17 | +import software.amazon.awssdk.services.s3.model.S3Exception; |
15 | 18 |
|
16 | 19 | import org.elasticsearch.common.io.Streams; |
17 | 20 | import org.elasticsearch.core.Nullable; |
18 | 21 | import org.elasticsearch.repositories.blobstore.RequestedRangeNotSatisfiedException; |
19 | 22 | import org.elasticsearch.rest.RestStatus; |
20 | 23 | import org.elasticsearch.test.ESTestCase; |
21 | 24 |
|
22 | | -import software.amazon.awssdk.services.s3.S3Client; |
23 | | -import software.amazon.awssdk.services.s3.model.GetObjectResponse; |
24 | | -import software.amazon.awssdk.services.s3.model.S3Exception; |
25 | | - |
26 | 25 | import java.io.ByteArrayInputStream; |
27 | 26 | import java.io.IOException; |
28 | 27 | import java.util.Arrays; |
@@ -144,22 +143,20 @@ private S3RetryingInputStream createInputStream(final byte[] data, @Nullable fin |
144 | 143 |
|
145 | 144 | // NOMERGE: I think blobStore.getMetricPublisher(operation, purpose) needs to be defined, to fix the NPE. I didn't get that far. |
146 | 145 | // TODO NOMERGE: revisit AbortableInputStream, I just threw it on to see if that fixed the NPE. |
147 | | - ResponseInputStream<GetObjectResponse> objectResponse = |
148 | | - new ResponseInputStream<>( |
149 | | - GetObjectResponse.builder().build(),//.contentLength(length.longValue()).build(), |
150 | | - AbortableInputStream.create(new ByteArrayInputStream(data, position, length)) |
151 | | - ); |
| 146 | + ResponseInputStream<GetObjectResponse> objectResponse = new ResponseInputStream<>( |
| 147 | + GetObjectResponse.builder().build(),// .contentLength(length.longValue()).build(), |
| 148 | + AbortableInputStream.create(new ByteArrayInputStream(data, position, length)) |
| 149 | + ); |
152 | 150 | when(client.getObject(any(GetObjectRequest.class))).thenReturn(objectResponse); |
153 | 151 | return new S3RetryingInputStream(randomPurpose(), blobStore, "_blob", position, Math.addExact(position, length - 1)); |
154 | 152 | } |
155 | 153 |
|
156 | 154 | // NOMERGE: I think blobStore.getMetricPublisher(operation, purpose) needs to be defined, to fix the NPE. I didn't get that far. |
157 | 155 | // TODO NOMERGE: revisit AbortableInputStream, I just threw it on to see if that fixed the NPE. |
158 | | - ResponseInputStream<GetObjectResponse> objectResponse = |
159 | | - new ResponseInputStream<>( |
160 | | - GetObjectResponse.builder().build(),//.contentLength(Long.valueOf(data.length)).build(), |
161 | | - AbortableInputStream.create(new ByteArrayInputStream(data)) |
162 | | - ); |
| 156 | + ResponseInputStream<GetObjectResponse> objectResponse = new ResponseInputStream<>( |
| 157 | + GetObjectResponse.builder().build(),// .contentLength(Long.valueOf(data.length)).build(), |
| 158 | + AbortableInputStream.create(new ByteArrayInputStream(data)) |
| 159 | + ); |
163 | 160 | when(client.getObject(any(GetObjectRequest.class))).thenReturn(objectResponse); |
164 | 161 | return new S3RetryingInputStream(randomPurpose(), blobStore, "_blob"); |
165 | 162 | } |
|
0 commit comments