Open iSenninha opened 4 years ago
感谢反馈,我们review 一下这个情况
确认, 需要升级netty最版本
Thread [main] (Suspended)
owns: ProtobufRpcProxy
waiting for: DefaultChannelPromise (id=99)
Object.wait(long) line: not available [native method] [local variables unavailable]
DefaultChannelPromise(Object).wait() line: 502 [local variables unavailable]
DefaultChannelPromise(DefaultPromise
DefaultChannelPromise.awaitUninterruptibly() line: 135
DefaultChannelPromise.awaitUninterruptibly() line: 28
ChannelPoolObjectFactory.wrap(Connection) line: 88
ChannelPoolObjectFactory.wrap(Object) line: 1
ChannelPoolObjectFactory(BasePooledObjectFactory
GenericObjectPool
GenericObjectPool
ChannelPool.getChannel() line: 79
RpcChannel.testChannlConnect() line: 49
ProtobufRpcProxy
TestRpcHang.testRpcHang() line: 30
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
Method.invoke(Object, Object...) line: 497
FrameworkMethod$1.runReflectiveCall() line: 50
FrameworkMethod$1(ReflectiveCallable).run() line: 12
FrameworkMethod.invokeExplosively(Object, Object...) line: 47
InvokeMethod.evaluate() line: 17
BlockJUnit4ClassRunner(ParentRunner
BlockJUnit4ClassRunner.runChild(FrameworkMethod, RunNotifier) line: 78
BlockJUnit4ClassRunner.runChild(Object, RunNotifier) line: 57
ParentRunner$3.run() line: 290
ParentRunner$1.schedule(Runnable) line: 71
BlockJUnit4ClassRunner(ParentRunner
ParentRunner
ParentRunner$2.evaluate() line: 268
BlockJUnit4ClassRunner(ParentRunner
JUnit4TestReference.run(TestExecution) line: 89
TestExecution.run(ITestReference[]) line: 41
RemoteTestRunner.runTests(String[], String, TestExecution) line: 541
RemoteTestRunner.runTests(TestExecution) line: 763
RemoteTestRunner.run() line: 463
RemoteTestRunner.main(String[]) line: 209
RpcClient建立连接过程中是同步等待在这里:
如果上述连接未建立完成/连接失败,并且RpcClient过早暴露并被其他线程执行shutdown,上面的线程无法再被唤醒。
无法被唤醒的具体原因是依赖的Netty 4.0.27.Final shutdown 的时候没有处理未完成连接的channel等待的DefaultChannelPromise。最新版的Netty已经修复这个bug。
Bug复现:
环境信息
import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors;
/**
纯Netty版复现: