[Bug] NettyConnectionHandler.channelInactive() does not remove channel from CHANNEL_MAP causing memory leak
- Dominant language
- Java
- Stars
- 41.6k
- Forks
- 26.4k
- Avg merge
- 15h 13m
- Merged PRs (30d)
- 4
Description
### Pre-check
- [x] I am sure that all the content I provide is in English.
### Search before asking
- [x] I had searched in the [issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no similar issues.
### Apache Dubbo Component
Java SDK (apache/dubbo)
### Dubbo Version
- Dubbo version: dubbo-dubbo.3.2.19
- Java version: 1.8
- OS: Linux
- Protocol: Triple (tri://)
### Steps to reproduce this issue
1. Configure a Dubbo consumer to call a Triple protocol service
2. The Triple service endpoint is unreachable or TLS handshake fails
3. Connection continuously fails and reconnects every second
4. Observe CHANNEL_MAP size growing unbounded
### What you expected to happen
When `channelInactive` is called, the channel should be removed from `CHANNEL_MAP` to prevent memory leak.
`NettyConnectionHandler.channelInactive()` only calls `reconnect()` but does NOT call `NettyChannel.removeChannel()`, causing channels to accumulate in `CHANNEL_MAP`.
**NettyConnectionHandler.java (BUG):**
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
super.channelInactive(ctx);
final Attribute goawayAttr = ctx.channel().attr(GO_AWAY_KEY);
if (!Boolean.TRUE.equals(goawayAttr.get())) {
reconnect(ctx.channel());
}
// ❌ Missing: NettyChannel.removeChannel(ctx.channel())
}
### Anything else
_No response_
### Do you have a (mini) reproduction demo?
- [x] Yes, I have a minimal reproduction demo to help resolve this issue more effectively!
### Are you willing to submit a pull request to fix on your own?
- [x] Yes I am willing to submit a pull request on my own!
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
Contributor guide
Research direction
Start with NettyConnectionHandler.java and inspect channelInactive(), then trace NettyChannel.removeChannel() and CHANNEL_MAP. Reproduce the unreachable-endpoint or failed-TLS reconnect scenario and verify that inactive channels no longer accumulate in CHANNEL_MAP.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design, distributed-systems
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100