Skip to content

Commit b1c4cb4

Browse files
authored
Take into account range start to compute the current stream end on url repositories. (#70509)
Closes #70310
1 parent 6c08574 commit b1c4cb4

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

modules/repository-url/src/main/java/org/elasticsearch/common/blobstore/url/http/HttpURLBlobContainer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.elasticsearch.common.blobstore.url.URLBlobContainer;
1313
import org.elasticsearch.common.blobstore.url.URLBlobStore;
1414

15+
import java.io.ByteArrayInputStream;
1516
import java.io.IOException;
1617
import java.io.InputStream;
1718
import java.net.URI;
@@ -33,6 +34,10 @@ public HttpURLBlobContainer(URLBlobStore blobStore,
3334

3435
@Override
3536
public InputStream readBlob(String name, long position, long length) throws IOException {
37+
if (length == 0) {
38+
return new ByteArrayInputStream(new byte[0]);
39+
}
40+
3641
return new RetryingHttpInputStream(name,
3742
getURIForBlob(name),
3843
position,

modules/repository-url/src/main/java/org/elasticsearch/common/blobstore/url/http/RetryingHttpInputStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ private HttpResponseInputStream openInputStream() throws IOException {
220220
" Status code: [" + statusCode + "] - Body: " + body));
221221
}
222222

223-
currentStreamLastOffset = getStreamLength(response);
223+
currentStreamLastOffset = Math.addExact(Math.addExact(start, totalBytesRead), getStreamLength(response));
224224

225225
return response.getInputStream();
226226
} catch (URLHttpClientException e) {

modules/repository-url/src/test/java/org/elasticsearch/common/blobstore/url/URLBlobContainerRetriesTests.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ public static void tearDownHttpClient() throws IOException {
4141
factory.close();
4242
}
4343

44-
@Override
45-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/70310")
46-
public void testReadRangeBlobWithRetries() {
47-
48-
}
49-
5044
@Override
5145
protected String downloadStorageEndpoint(String blob) {
5246
return "/" + blob;

0 commit comments

Comments
 (0)