支持jdk17
This commit is contained in:
@@ -26,6 +26,12 @@ import org.springframework.core.NamedThreadLocal;
|
||||
public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ObjectUtils.class);
|
||||
private static final boolean isJavaSerialize;
|
||||
|
||||
static {
|
||||
String[] ver = StringUtils.split(System.getProperty("java.version"), '.');
|
||||
isJavaSerialize = ver.length > 0 && Integer.parseInt(ver[0]) > 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为 Double 类型
|
||||
@@ -155,7 +161,11 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
|
||||
* @return
|
||||
*/
|
||||
public static byte[] serialize(Object object) {
|
||||
return ObjectUtils.serializeFst(object);
|
||||
if (isJavaSerialize) {
|
||||
return ObjectUtils.serializeJava(object);
|
||||
}else {
|
||||
return ObjectUtils.serializeFst(object);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,7 +174,11 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
|
||||
* @return
|
||||
*/
|
||||
public static Object unserialize(byte[] bytes) {
|
||||
return ObjectUtils.unserializeFst(bytes);
|
||||
if (isJavaSerialize) {
|
||||
return ObjectUtils.unserializeJava(bytes);
|
||||
}else {
|
||||
return ObjectUtils.unserializeFst(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,7 +226,7 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
|
||||
}
|
||||
}
|
||||
long totalTime = System.currentTimeMillis() - beginTime;
|
||||
if (totalTime > 3000){
|
||||
if (totalTime > 3000 && object != null){
|
||||
logger.warn(object.getClass() + " unserialize time: " + TimeUtils.formatDateAgo(totalTime));
|
||||
}
|
||||
return object;
|
||||
@@ -255,7 +269,7 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
|
||||
long beginTime = System.currentTimeMillis();
|
||||
Object object = fstConfiguration.get().asObject(bytes);
|
||||
long totalTime = System.currentTimeMillis() - beginTime;
|
||||
if (totalTime > 3000){
|
||||
if (totalTime > 3000 && object != null){
|
||||
logger.warn(object.getClass() + " fst unserialize time: " + TimeUtils.formatDateAgo(totalTime));
|
||||
}
|
||||
return object;
|
||||
|
||||
Reference in New Issue
Block a user