Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
2.5.0
-
None
Description
Hello
We noticed an error when requesting a blob via a range request when running on GCS mode
The payload requested is correct, however the size announced by its metadata points to the full blob size.
This was noticed on JClouds 2.5.0, running on Java 8
For some reason I couldn't package a reproducer project but I'm putting a code snippet that reproduces this error:
// ---- REDACTED: Creating a blobStore context from GCS provider ----- // Create blob, payload size is 12 bytes byte[] payload = "Hello World!".getBytes(); assertEquals(12, payload.length); Blob blob = blobStore.blobBuilder(blobName).payload(payload).build(); // Put blob to GCS blobStore.putBlob(bucketName, blob); // ----- 1. Retrieve blob ----- Blob resultBlob = blobStore.getBlob(bucketName, blobName); // ----- 2. Retrieve blob with range query ----- GetOptions getOptions = new GetOptions().range(0,4); Blob resultRangeBlob = blobStore.getBlob(bucketName, blobName, getOptions); // ----- 3. Read content of blob and assert size (12 for the first one, 5 for the second) ----- byte[] buffer = new byte[15]; int readBytesFromBlob = resultBlob.getPayload().openStream().read(buffer); int readBytesFromRangeBlob = resultRangeBlob.getPayload().openStream().read(buffer);Assert.assertEquals(12, readBytesFromBlob); assertEquals(12, readBytesFromBlob); assertEquals(5, readBytesFromRangeBlob); // ----- 4. Get blobs sizes from respective metadata ----- Long blobSize = resultBlob.getMetadata().getSize(); Long rangeBlobSize = resultRangeBlob.getMetadata().getSize(); assertEquals(Long.valueOf(12), blobSize); // The following assertion fails // The rangeBlobSize equals 12, the full blob length // Whereas it should reflect only the size that has been read (5 in this case) assertEquals(Long.valueOf(5), rangeBlobSize);
For info, I think it's this line that causes the error, as the payload metadata is being set from the initial metadata of the full blob (object retrieved on L246).
I'm opening this Jira ticket before proceeding by creating a PR to fix this bug.