This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.0 by this push:
     new 16b3d42  Remove needless toString convert & Enable checking by default 
(#8073)
16b3d42 is described below

commit 16b3d42c7aa4694b365c0d1bf57c8c712a32965e
Author: Albumen Kevin <[email protected]>
AuthorDate: Wed Jun 16 20:07:03 2021 +0800

    Remove needless toString convert & Enable checking by default (#8073)
    
    * Remove needless toString convert & Enable checking by default
    
    * enable check
---
 .../org/apache/dubbo/common/utils/PojoUtils.java   | 24 +++++++++++++---------
 .../protocol/dubbo/DecodeableRpcInvocation.java    |  2 +-
 .../rpc/protocol/dubbo/DecodeableRpcResult.java    |  2 +-
 3 files changed, 16 insertions(+), 12 deletions(-)

diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/PojoUtils.java 
b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/PojoUtils.java
index 53238dd..1a8330a 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/utils/PojoUtils.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/PojoUtils.java
@@ -189,7 +189,7 @@ public class PojoUtils {
                     if (history.containsKey(pojo)) {
                         Object pojoGeneralizedValue = history.get(pojo);
                         if (pojoGeneralizedValue instanceof Map
-                                && ((Map) 
pojoGeneralizedValue).containsKey(field.getName())) {
+                            && ((Map) 
pojoGeneralizedValue).containsKey(field.getName())) {
                             continue;
                         }
                     }
@@ -312,9 +312,9 @@ public class PojoUtils {
         }
 
         if (ReflectUtils.isPrimitives(pojo.getClass())
-                && !(type != null && type.isArray()
-                && type.getComponentType().isEnum()
-                && pojo.getClass() == String[].class)) {
+            && !(type != null && type.isArray()
+            && type.getComponentType().isEnum()
+            && pojo.getClass() == String[].class)) {
             return CompatibleTypeUtils.compatibleTypeConvert(pojo, type);
         }
 
@@ -399,7 +399,11 @@ public class PojoUtils {
             if (type.isEnum()) {
                 Object name = ((Map<Object, Object>) pojo).get("name");
                 if (name != null) {
-                    return Enum.valueOf((Class<Enum>) type, name.toString());
+                    if (!(name instanceof String)) {
+                        throw new IllegalArgumentException("`name` filed 
should be string!");
+                    } else {
+                        return Enum.valueOf((Class<Enum>) type, (String) name);
+                    }
                 }
             }
             Map<Object, Object> map;
@@ -426,8 +430,8 @@ public class PojoUtils {
                 Type mapKeyType = getKeyTypeForMap(map.getClass());
                 Type typeKeyType = getGenericClassByIndex(genericType, 0);
                 boolean typeMismatch = mapKeyType instanceof Class
-                        && typeKeyType instanceof Class
-                        && 
!typeKeyType.getTypeName().equals(mapKeyType.getTypeName());
+                    && typeKeyType instanceof Class
+                    && 
!typeKeyType.getTypeName().equals(mapKeyType.getTypeName());
                 if (typeMismatch) {
                     result = createMap(new HashMap(0));
                 } else {
@@ -485,7 +489,7 @@ public class PojoUtils {
                                     method.invoke(dest, value);
                                 } catch (Exception e) {
                                     String exceptionDescription = "Failed to 
set pojo " + dest.getClass().getSimpleName() + " property " + name
-                                            + " value " + value + "(" + 
value.getClass() + "), cause: " + e.getMessage();
+                                        + " value " + value.getClass() + ", 
cause: " + e.getMessage();
                                     logger.error(exceptionDescription, e);
                                     throw new 
RuntimeException(exceptionDescription, e);
                                 }
@@ -663,8 +667,8 @@ public class PojoUtils {
 
     public static boolean isPojo(Class<?> cls) {
         return !ReflectUtils.isPrimitives(cls)
-                && !Collection.class.isAssignableFrom(cls)
-                && !Map.class.isAssignableFrom(cls);
+            && !Collection.class.isAssignableFrom(cls)
+            && !Map.class.isAssignableFrom(cls);
     }
 
     /**
diff --git 
a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcInvocation.java
 
b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcInvocation.java
index afedeeb..91ebb81 100644
--- 
a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcInvocation.java
+++ 
b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcInvocation.java
@@ -123,7 +123,7 @@ public class DecodeableRpcInvocation extends RpcInvocation 
implements Codec, Dec
         setParameterTypesDesc(desc);
 
         try {
-            if 
(ConfigurationUtils.getSystemConfiguration().getBoolean(SERIALIZATION_SECURITY_CHECK_KEY,
 false)) {
+            if 
(ConfigurationUtils.getSystemConfiguration().getBoolean(SERIALIZATION_SECURITY_CHECK_KEY,
 true)) {
                 CodecSupport.checkSerialization(path, version, 
serializationType);
             }
             Object[] args = DubboCodec.EMPTY_OBJECT_ARRAY;
diff --git 
a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcResult.java
 
b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcResult.java
index 30ee3a0..cb7a41a 100644
--- 
a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcResult.java
+++ 
b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcResult.java
@@ -118,7 +118,7 @@ public class DecodeableRpcResult extends AppResponse 
implements Codec, Decodeabl
     public void decode() throws Exception {
         if (!hasDecoded && channel != null && inputStream != null) {
             try {
-                if 
(ConfigurationUtils.getSystemConfiguration().getBoolean(SERIALIZATION_SECURITY_CHECK_KEY,
 false)) {
+                if 
(ConfigurationUtils.getSystemConfiguration().getBoolean(SERIALIZATION_SECURITY_CHECK_KEY,
 true)) {
                     Object serializationType_obj = 
invocation.get(SERIALIZATION_ID_KEY);
                     if (serializationType_obj != null) {
                         if ((byte) serializationType_obj != serializationType) 
{

Reply via email to