From 8c8610f9121d19bf7108903e41276d5f6afaa81a Mon Sep 17 00:00:00 2001 From: Jaskey Date: Sat, 27 May 2017 11:22:46 +0800 Subject: [PATCH] [ROCKETMQ-188]RemotingExecption is not consistent between invoke async and invoke oneway closes apache/incubator-rocketmq#98 --- .../remoting/netty/NettyRemotingAbstract.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java index cddab3d7..15586cbf 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java @@ -417,14 +417,18 @@ public abstract class NettyRemotingAbstract { throw new RemotingSendRequestException(RemotingHelper.parseChannelRemoteAddr(channel), e); } } else { - String info = - String.format("invokeAsyncImpl tryAcquire semaphore timeout, %dms, waiting thread nums: %d semaphoreAsyncValue: %d", // - timeoutMillis, // - this.semaphoreAsync.getQueueLength(), // - this.semaphoreAsync.availablePermits()// - ); - PLOG.warn(info); - throw new RemotingTooMuchRequestException(info); + if (timeoutMillis <= 0) { + throw new RemotingTooMuchRequestException("invokeAsyncImpl invoke too fast"); + } else { + String info = + String.format("invokeAsyncImpl tryAcquire semaphore timeout, %dms, waiting thread nums: %d semaphoreAsyncValue: %d", // + timeoutMillis, // + this.semaphoreAsync.getQueueLength(), // + this.semaphoreAsync.availablePermits()// + ); + PLOG.warn(info); + throw new RemotingTimeoutException(info); + } } } -- GitLab