New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObjectStorage: file download #222

Closed
bassimatteo opened this Issue Jan 27, 2015 · 6 comments

Comments

Projects
None yet
3 participants
@bassimatteo

bassimatteo commented Jan 27, 2015

Hello,

I'm using Openstack4j with RestEasy Connector, using this snippet I'm not able to download a file:

OSClient.objectStorage().objects().download(container, fileName)

I get an exception from RestEasy, complaining that:

Unable to find a MessageBodyReader of content-type application/octet-stream and type class java.lang.Void

Is there a solution to solve the problem?

NOTE: I saw that in your ObjectStorageObjectServiceImpl class the method public DLPayload download(ObjectLocation location, DownloadOptions options) tries to convert the entity stream to a Void class. Maybe RestEasy is not accepting that.

@gondor gondor added the bug label Jan 27, 2015

@gondor gondor added this to the 2.0.2 Release milestone Jan 27, 2015

@gondor gondor self-assigned this Jan 27, 2015

gondor added a commit that referenced this issue Jan 27, 2015

@gondor

This comment has been minimized.

Show comment
Hide comment
@gondor

gondor Jan 27, 2015

Member

Thanks for the detailed information. I was able to reproduce this and fix the cause. Just checked in the code and re-deployed a new SNAPSHOT. Let me know if this works

Member

gondor commented Jan 27, 2015

Thanks for the detailed information. I was able to reproduce this and fix the cause. Just checked in the code and re-deployed a new SNAPSHOT. Let me know if this works

@bassimatteo

This comment has been minimized.

Show comment
Hide comment
@bassimatteo

bassimatteo Jan 29, 2015

It works!

Thank you very much

bassimatteo commented Jan 29, 2015

It works!

Thank you very much

@gondor

This comment has been minimized.

Show comment
Hide comment
@gondor

gondor Jan 29, 2015

Member

Great!

Member

gondor commented Jan 29, 2015

Great!

@gondor gondor closed this Jan 29, 2015

@bassimatteo

This comment has been minimized.

Show comment
Hide comment
@bassimatteo

bassimatteo Jan 30, 2015

Trying to read a big (~30 MB) file, I got the following exception:

java.io.IOException: Stream closed
    at java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:162)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:280)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
    at org.jboss.resteasy.client.core.SelfExpandingBufferredInputStream.read(SelfExpandingBufferredInputStream.java:57)
    at java.io.FilterInputStream.read(FilterInputStream.java:107)
    at org.jboss.resteasy.client.core.SelfExpandingBufferredInputStream.read(SelfExpandingBufferredInputStream.java:67)

It looks like in org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor, there's a method automatically closing the stream.

public void performReleaseConnection()
            {
               // Apache Client 4 is stupid, You have to get the InputStream and close it if there is an entity
               // otherwise the connection is never released. There is, of course, no close() method on response
               // to make this easier.
               try
               {
                  if (stream != null)
                  {
                     stream.close();
                  }
                  else
                  {

I also tried initializing the OSClient with:

'.withConfig(Config.newConfig().withReadTimeout(120000).withConnectionTimeout(120000))', 

but still no luck.

Do you think it's a RestEasy issue or can be fixed from your client ?

bassimatteo commented Jan 30, 2015

Trying to read a big (~30 MB) file, I got the following exception:

java.io.IOException: Stream closed
    at java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:162)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:280)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
    at org.jboss.resteasy.client.core.SelfExpandingBufferredInputStream.read(SelfExpandingBufferredInputStream.java:57)
    at java.io.FilterInputStream.read(FilterInputStream.java:107)
    at org.jboss.resteasy.client.core.SelfExpandingBufferredInputStream.read(SelfExpandingBufferredInputStream.java:67)

It looks like in org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor, there's a method automatically closing the stream.

public void performReleaseConnection()
            {
               // Apache Client 4 is stupid, You have to get the InputStream and close it if there is an entity
               // otherwise the connection is never released. There is, of course, no close() method on response
               // to make this easier.
               try
               {
                  if (stream != null)
                  {
                     stream.close();
                  }
                  else
                  {

I also tried initializing the OSClient with:

'.withConfig(Config.newConfig().withReadTimeout(120000).withConnectionTimeout(120000))', 

but still no luck.

Do you think it's a RestEasy issue or can be fixed from your client ?

@bassimatteo

This comment has been minimized.

Show comment
Hide comment
@bassimatteo

bassimatteo commented Feb 2, 2015

@vinodborole

This comment has been minimized.

Show comment
Hide comment
@vinodborole

vinodborole Feb 25, 2016

Contributor

@gondor @bassimatteo

We are facing similar issue with 2.10 version of openstack4j-resteasy connector. Do we have a workaround for this?

Contributor

vinodborole commented Feb 25, 2016

@gondor @bassimatteo

We are facing similar issue with 2.10 version of openstack4j-resteasy connector. Do we have a workaround for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment