Skip to content

Conversation

@fdesu
Copy link
Contributor

@fdesu fdesu commented Dec 15, 2025

Description

This PR fixes some of the deprecation warnings in the transport-netty4 module:

  1. Use ChannelOption#RECVBUF_ALLOCATOR instead of ChannelOption#RCVBUF_ALLOCATOR
  2. Remove the usage of PooledByteBufAllocator#defaultTinyCacheSize (as per the comment: @deprecated Tiny caches have been merged into small caches.) + use appropriate PooledByteBufAllocator constructor.
  3. Use MultiThreadIoEventLoopGroup instead of NioEventLoopGroup. See more here: Netty 4.2 Migration Guide: IoHandlerFactories for EventLoopGroups
  4. Use HttpContentDecompressor(int maxAllocation) instead of default constructor that internally delegates to the HttpContentDecompressor(boolean strict = false, int maxAllocation = 0). The constructor being used after migration delegates to the same 2-args constructor with the strict=false and the given maxAllocation = 0 which means the maximum size is not limited. This change should be compatible with the previous usage.

Related Issues

No issue was created but I can totally do that.

Check List

  • Functionality includes testing.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed transport-related configuration to eliminate deprecation warnings and ensure consistent network buffer allocation between server and client.
    • Updated decompression buffer handling for more predictable request payload processing.
  • Performance Improvements

    • Improved event loop group handling for better resource utilization and scalability.
    • Adjusted memory allocator cache behavior for more efficient buffer allocation and reduced overhead.

✏️ Tip: You can customize this high-level summary in your review settings.

@fdesu fdesu requested review from a team and peternied as code owners December 15, 2025 10:46
@coderabbitai
Copy link

coderabbitai bot commented Dec 15, 2025

Walkthrough

These changes standardize Netty channel options, migrate event loop groups to MultiThreadIoEventLoopGroup, adjust pooled buffer allocator construction, and explicitly set the HTTP decompressor buffer size.

Changes

Cohort / File(s) Summary
Receive buffer allocator option updates
modules/transport-netty4/src/main/java/org/opensearch/http/netty4/Netty4HttpServerTransport.java, modules/transport-netty4/src/main/java/org/opensearch/transport/netty4/Netty4Transport.java
Replaced ChannelOption.RCVBUF_ALLOCATOR with ChannelOption.RECVBUF_ALLOCATOR in server and client bootstrap configurations.
Event loop group initialization
modules/transport-netty4/src/main/java/org/opensearch/transport/SharedGroupFactory.java
Replaced NioEventLoopGroup with MultiThreadIoEventLoopGroup and added NioIoHandler.newFactory() as the constructor factory argument for HTTP and generic transport groups.
Byte buffer allocator configuration
modules/transport-netty4/src/main/java/org/opensearch/transport/NettyAllocator.java
Removed tinyCacheSize argument from PooledByteBufAllocator construction, omitting the tiny-cache configuration while keeping other cache sizes and flags.
HTTP decompressor setup
modules/transport-netty4/src/main/java/org/opensearch/http/netty4/Netty4HttpServerTransport.java
Added UNLIMITED_DECOMPRESSOR_BUFFER constant and changed createDecompressor() to construct HttpContentDecompressor with that buffer size parameter.
Changelog
CHANGELOG.md
Added a note about fixing Netty deprecation warnings in the transport-netty4 module.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Review MultiThreadIoEventLoopGroup usage and compatibility where NioEventLoopGroup was replaced.
  • Verify NioIoHandler.newFactory() semantics and thread-factory integration.
  • Confirm RECVBUF_ALLOCATOR option maps correctly in all bootstrap sites.
  • Check PooledByteBufAllocator behavior change due to removed tinyCacheSize.
  • Validate HTTP decompressor instantiation and its runtime effect.

Poem

🐰 I hopped through code with nimble feet,
Replaced, removed, and tuned a beat,
Buffers set and threads aligned,
Decompressors sized — all refined,
A tiny hop for transport sweet.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main objective of the PR—fixing Netty deprecation warnings in the transport-netty4 module, which aligns with all four modified files and the changelog entry.
Description check ✅ Passed The PR description clearly outlines four specific deprecation fixes with technical details and references, includes testing confirmation, and meets template requirements.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
modules/transport-netty4/src/main/java/org/opensearch/transport/SharedGroupFactory.java (1)

