mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-18 04:28:40 +00:00
perf[storage]: catch convert exception
This commit is contained in:
@@ -46,10 +46,14 @@ public class ArrayConverter implements ConditionalGenericConverter {
|
||||
return Array.newInstance(componentType, 0);
|
||||
}
|
||||
// 如果为json格式,则以json格式解析
|
||||
if (content.startsWith("[") || content.endsWith("]")) {
|
||||
return componentType.isPrimitive()
|
||||
? JsonUtils.string2Object(content, targetType.getObjectType())
|
||||
: JsonUtils.string2Array(content, componentType);
|
||||
if (content.startsWith("[") && content.endsWith("]")) {
|
||||
try {
|
||||
return componentType.isPrimitive()
|
||||
? JsonUtils.string2Object(content, targetType.getObjectType())
|
||||
: JsonUtils.string2Array(content, componentType);
|
||||
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return ConvertUtils.convertToArray(content, componentType);
|
||||
}
|
||||
|
||||
@@ -54,8 +54,11 @@ public class ListConverter implements ConditionalGenericConverter {
|
||||
} else {
|
||||
clazz = (Class<?>) type;
|
||||
}
|
||||
if (content.startsWith("[") || content.endsWith("]")) {
|
||||
return Collections.unmodifiableList(JsonUtils.string2List(content, clazz));
|
||||
if (content.startsWith("[") && content.endsWith("]")) {
|
||||
try {
|
||||
return Collections.unmodifiableList(JsonUtils.string2List(content, clazz));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return ConvertUtils.convertToList(content, clazz);
|
||||
}
|
||||
|
||||
@@ -53,8 +53,11 @@ public class SetConverter implements ConditionalGenericConverter {
|
||||
} else {
|
||||
clazz = (Class<?>) type;
|
||||
}
|
||||
if (content.startsWith("[") || content.endsWith("]")) {
|
||||
return Collections.unmodifiableSet(JsonUtils.string2Set(content, clazz));
|
||||
if (content.startsWith("[") && content.endsWith("]")) {
|
||||
try {
|
||||
return Collections.unmodifiableSet(JsonUtils.string2Set(content, clazz));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return ConvertUtils.convertToSet(content, clazz);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user