Error when putting a blob as byte[]

114 views
Skip to first unread message

José Elias Queiroga da Costa Araújo

unread,
Jan 22, 2013, 9:16:28 AM1/22/13
to jcl...@googlegroups.com

          Hi all,

          I'm facing a problem when I try to put a blob content by using a byte[] type.  The code is:

            byte[] content = "this is a test".getBytes();
Blob blob = blobStore.blobBuilder("blob").payload(content)
.name("teste").build();

blobStore.putBlob("MyContainer", blob);

        The error message is:

Exception in thread "main" org.jclouds.http.HttpResponseException: Unexpected end of file from server connecting to PUT https://region-a.geo-1.objects.hpcloudsvc.com/v1/31369288792652/MyContainer/teste HTTP/1.1
at org.jclouds.http.internal.BaseHttpCommandExecutorService$HttpResponseCallable.call(BaseHttpCommandExecutorService.java:179)
at org.jclouds.http.internal.BaseHttpCommandExecutorService$HttpResponseCallable.call(BaseHttpCommandExecutorService.java:135)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at org.jclouds.concurrent.config.DescribingExecutorService.submit(DescribingExecutorService.java:89)
at org.jclouds.http.internal.BaseHttpCommandExecutorService.submit(BaseHttpCommandExecutorService.java:132)
at org.jclouds.http.TransformingHttpCommandExecutorServiceImpl.submit(TransformingHttpCommandExecutorServiceImpl.java:54)
at org.jclouds.http.TransformingHttpCommandImpl.execute(TransformingHttpCommandImpl.java:73)
at org.jclouds.rest.internal.AsyncRestClientProxy.createListenableFutureForHttpRequestMappedToMethodAndArgs(AsyncRestClientProxy.java:254)
at org.jclouds.rest.internal.AsyncRestClientProxy.invoke(AsyncRestClientProxy.java:148)
at $Proxy76.putObject(Unknown Source)

            However, If I use a FileInputStream or ByteArrayInputStream instad of byte[] type, the above code works fine.  The jclouds version is 1.5.5 and the service is the "hpcloud-objectstorage"

            Thus, can anyone help me?
 
             Best Regards,

             Elias.

Andrew Phillips

unread,
Jan 22, 2013, 8:46:02 PM1/22/13
to jcl...@googlegroups.com
Hi Elias

> However, If I use a FileInputStream or ByteArrayInputStream
> instad of byte[] type, the above code works fine. The jclouds version is
> 1.5.5 and the service is the "hpcloud-objectstorage"

Thanks for reporting this. An initial, perhaps stupid question: are
you able to use ByteArrayInputStream as a workaround in your situation
or do you really need to use a byte array?

ap

Andrew Gaul

unread,
Jan 22, 2013, 9:07:44 PM1/22/13
to jcl...@googlegroups.com
I tested this same code against hpcloud-objectstorage and it works with byte[].  Perhaps you experienced a transient error?

José Elias Queiroga da Costa Araújo

unread,
Jan 23, 2013, 8:27:28 AM1/23/13
to jcl...@googlegroups.com, aphi...@qrmedia.com

            Hi Andrew, thanks for replying

            ByteArrayInputStream may work for me as well.  However I have a code that use byte[] in many of points in my project and I would like to know why occur this error before changing to use ByteArrayInputStream.  I remember that it worked with another version like 1.5.0-beta-9.

            Would you have any idea the cause? 

            Thanks a lot.

            Elias.

José Elias Queiroga da Costa Araújo

unread,
Jan 23, 2013, 8:29:54 AM1/23/13
to jcl...@googlegroups.com

              Hi Andrew Gaul,

              have you used the 1.5.5 version?  Is it able to work with something like "This is a test".getByte()?

              Thanks,

              Elias.

Andrew Gaul

unread,
Jan 23, 2013, 12:27:40 PM1/23/13
to jcl...@googlegroups.com
José, I tested against hpcloud-objectstorage with jclouds 1.5.5 using:

    @Test
    public void testPutByteArray() throws Exception {
        BlobStore blobStore = blobStoreContext.getBlobStore();
        byte[] content = "this is a test".getBytes();
        Blob blob = blobStore
                .blobBuilder("blob")
                .payload(content)
                .name("teste")
                .build();
        blobStore.putBlob(containerName, blob);
    }

Have you tried running your test again?

José Elias Queiroga da Costa Araújo

unread,
Jan 23, 2013, 1:18:39 PM1/23/13
to jcl...@googlegroups.com

           Hi Andrew,

           yes, I ran this code here in my project and it throws the same error

Jan 23, 2013 3:18:01 PM org.jclouds.logging.jdk.JDKLogger logError
SEVERE: Cannot retry after server error, command has exceeded retry limit 5: [method=HPCloudObjectStorageAsyncApi.putObject, request=PUT https://region-a.geo-1.objects.hpcloudsvc.com/v1/31369288792652/MyContainer/teste HTTP/1.1]
Exception in thread "main" org.jclouds.http.HttpResponseException: Unexpected end of file from server connecting to PUT https://region-a.geo-1.objects.hpcloudsvc.com/v1/31369288792652/MyContainer/teste HTTP/1.1
at org.jclouds.http.internal.BaseHttpCommandExecutorService$HttpResponseCallable.call(BaseHttpCommandExecutorService.java:179)
at org.jclouds.http.internal.BaseHttpCommandExecutorService$HttpResponseCallable.call(BaseHttpCommandExecutorService.java:135)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Reply all
Reply to author
Forward
0 new messages