tang-jie / NettyRPC

NettyRPC is high performance java rpc server base on Netty,using kryo,hessian,protostuff support message serialization.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

客户端并发调用,dump看了一下大量线程阻塞在一个地方

yeyincai opened this issue · comments

commented

MessageCallBack类

public Object start() throws InterruptedException {
        try {
            lock.lock();
            finish.await(10 * 1000, TimeUnit.MILLISECONDS);
            if (this.response != null) {
                return this.response.getResult();
            } else {
                return null;
            }
        } finally {
            lock.unlock();
        }
 }

不明白这句代码何意 finish.await(10 * 1000, TimeUnit.MILLISECONDS); 一定要嘛?

这个是用来等待服务端发送过来的RPC调用执行结果消息用的。

当单线程循环调试某个方式时,出现bug,这样改是否更合理?

lock.lock();
if(this.response==null){
    //限定时间内未被唤醒则抛出异常
    if(!finish.await(RpcSystemConfig.SYSTEM_PROPERTY_MESSAGE_CALLBACK_TIMEOUT, TimeUnit.MILLISECONDS)){
        throw new InvokeTimeoutException(RpcSystemConfig.TIMEOUT_RESPONSE_MSG);
    }
}
if (this.response != null) {