49-49: Unused import: NioEventLoopGroup appears to be dead code.

After migrating to MultiThreadIoEventLoopGroup, the NioEventLoopGroup import is no longer referenced in this file and should be removed.

-import io.netty.channel.nio.NioEventLoopGroup;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ee59cb0 and bd95b3c.

📒 Files selected for processing (4)
  • modules/transport-netty4/src/main/java/org/opensearch/http/netty4/Netty4HttpServerTransport.java (3 hunks)
  • modules/transport-netty4/src/main/java/org/opensearch/transport/NettyAllocator.java (0 hunks)
  • modules/transport-netty4/src/main/java/org/opensearch/transport/SharedGroupFactory.java (3 hunks)
  • modules/transport-netty4/src/main/java/org/opensearch/transport/netty4/Netty4Transport.java (2 hunks)
💤 Files with no reviewable changes (1)
  • modules/transport-netty4/src/main/java/org/opensearch/transport/NettyAllocator.java
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: reta
Repo: opensearch-project/OpenSearch PR: 20017
File: plugins/transport-reactor-netty4/src/test/java/org/opensearch/http/reactor/netty4/ssl/SecureReactorNetty4HttpServerTransportTests.java:256-256
Timestamp: 2025-12-12T18:40:01.303Z
Learning: In the OpenSearch ReactorNetty4 secure HTTP transport tests (plugins/transport-reactor-netty4/src/test/java/org/opensearch/http/reactor/netty4/ssl/SecureReactorNetty4HttpServerTransportTests.java), URI limit validation has been moved from the protocol layer to the transport layer, making it protocol-agnostic. The random protocol selection in ReactorHttpClient.https(settings) is intentional to ensure all tests validate correct behavior across HTTP/1.1, HTTP/2, and HTTP/3.
Learnt from: reta
Repo: opensearch-project/OpenSearch PR: 20017
File: modules/transport-netty4/src/main/java/org/opensearch/http/netty4/Netty4Http3ServerTransport.java:101-123
Timestamp: 2025-12-13T20:16:08.819Z
Learning: In OpenSearch, only one HTTP transport implementation can be active and loaded at a time, so duplicate setting definitions (such as h3.max_stream_local_length, h3.max_stream_remote_length, and h3.max_streams) across different transport implementations like Netty4Http3ServerTransport and ReactorNetty4HttpServerTransport will not cause setting registration conflicts.
📚 Learning: 2025-12-13T20:16:08.819Z
Learnt from: reta
Repo: opensearch-project/OpenSearch PR: 20017
File: modules/transport-netty4/src/main/java/org/opensearch/http/netty4/Netty4Http3ServerTransport.java:101-123
Timestamp: 2025-12-13T20:16:08.819Z
Learning: In OpenSearch, only one HTTP transport implementation can be active and loaded at a time, so duplicate setting definitions (such as h3.max_stream_local_length, h3.max_stream_remote_length, and h3.max_streams) across different transport implementations like Netty4Http3ServerTransport and ReactorNetty4HttpServerTransport will not cause setting registration conflicts.

Applied to files:

  • modules/transport-netty4/src/main/java/org/opensearch/transport/netty4/Netty4Transport.java
  • modules/transport-netty4/src/main/java/org/opensearch/http/netty4/Netty4HttpServerTransport.java
  • modules/transport-netty4/src/main/java/org/opensearch/transport/SharedGroupFactory.java
📚 Learning: 2025-12-12T18:40:01.303Z
Learnt from: reta
Repo: opensearch-project/OpenSearch PR: 20017
File: plugins/transport-reactor-netty4/src/test/java/org/opensearch/http/reactor/netty4/ssl/SecureReactorNetty4HttpServerTransportTests.java:256-256
Timestamp: 2025-12-12T18:40:01.303Z
Learning: In the OpenSearch ReactorNetty4 secure HTTP transport tests (plugins/transport-reactor-netty4/src/test/java/org/opensearch/http/reactor/netty4/ssl/SecureReactorNetty4HttpServerTransportTests.java), URI limit validation has been moved from the protocol layer to the transport layer, making it protocol-agnostic. The random protocol selection in ReactorHttpClient.https(settings) is intentional to ensure all tests validate correct behavior across HTTP/1.1, HTTP/2, and HTTP/3.

