[Enhancement] Socket Channel may be null if error or crash during `client-side` connecting
- Dominant language
- Java
- Stars
- 1.8k
- Forks
- 658
- Avg merge
- 11h 29m
- Merged PRs (30d)
- 52
Description
### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/eventmesh/issues?q=is%3Aissue) and found no similar issues.
### Enhancement Request
Locating at: org/apache/eventmesh/client/tcp/common/TcpClient.java
Line: 118
the implementation of `close()`
```java
try{
channel.disconnect().sync();
// ...
} catch {
// ...
}
```
`close()` would be called
- call func explicitly
- call func in `finally` block for resource safety
- deffer implicitly caz `try()`
socket will fail if the error or crash is on `bind()`, `channel` reference will be Null
### Describe the solution you'd like
Removing `channel.disconnect().sync(); `, resources will be closed with the determination of `EventLoopGroup`
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
Contributor guide
Research direction
Start in org/apache/eventmesh/client/tcp/common/TcpClient.java around line 118 and inspect how close() behaves when bind() fails before channel is initialized. Trace the resource-cleanup path through EventLoopGroup and verify that closing after a connection error or crash does not dereference a null channel and that resources are released.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100