Skip to content

Conversation

rozza
Copy link
Member

@rozza rozza commented Oct 15, 2025

  • Updated NettyByteBuf so that it does its own reference counting as the internals of Netty can also retain and release the netty ByteBuf implementation.
  • Updated CommandMessage as CompositeByteBuf handles the releasing of its ByteBufs
  • Migrated CompositeByteBufSpecification to JUnit 5 and added extra test cases with mixed ByteBuf types not just NIO ones.
  • Added recording to CommandHelperSpecification as this caught the initial use of Netty doing its own accounting on its ByteBuf implementations.

JAVA-5982

* Updated NettyByteBuf so that it does its own reference counting as the internals
  of Netty can also retain and release the netty ByteBuf implementation.
* Updated CommandMessage as CompositeByteBuf handles the releasing of its ByteBufs
* Migrated CompositeByteBufSpecification to JUnit 5 and added extra test cases with
  mixed ByteBuf types not just NIO ones.
* Added recording to CommandHelperSpecification as this caught the initial use of
  Netty doing its own accounting on its ByteBuf implementations.

JAVA-5982
@rozza rozza requested review from a team, Copilot, nhachicha and vbabanin and removed request for a team and vbabanin October 16, 2025 11:06
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates CompositeByteBuf to take responsibility for managing the reference counting lifecycle of its constituent ByteBuf components, rather than relying on external callers to handle this.

  • Updated NettyByteBuf to maintain its own reference count separate from the underlying Netty buffer
  • Modified CompositeByteBuf to retain/release component buffers during its own lifecycle management
  • Migrated test suite from Groovy/Spock to JUnit 5 with enhanced coverage for mixed buffer types

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
CompositeByteBufTest.java New JUnit 5 test suite with parameterized tests for ByteBufNIO, NettyByteBuf, and mixed buffer scenarios
CompositeByteBufSpecification.groovy Removed legacy Groovy/Spock test file being replaced by JUnit 5 version
CommandHelperSpecification.groovy Added recording configuration to enable proper implementation logging
NettyByteBuf.java Implemented independent reference counting with AtomicInteger to track buffer lifecycle
CompositeByteBuf.java Updated to retain/release component buffers and duplicate them properly in copy constructor
CommandMessage.java Simplified buffer management by removing manual release of byte buffers
Comments suppressed due to low confidence (2)

driver-core/src/test/unit/com/mongodb/internal/connection/CompositeByteBufTest.java:1

  • The comment in line 246 says 'accross' but should be 'across'.
/*

driver-core/src/test/unit/com/mongodb/internal/connection/CompositeByteBufTest.java:1

  • The comment in line 280 says 'accross' but should be 'across'.
/*

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@rozza rozza marked this pull request as ready for review October 16, 2025 11:09
@rozza rozza requested a review from a team as a code owner October 16, 2025 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant