dubbo [Bug] NPE will occur when consumer lazy init and the consumer thread contextClassLoader is null

bq8i3lrv  于 4个月前  发布在  其他
关注(0)|答案(2)|浏览(37)

Pre-check

  • I am sure that all the content I provide is in English.

Search before asking

  • I had searched in the issues and found no similar issues.

Apache Dubbo Component

Java SDK (apache/dubbo)

Dubbo Version

3.2.0

Steps to reproduce this issue

1、consumer lazy init config
dubbo:consumer init=false
2、start your dubbo service
3、use arthas to invoke your dubbo service
you will get the NPE Exception

What you expected to happen

the invoke will be ok,not throw NPE Exception

Anything else

No response

Are you willing to submit a pull request to fix on your own?

  • Yes I am willing to submit a pull request on my own!

Code of Conduct

deyfvvtc

deyfvvtc2#

when mH2i.getSerializerFactory().getClassLoader() is null , the NPE exception will occur

https://github.com/apache/dubbo/blob/3.2/dubbo-serialization/dubbo-serialization-hessian2/src/main/java/org/apache/dubbo/common/serialize/hessian2/Hessian2ObjectInput.java#L113

public T readObject(Class cls, Type type) throws IOException, ClassNotFoundException {
if (!mH2i.getSerializerFactory().getClassLoader().equals(Thread.currentThread().getContextClassLoader())) {
mH2i.setSerializerFactory(hessian2FactoryManager.getSerializerFactory(Thread.currentThread().getContextClassLoader()));
}
return readObject(cls);
}

相关问题