Aliaksandr created JCLOUDS-1632: ----------------------------------- Summary: GCP BlobStore fails to put a blob if blob name contains non ASCII characters Key: JCLOUDS-1632 URL: https://issues.apache.org/jira/browse/JCLOUDS-1632 Project: jclouds Issue Type: Bug Components: jclouds-blobstore, jclouds-core Affects Versions: 2.5.0 Reporter: Aliaksandr
*Steps to reproduce*: # Configure blob store using `google-cloud-storage` # Try to put a blob with name containing any Unicode character # The error occurred something like below {noformat} SEVERE: error after writing 389/409 bytes to https://www.googleapis.com/upload/storage/v1/b/gcp-dev/o?uploadType=multipart java.io.IOException: too many bytes written at java.base/sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.write(HttpURLConnection.java:3812) at com.google.common.io.CountingOutputStream.write(CountingOutputStream.java:54) at org.jclouds.io.ByteStreams2.copy(ByteStreams2.java:73) at org.jclouds.http.internal.JavaUrlHttpCommandExecutorService.writePayloadToConnection(JavaUrlHttpCommandExecutorService.java:302) at org.jclouds.http.internal.JavaUrlHttpCommandExecutorService.convert(JavaUrlHttpCommandExecutorService.java:175) at org.jclouds.http.internal.JavaUrlHttpCommandExecutorService.convert(JavaUrlHttpCommandExecutorService.java:66) at org.jclouds.http.internal.BaseHttpCommandExecutorService.invoke(BaseHttpCommandExecutorService.java:97) at org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:91) at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:74) at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:45) at org.jclouds.reflect.FunctionalReflection$FunctionalInvocationHandler.handleInvocation(FunctionalReflection.java:117) at com.google.common.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:87) at jdk.proxy3/jdk.proxy3.$Proxy86.multipartUpload(Unknown Source) at org.jclouds.googlecloudstorage.blobstore.GoogleCloudStorageBlobStore.putBlob(GoogleCloudStorageBlobStore.java:235) at org.jclouds.googlecloudstorage.blobstore.GoogleCloudStorageBlobStore.putBlob(GoogleCloudStorageBlobStore.java:207) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at com.google.inject.internal.DelegatingInvocationHandler.invoke(DelegatingInvocationHandler.java:50) at jdk.proxy3/jdk.proxy3.$Proxy78.putBlob(Unknown Source) {noformat} *Root cause* The contractor org.jclouds.io.payloads.MultipartForm#MultipartForm(java.lang.String, java.lang.Iterable<? extends org.jclouds.io.payloads.Part>) doesn't calculate content's length properly. Specifically the contractor counts the length of org.jclouds.io.payloads.MultipartForm#createHeaders string instead of encoded byte array length to UTF-8. AS a result a wrong content length is assigned to output stream causing the error above. *Solution* Use the length of byte array encoded to UTF-8 instead of string length obtained from the method org.jclouds.io.payloads.MultipartForm#createHeaders -- This message was sent by Atlassian Jira (v8.20.10#820010)