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 302c78a7119..8bb224d5452 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 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 String readUTF() throws IOException { @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 Object readObject() throws IOException { @Override @SuppressWarnings("unchecked") public T readObject(Class 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 T readObject(Class cls) throws IOException, ClassNotFoundException @Override public T readObject(Class 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())); }