apache / apache/rocketmq

[Code Quality] Make org.apache.rocketmq.remoting.netty.NettyRemotingAbstract#processResponseCommand more reasonable.

Open
#2,578 0 comments 0 reactions 0 assignees View on GitHub
no stale type/code style
Dominant language
Java
Stars
22.6k
Forks
12k
Avg merge
2d 20h
Merged PRs (30d)
26

Description

**FEATURE REQUEST**

1. Please describe the feature you are requesting.
```
public void processResponseCommand(ChannelHandlerContext ctx, RemotingCommand cmd) {
final int opaque = cmd.getOpaque();
final ResponseFuture responseFuture = responseTable.get(opaque);
if (responseFuture != null) {
responseFuture.setResponseCommand(cmd);

responseTable.remove(opaque);

if (responseFuture.getInvokeCallback() != null) {
executeInvokeCallback(responseFuture);
} else {
responseFuture.putResponse(cmd);
responseFuture.release();
}
} else {
log.warn("receive response, but not matched any request, " + RemotingHelper.parseChannelRemoteAddr(ctx.channel()));
log.warn(cmd.toString());
}
}
```
`responseFuture.setResponseCommand(cmd);` is repeat operation with `responseFuture.putResponse(cmd);`.
Just execute in `if (responseFuture.getInvokeCallback() != null)` code block.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.