diaohancai opened a new issue, #7749:
URL: https://github.com/apache/rocketmq/issues/7749

   ### Before Creating the Bug Report
   
   - [X] I found a bug, not just asking a question, which should be created in 
[GitHub Discussions](https://github.com/apache/rocketmq/discussions).
   
   - [X] I have searched the [GitHub 
Issues](https://github.com/apache/rocketmq/issues) and [GitHub 
Discussions](https://github.com/apache/rocketmq/discussions)  of this 
repository and believe that this is not a duplicate.
   
   - [X] I have confirmed that this bug belongs to the current repository, not 
other repositories of RocketMQ.
   
   
   ### Runtime platform environment
   
   Don't care.
   
   ### RocketMQ version
   
   branch: 4.9.x
   
   ### JDK Version
   
   Don't care.
   
   ### Describe the Bug
   
   `org.apache.rocketmq.remoting.netty.NettyRemotingAbstract#invokeSyncImpl`
   ```java
   channel.writeAndFlush(request).addListener(new ChannelFutureListener() {
        @Override
        public void operationComplete(ChannelFuture f) throws Exception {
                if (f.isSuccess()) {
                        responseFuture.setSendRequestOK(true);
                        return;
                } else {
                        responseFuture.setSendRequestOK(false);
                }
   
                responseTable.remove(opaque);
                responseFuture.setCause(f.cause());
                responseFuture.putResponse(null);
                log.warn("send a request command to channel <" + addr + "> 
failed.");
        }
   });
   
   RemotingCommand responseCommand = responseFuture.waitResponse(timeoutMillis);
   ```
   
   `org.apache.rocketmq.remoting.netty.ResponseFuture#putResponse`
   ```
   public void putResponse(final RemotingCommand responseCommand) {
        this.responseCommand = responseCommand;
        this.countDownLatch.countDown();
   }
   ```
   
   1. `responseFuture.waitResponse(timeoutMillis);` -> 
`this.countDownLatch.await(timeoutMillis, TimeUnit.MILLISECONDS);` use 
`countDownLatch` to wait for asynchronous response.
   2. If `f.isSuccess() == false`, then call 
`responseFuture.putResponse(null);` to `countDownLatch.countDown()`.
   3. But if `f.isSuccess() == true`, did not to `countDownLatch.countDown()`, 
cause `responseFuture.waitResponse(timeoutMillis);` always timeout after 
`timeoutMillis`.
   
   ### Steps to Reproduce
   
   Don't care.
   
   ### What Did You Expect to See?
   
   If `f.isSuccess() == true`, also `countDownLatch.countDown()`.
   And `RemotingCommand responseCommand = 
responseFuture.waitResponse(timeoutMillis);` is no need to wait for timeout.
   
   ### What Did You See Instead?
   
   Nothing.
   
   ### Additional Context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@rocketmq.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to