Skip to content

Commit 973b9e1

Browse files
authored
Make NettyByteBuf share parent reference count (#1897)
JAVA-6107
1 parent 5604c04 commit 973b9e1

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

driver-core/src/main/com/mongodb/internal/connection/netty/NettyByteBuf.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public ByteBuf asReadOnly() {
256256

257257
@Override
258258
public ByteBuf duplicate() {
259-
return new NettyByteBuf(proxied.retainedDuplicate(), isWriting);
259+
return new NettyByteBuf(proxied.duplicate().retain(), isWriting);
260260
}
261261

262262
@Override

driver-core/src/main/com/mongodb/internal/connection/netty/NettyStream.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ private void readAsync(final int numBytes, final AsyncCompletionHandler<ByteBuf>
307307
composite.addComponent(next);
308308
iter.remove();
309309
} else {
310-
composite.addComponent(next.readRetainedSlice(bytesNeededFromCurrentBuffer));
310+
next.retain();
311+
composite.addComponent(next.readSlice(bytesNeededFromCurrentBuffer));
311312
}
312313
composite.writerIndex(composite.writerIndex() + bytesNeededFromCurrentBuffer);
313314
bytesNeeded -= bytesNeededFromCurrentBuffer;

driver-core/src/test/functional/com/mongodb/internal/connection/CommandHelperSpecification.groovy

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import com.mongodb.connection.SocketSettings
2525
import com.mongodb.internal.connection.netty.NettyStreamFactory
2626
import org.bson.BsonDocument
2727
import org.bson.BsonInt32
28-
import spock.lang.Ignore
2928
import spock.lang.Specification
3029

3130
import java.util.concurrent.CountDownLatch
@@ -57,7 +56,6 @@ class CommandHelperSpecification extends Specification {
5756
connection?.close()
5857
}
5958

60-
@Ignore("JAVA-5982")
6159
def 'should execute command asynchronously'() {
6260
when:
6361
BsonDocument receivedDocument = null
@@ -84,5 +82,4 @@ class CommandHelperSpecification extends Specification {
8482
!receivedDocument
8583
receivedException instanceof MongoCommandException
8684
}
87-
8885
}

0 commit comments

Comments
 (0)