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 f069151baac..b7beb7d7938 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 @@ private static Object realize0(Object pojo, Class type, Type genericType, fin // special logic for enum if (type.isEnum()) { Object name = ((Map) pojo).get("name"); - if (name != null) { - return Enum.valueOf((Class) type, name.toString()); + if (!(name instanceof String)) { + throw new IllegalArgumentException("`name` filed should be string!"); + } else { + return Enum.valueOf((Class) type, (String) name); } } Map map; @@ -455,7 +457,7 @@ private static Object realize0(Object pojo, Class type, Type genericType, fin } 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);