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 2021/06/18 05:30:02 UTC

[dubbo] branch 2.6.x updated: Remove needless toString convert (#8093)

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

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


The following commit(s) were added to refs/heads/2.6.x by this push:
     new 3f1e3f4  Remove needless toString convert (#8093)
3f1e3f4 is described below

commit 3f1e3f491df7130f8018ecce7765413b0205a8fb
Author: Albumen Kevin <jh...@gmail.com>
AuthorDate: Fri Jun 18 13:29:38 2021 +0800

    Remove needless toString convert (#8093)
---
 .../src/main/java/com/alibaba/dubbo/common/utils/PojoUtils.java   | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/PojoUtils.java b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/PojoUtils.java
index f069151..b7beb7d 100644
--- a/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/PojoUtils.java
+++ b/dubbo-common/src/main/java/com/alibaba/dubbo/common/utils/PojoUtils.java
@@ -382,8 +382,10 @@ public class PojoUtils {
             // special logic for enum
             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;
@@ -455,7 +457,7 @@ public class PojoUtils {
                                 } catch (Exception e) {
                                     e.printStackTrace();
                                     throw new RuntimeException("Failed to set pojo " + dest.getClass().getSimpleName() + " property " + name
-                                            + " value " + value + "(" + value.getClass() + "), cause: " + e.getMessage(), e);
+                                            + " value " + value.getClass() + ", cause: " + e.getMessage(), e);
                                 }
                             } else if (field != null) {
                                 value = realize0(value, field.getType(), field.getGenericType(), history);