Bill commented on a change in pull request #5666:
URL: https://github.com/apache/geode/pull/5666#discussion_r514563824



##########
File path: 
geode-core/src/main/java/org/apache/geode/internal/net/NioPlainEngine.java
##########
@@ -121,8 +121,12 @@ public void doneReading(ByteBuffer unwrappedBuffer) {
   }
 
   @Override
-  public ByteBuffer getUnwrappedBuffer(ByteBuffer wrappedBuffer) {
-    return wrappedBuffer;
+  public ByteBufferSharing getUnwrappedBuffer() {
+    return shareBuffer(null);

Review comment:
       What @bschuchardt's comment made me concerned about, is the prospect of 
a "client" of a `ByteBufferSharing` (`ByteBufferSharingImpl` particularly), 
calling `close()` too many times i.e. more than once.
   
   Turns our there was a bug there. In the version of the code he commented on, 
if a client called `close()` twice then the reference count was decremented on 
the second call, even though it was already `0` (leaving it at `-1`.) You can 
imagine the bad things that happen in that state.
   
   The latest commit adds a test for this bug (`ByteBufferSharingImplTest`) and 
also fixes the bug.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to