Applied to files:

  • modules/transport-netty4/src/main/java/org/opensearch/transport/netty4/Netty4Transport.java
  • modules/transport-netty4/src/main/java/org/opensearch/http/netty4/Netty4HttpServerTransport.java
  • modules/transport-netty4/src/main/java/org/opensearch/transport/SharedGroupFactory.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: gradle-check
  • GitHub Check: assemble (25, windows-latest)
  • GitHub Check: assemble (21, ubuntu-latest)
  • GitHub Check: precommit (25, ubuntu-latest)
  • GitHub Check: precommit (21, ubuntu-latest)
  • GitHub Check: precommit (21, windows-2025, true)
  • GitHub Check: assemble (21, ubuntu-24.04-arm)
  • GitHub Check: assemble (25, ubuntu-24.04-arm)
  • GitHub Check: precommit (25, macos-15-intel)
  • GitHub Check: precommit (25, windows-latest)
  • GitHub Check: precommit (21, macos-15-intel)
  • GitHub Check: precommit (25, ubuntu-24.04-arm)
  • GitHub Check: precommit (21, windows-latest)
  • GitHub Check: assemble (21, windows-latest)
  • GitHub Check: precommit (21, macos-15)
  • GitHub Check: precommit (25, macos-15)
  • GitHub Check: precommit (21, ubuntu-24.04-arm)
  • GitHub Check: assemble (25, ubuntu-latest)
  • GitHub Check: detect-breaking-change
  • GitHub Check: Analyze (java)
🔇 Additional comments (6)
modules/transport-netty4/src/main/java/org/opensearch/transport/netty4/Netty4Transport.java (2)

221-221: LGTM! Deprecation fix for client bootstrap.

The rename from RCVBUF_ALLOCATOR to RECVBUF_ALLOCATOR addresses the Netty deprecation warning. This is a pure constant rename with no functional change.


291-292: LGTM! Deprecation fix for server bootstrap.

Both the server channel option and child option are correctly updated to use RECVBUF_ALLOCATOR, maintaining consistency with the client bootstrap change.

modules/transport-netty4/src/main/java/org/opensearch/transport/SharedGroupFactory.java (1)

94-111: LGTM! Migration to MultiThreadIoEventLoopGroup with NioIoHandler.newFactory() is correct.

The migration from NioEventLoopGroup to MultiThreadIoEventLoopGroup follows Netty 4.2's guidance for decoupling transport from event loop groups. Using NioIoHandler.newFactory() maintains NIO-based I/O handling, preserving behavioral compatibility.

modules/transport-netty4/src/main/java/org/opensearch/http/netty4/Netty4HttpServerTransport.java (3)

583-585: Behavior change: verify passing 0 matches or improves upon default constructor behavior.

The method now explicitly passes UNLIMITED_DECOMPRESSOR_BUFFER (0) to HttpContentDecompressor instead of using the default constructor. Since this is an extension point for NetworkPlugin implementations, ensure this change is intentional and that the behavior is equivalent or improved.


319-320: Correct use of non-deprecated Netty 4.2 channel option.

The change from RCVBUF_ALLOCATOR to RECVBUF_ALLOCATOR is correct. In Netty 4.2, ChannelOption.RCVBUF_ALLOCATOR is deprecated—it is a deprecated alias for RECVBUF_ALLOCATOR. Replacing it with RECVBUF_ALLOCATOR properly resolves the deprecation warning with no behavioral change.


142-146: The constant UNLIMITED_DECOMPRESSOR_BUFFER = 0 is correctly implemented. Per Netty's documentation, passing 0 to HttpContentDecompressor's maxAllocation parameter means unlimited buffer size, which aligns with the constant's name and intended usage in createDecompressor() at line 584.

@github-actions
Copy link
Contributor

✅ Gradle check result for bb38a0c: SUCCESS

@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.21%. Comparing base (1022486) to head (bb38a0c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main   #20233   +/-   ##
=========================================
  Coverage     73.20%   73.21%           
+ Complexity    71766    71735   -31     
=========================================
  Files          5795     5795           
  Lines        328302   328304    +2     
  Branches      47283    47283           
=========================================
+ Hits         240345   240352    +7     
- Misses        68628    68668   +40     
+ Partials      19329    19284   -45     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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