JCLOUDS-1327: Do not try GCS MPU if length is zero

References JCLOUDS-912.


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/9e73bbec
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/9e73bbec
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/9e73bbec

Branch: refs/heads/master
Commit: 9e73bbec16cbf91c5f228d4c3ae99c6c526081f8
Parents: d603848
Author: Andrew Gaul <g...@apache.org>
Authored: Sun Aug 6 13:13:15 2017 -0700
Committer: Andrew Gaul <g...@apache.org>
Committed: Sun Aug 6 13:51:08 2017 -0700

----------------------------------------------------------------------
 .../blobstore/GoogleCloudStorageBlobStore.java                 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/9e73bbec/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GoogleCloudStorageBlobStore.java
----------------------------------------------------------------------
diff --git 
a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GoogleCloudStorageBlobStore.java
 
b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GoogleCloudStorageBlobStore.java
index c86dcc8..b58f25c 100644
--- 
a/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GoogleCloudStorageBlobStore.java
+++ 
b/providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GoogleCloudStorageBlobStore.java
@@ -215,13 +215,13 @@ public final class GoogleCloudStorageBlobStore extends 
BaseBlobStore {
 
    @Override
    public String putBlob(String container, Blob blob, PutOptions options) {
-      if (options.isMultipart() || !blob.getPayload().isRepeatable()) {
+      long length = 
checkNotNull(blob.getPayload().getContentMetadata().getContentLength());
+
+      if (length != 0 && (options.isMultipart() || 
!blob.getPayload().isRepeatable())) {
          // JCLOUDS-912 prevents using single-part uploads with InputStream 
payloads.
          // Work around this with multi-part upload which buffers parts 
in-memory.
          return putMultipartBlob(container, blob, options);
       } else {
-         
checkNotNull(blob.getPayload().getContentMetadata().getContentLength());
-
          ObjectTemplate template = 
blobMetadataToObjectTemplate.apply(blob.getMetadata());
 
          HashCode md5 = 
blob.getMetadata().getContentMetadata().getContentMD5AsHashCode();

Reply via email to