XEdwin / jcouchdb

Automatically exported from code.google.com/p/jcouchdb
Other
0 stars 0 forks source link

Inconsistent destroying of Response object in Database class #83

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Please document or change this behavior in Database class.

When you use the following method to load attachment:

public byte[] getAttachment(String docId, String attachmentId);

If the error occurs (e.g. attachment does not exist), the response object is 
destroyed automatically. On the other hand, if using this method:

public Response getAttachmentResponse(String docId, String attachmentId);

If the error occurs, the response is not destroyed correctly and the connection 
remains open (which leads to a deadlock in connection pool). Of course, it is 
possible to destroy response manually by extracting it from the exception, but 
it is not very convenient.

Thank you for any action, hope this helps.

Original issue reported on code.google.com by vojtech....@insophy.cz on 26 Apr 2012 at 12:03

GoogleCodeExporter commented 9 years ago
What you've described seems to be the behavior that's documented ... I believe 
that if the attachment isn't found, the getAttachmentResponse() should return a 
Response object with a 404 status code.  So here's a snippet of code I'd use to 
test this:

Response response = getAttachment(docId, attachmentId);
if(response.isOk()) {
    ...
} else {
    System.out.println(response.getCode);
    response.destroy();
}

I'll take a look at the code, but to me it sounds like the Exception shouldn't 
be thrown.

Original comment by smoye...@gmail.com on 31 May 2012 at 9:53