You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2024/08/02 05:32:23 UTC
(dubbo) branch 3.2 updated: NPE will occur when consumer lazy init and the consumer thread contextClassLoader is null (#14478)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.2 by this push:
new feceeca631 NPE will occur when consumer lazy init and the consumer thread contextClassLoader is null (#14478)
feceeca631 is described below
commit feceeca631106803d767945a9b05e07b69541f4d
Author: Xwiam <54...@qq.com>
AuthorDate: Fri Aug 2 13:32:18 2024 +0800
NPE will occur when consumer lazy init and the consumer thread contextClassLoader is null (#14478)
* hessian2 readObject NPE bugfix
* format the code
---------
Co-authored-by: wiam <xi...@tuya.com>
---
.../serialize/hessian2/Hessian2ObjectInput.java | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/dubbo-serialization/dubbo-serialization-hessian2/src/main/java/org/apache/dubbo/common/serialize/hessian2/Hessian2ObjectInput.java b/dubbo-serialization/dubbo-serialization-hessian2/src/main/java/org/apache/dubbo/common/serialize/hessian2/Hessian2ObjectInput.java
index 302c78a711..8bb224d545 100644
--- a/dubbo-serialization/dubbo-serialization-hessian2/src/main/java/org/apache/dubbo/common/serialize/hessian2/Hessian2ObjectInput.java
+++ b/dubbo-serialization/dubbo-serialization-hessian2/src/main/java/org/apache/dubbo/common/serialize/hessian2/Hessian2ObjectInput.java
@@ -23,6 +23,7 @@ import org.apache.dubbo.rpc.model.FrameworkModel;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Type;
+import java.util.Objects;
import com.alibaba.com.caucho.hessian.io.Hessian2Input;
@@ -96,9 +97,9 @@ public class Hessian2ObjectInput implements ObjectInput, Cleanable {
@Override
public Object readObject() throws IOException {
- if (!mH2i.getSerializerFactory()
- .getClassLoader()
- .equals(Thread.currentThread().getContextClassLoader())) {
+ if (!Objects.equals(
+ mH2i.getSerializerFactory().getClassLoader(),
+ Thread.currentThread().getContextClassLoader())) {
mH2i.setSerializerFactory(hessian2FactoryManager.getSerializerFactory(
Thread.currentThread().getContextClassLoader()));
}
@@ -108,9 +109,9 @@ public class Hessian2ObjectInput implements ObjectInput, Cleanable {
@Override
@SuppressWarnings("unchecked")
public <T> T readObject(Class<T> cls) throws IOException, ClassNotFoundException {
- if (!mH2i.getSerializerFactory()
- .getClassLoader()
- .equals(Thread.currentThread().getContextClassLoader())) {
+ if (!Objects.equals(
+ mH2i.getSerializerFactory().getClassLoader(),
+ Thread.currentThread().getContextClassLoader())) {
mH2i.setSerializerFactory(hessian2FactoryManager.getSerializerFactory(
Thread.currentThread().getContextClassLoader()));
}
@@ -119,9 +120,9 @@ public class Hessian2ObjectInput implements ObjectInput, Cleanable {
@Override
public <T> T readObject(Class<T> cls, Type type) throws IOException, ClassNotFoundException {
- if (!mH2i.getSerializerFactory()
- .getClassLoader()
- .equals(Thread.currentThread().getContextClassLoader())) {
+ if (!Objects.equals(
+ mH2i.getSerializerFactory().getClassLoader(),
+ Thread.currentThread().getContextClassLoader())) {
mH2i.setSerializerFactory(hessian2FactoryManager.getSerializerFactory(
Thread.currentThread().getContextClassLoader()));
}