Skip to content

Commit

Permalink
Fix on branch master, consumer invoke timeout cause NPE. (#8587)
Browse files Browse the repository at this point in the history
* Fix on branch master, consumer invoke timeout cause NPE.

* use Camel-Case rule
  • Loading branch information
wangchengming666 committed Aug 25, 2021
1 parent fd80172 commit 4c8a54e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
Expand Up @@ -118,11 +118,13 @@ public Object decode(Channel channel, InputStream input) throws IOException {
public void decode() throws Exception {
if (!hasDecoded && channel != null && inputStream != null) {
try {
if (ConfigurationUtils.getSystemConfiguration().getBoolean(SERIALIZATION_SECURITY_CHECK_KEY, false)) {
Object serializationType_obj = invocation.get(SERIALIZATION_ID_KEY);
if (serializationType_obj != null) {
if ((byte) serializationType_obj != serializationType) {
throw new IOException("Unexpected serialization id:" + serializationType + " received from network, please check if the peer send the right id.");
if (invocation != null) {
if (ConfigurationUtils.getSystemConfiguration().getBoolean(SERIALIZATION_SECURITY_CHECK_KEY, false)) {
Object serializationTypeObj = invocation.get(SERIALIZATION_ID_KEY);
if (serializationTypeObj != null) {
if ((byte) serializationTypeObj != serializationType) {
throw new IOException("Unexpected serialization id:" + serializationType + " received from network, please check if the peer send the right id.");
}
}
}
}
Expand Down
Expand Up @@ -30,21 +30,21 @@
public class DubboCodecSupport {

public static Serialization getRequestSerialization(URL url, Invocation invocation) {
Object serializationType_obj = invocation.get(SERIALIZATION_ID_KEY);
if (serializationType_obj != null) {
return CodecSupport.getSerializationById((byte) serializationType_obj);
Object serializationTypeObj = invocation.get(SERIALIZATION_ID_KEY);
if (serializationTypeObj != null) {
return CodecSupport.getSerializationById((byte) serializationTypeObj);
}
return ExtensionLoader.getExtensionLoader(Serialization.class).getExtension(
url.getParameter(org.apache.dubbo.remoting.Constants.SERIALIZATION_KEY, Constants.DEFAULT_REMOTING_SERIALIZATION));
}

public static Serialization getResponseSerialization(URL url, AppResponse appResponse) {
Object invocation_obj = appResponse.getAttribute(INVOCATION_KEY);
if (invocation_obj != null) {
Invocation invocation = (Invocation) invocation_obj;
Object serializationType_obj = invocation.get(SERIALIZATION_ID_KEY);
if (serializationType_obj != null) {
return CodecSupport.getSerializationById((byte) serializationType_obj);
Object invocationObj = appResponse.getAttribute(INVOCATION_KEY);
if (invocationObj != null) {
Invocation invocation = (Invocation) invocationObj;
Object serializationTypeObj = invocation.get(SERIALIZATION_ID_KEY);
if (serializationTypeObj != null) {
return CodecSupport.getSerializationById((byte) serializationTypeObj);
}
}
return ExtensionLoader.getExtensionLoader(Serialization.class).getExtension(
Expand Down

0 comments on commit 4c8a54e

Please sign in to comment.