소스 검색

反序列化枚举时,将空字符串识别为null

zhou-hao 4 년 전
부모
커밋
91c266429c
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      hsweb-core/src/main/java/org/hswebframework/web/dict/EnumDict.java

+ 2 - 1
hsweb-core/src/main/java/org/hswebframework/web/dict/EnumDict.java

@@ -20,6 +20,7 @@ import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.hswebframework.web.exception.ValidationException;
 import org.springframework.beans.BeanUtils;
+import org.springframework.util.StringUtils;
 
 import java.io.IOException;
 import java.lang.reflect.Type;
@@ -349,7 +350,7 @@ public interface EnumDict<V> extends JSONSerializable {
             String currentName = jp.currentName();
             Object currentValue = jp.getCurrentValue();
             Class findPropertyType;
-            if (currentName == null || currentValue == null) {
+            if (StringUtils.isEmpty(currentName) || StringUtils.isEmpty(currentValue)) {
                 return null;
             } else {
                 findPropertyType = BeanUtils.findPropertyType(currentName, currentValue.getClass());