[ https://issues.apache.org/jira/browse/JCLOUDS-1625?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Amine RACHYD updated JCLOUDS-1625: ---------------------------------- Summary: Wrong blob size from metadata when sending range request to JClouds running on GCS (was: Wrong metadata blob size when sending range request to JClouds running on GCS) > Wrong blob size from metadata when sending range request to JClouds running > on GCS > ---------------------------------------------------------------------------------- > > Key: JCLOUDS-1625 > URL: https://issues.apache.org/jira/browse/JCLOUDS-1625 > Project: jclouds > Issue Type: Bug > Components: jclouds-blobstore > Affects Versions: 2.5.0 > Reporter: Amine RACHYD > Priority: Major > > 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: > > {code:java} > // ---- 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(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); > {code} > For info, I think it's this > [line|https://github.com/apache/jclouds/blob/611b4c4a1107501b705191495fb034e2b8ac1bcc/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GoogleCloudStorageBlobStore.java#L255] > 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 issue before proceeding by creating a PR to fix this issue. > -- This message was sent by Atlassian Jira (v8.20.10#820010)