You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/03/08 20:00:59 UTC

[GitHub] reddycharan opened a new issue #1237: Question regarding refcount of ByteBuf in our client API

reddycharan opened a new issue #1237: Question regarding refcount of ByteBuf in our client API
URL: https://github.com/apache/bookkeeper/issues/1237
 
 
   **QUESTION**
   
   Regarding the refcount of ByteBuf, from what I understand the API method which takes ByteBuf as argument shouldn't increase or decrease the refcount of 'ReferenceCounted' object.
   
   I mean
   ```
   myApplicationMethod() {
   
       ByteBuf byteBuf = createNewInstanceOfByteBuf();
       ...
       APIClass.APIMethod(bytebuf);
       ...
       byteBuf.release(); 
   }
   ```
   here when I create byteBuf the refCount would typically be 1. Now by passing this refcounted object to the standard API method, I don?t expect the APIMethod to decrease the refCount (modify refCount) and finally it is the responsibility of the caller (application) method to release it by calling release method explicitly when they are done with the byteBuf.
   
   But in our case  WriteAdvHandle.write(long entryId, ByteBuf data) is decreasing the refcount, this is because of https://github.com/apache/bookkeeper/blob/master/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingAddOp.java#L422 . Hence @ivankelly is calling https://github.com/apache/bookkeeper/pull/1233/commits/23a548d95474969729a59a1d3676ecf0de24d34a#diff-d168699d534345c67678296447f8375cR609 , explicit retain() immediately after creating ByteBuf. 
   
   **Que:** Why are we doing this? What is the general practice with regards to usage of refcounted objects in API methods? Have we mentioned the expected behavior in detail in our API docs?
   
   Are we doing corresponding release calls in all the places where ByteBuff is created. https://netty.io/4.0/api/io/netty/util/ReferenceCounted.html says that initial count would be 1 when an ReferenceCounted object is created.
   
   Are there enough documentation/comments in code/invariant checks/testcases at each layer for ByteBuf usage in our Client and Server code?
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services