[
https://issues.apache.org/jira/browse/JCLOUDS-1646?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17926666#comment-17926666
]
ASF subversion and git services commented on JCLOUDS-1646:
----------------------------------------------------------
Commit 45adfd679b66b2f065116abed88952fed9f41131 in jclouds's branch
refs/heads/master from Andrew Gaul
[ https://gitbox.apache.org/repos/asf?p=jclouds.git;h=45adfd679b ]
JCLOUDS-1646: Use boxed Long in GCS
Previously some objects lacked a content-length so this threw a
NullPointerException when unboxing.
> GCP BlobStore fails to get blob
> -------------------------------
>
> Key: JCLOUDS-1646
> URL: https://issues.apache.org/jira/browse/JCLOUDS-1646
> Project: jclouds
> Issue Type: Bug
> Components: jclouds-blobstore
> Affects Versions: 2.7.0
> Reporter: Aliaksandr
> Priority: Major
> Labels: google-cloud-storage
>
> *Steps to reproduce*
> * Configure blob store using `google-cloud-storage`
> * Some blob A already exists by the path "bucket/folder1/A"
> * The code copies the blob A to blob B
> org.jclouds.blobstore.BlobStore#copyBlob("bucket", "folder1/A", "bucket",
> "folder2/B",
> CopyOptions.NONE))
> * An then the code reads immediately blob B using
> org.jclouds.blobstore.BlobStore#getBlob("bucket", "folder2/B")
> * The error occurred something like below
> {noformat}
> java.lang.NullPointerException: Cannot invoke "java.lang.Long.longValue()"
> because the return value of
> "org.jclouds.io.MutableContentMetadata.getContentLength()" is null
> at
> org.jclouds.googlecloudstorage.blobstore.GoogleCloudStorageBlobStore.getBlob(GoogleCloudStorageBlobStore.java:254)
> at
> org.jclouds.blobstore.internal.BaseBlobStore.getBlob(BaseBlobStore.java:217)
> at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(native)
> at
> jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
> at
> jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:568)
> at
> com.google.inject.internal.DelegatingInvocationHandler.invoke(DelegatingInvocationHandler.java:50)
> at jdk.proxy3.$Proxy129.getBlob(unknown)
> {noformat}
> *Root cause*
> The attribute `Content-Length` might be null in
> `org.jclouds.io.ContentMetadata#getContentLength` but the code does a cast to
> primitive type(see
> `org.jclouds.googlecloudstorage.blobstore.GoogleCloudStorageBlobStore#getBlob`):
> {noformat}
> Payload payload = api.getObjectApi().download(container,
> Strings2.urlEncode(name), httpOptions).getPayload();
> long contentLength = payload.getContentMetadata().getContentLength();
> {noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)