mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-12 20:16:07 +00:00
perf[storage]: catch convert exception
This commit is contained in:
1 parent
1f7b76dbbb
commit
06898096b0
3 files changed
+18
-8
No files matched your search
@@ -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