移除fst依赖
This commit is contained in:
@@ -46,13 +46,6 @@
|
|||||||
<version>${commons-io.version}</version>
|
<version>${commons-io.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Java serialization -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>de.ruedigermoeller</groupId>
|
|
||||||
<artifactId>fst</artifactId>
|
|
||||||
<version>${fst.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Jackson json -->
|
<!-- Jackson json -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
|||||||
@@ -5,11 +5,9 @@
|
|||||||
package com.jeesite.common.lang;
|
package com.jeesite.common.lang;
|
||||||
|
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.nustaq.serialization.FSTConfiguration;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.core.NamedThreadLocal;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@@ -24,7 +22,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
*/
|
*/
|
||||||
public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
|
public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(ObjectUtils.class);
|
private static final Logger logger = LoggerFactory.getLogger(ObjectUtils.class);
|
||||||
private static final boolean isJavaSerialize;
|
private static final boolean isJavaSerialize;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@@ -164,11 +162,7 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
|
|||||||
*/
|
*/
|
||||||
public static byte[] serialize(Object object) {
|
public static byte[] serialize(Object object) {
|
||||||
try {
|
try {
|
||||||
if (isJavaSerialize) {
|
return ObjectUtils.serializeJava(object);
|
||||||
return ObjectUtils.serializeJava(object);
|
|
||||||
}else {
|
|
||||||
return ObjectUtils.serializeFst(object);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("serialize: {}", e.getMessage());
|
logger.error("serialize: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -182,11 +176,7 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
|
|||||||
*/
|
*/
|
||||||
public static Object unserialize(byte[] bytes) {
|
public static Object unserialize(byte[] bytes) {
|
||||||
try {
|
try {
|
||||||
if (isJavaSerialize) {
|
return ObjectUtils.unserializeJava(bytes);
|
||||||
return ObjectUtils.unserializeJava(bytes);
|
|
||||||
}else {
|
|
||||||
return ObjectUtils.unserializeFst(bytes);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("unserialize: {}", e.getMessage());
|
logger.error("unserialize: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -244,49 +234,49 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ThreadLocal<FSTConfiguration> fstConfiguration =
|
// private static ThreadLocal<FSTConfiguration> fstConfiguration =
|
||||||
new NamedThreadLocal<FSTConfiguration>("FSTConfiguration") {
|
// new NamedThreadLocal<FSTConfiguration>("FSTConfiguration") {
|
||||||
@Override
|
// @Override
|
||||||
public FSTConfiguration initialValue() {
|
// public FSTConfiguration initialValue() {
|
||||||
return FSTConfiguration.createDefaultConfiguration();
|
// return FSTConfiguration.createDefaultConfiguration();
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* FST 序列化对象
|
// * FST 序列化对象
|
||||||
* @param object
|
// * @param object
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
public static byte[] serializeFst(Object object) {
|
// public static byte[] serializeFst(Object object) {
|
||||||
if (object == null){
|
// if (object == null){
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
long beginTime = System.currentTimeMillis();
|
// long beginTime = System.currentTimeMillis();
|
||||||
byte[] bytes = fstConfiguration.get().asByteArray(object);
|
// byte[] bytes = fstConfiguration.get().asByteArray(object);
|
||||||
long totalTime = System.currentTimeMillis() - beginTime;
|
// long totalTime = System.currentTimeMillis() - beginTime;
|
||||||
if (totalTime > 30000){
|
// if (totalTime > 30000){
|
||||||
logger.warn(object.getClass() + " fst serialize time: " + TimeUtils.formatTime(totalTime));
|
// logger.warn(object.getClass() + " fst serialize time: " + TimeUtils.formatTime(totalTime));
|
||||||
}
|
// }
|
||||||
return bytes;
|
// return bytes;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* FST 反序列化对象
|
// * FST 反序列化对象
|
||||||
* @param bytes
|
// * @param bytes
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
public static Object unserializeFst(byte[] bytes) {
|
// public static Object unserializeFst(byte[] bytes) {
|
||||||
if (bytes == null){
|
// if (bytes == null){
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
long beginTime = System.currentTimeMillis();
|
// long beginTime = System.currentTimeMillis();
|
||||||
Object object = fstConfiguration.get().asObject(bytes);
|
// Object object = fstConfiguration.get().asObject(bytes);
|
||||||
long totalTime = System.currentTimeMillis() - beginTime;
|
// long totalTime = System.currentTimeMillis() - beginTime;
|
||||||
if (totalTime > 30000 && object != null){
|
// if (totalTime > 30000 && object != null){
|
||||||
logger.warn(object.getClass() + " fst unserialize time: " + TimeUtils.formatTime(totalTime));
|
// logger.warn(object.getClass() + " fst unserialize time: " + TimeUtils.formatTime(totalTime));
|
||||||
}
|
// }
|
||||||
return object;
|
// return object;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// private static Pool<Kryo> kryoPool = new Pool<Kryo>(true, false, 8) {
|
// private static Pool<Kryo> kryoPool = new Pool<Kryo>(true, false, 8) {
|
||||||
// protected Kryo create() {
|
// protected Kryo create() {
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
<jackson-bom2.version>2.17.1</jackson-bom2.version>
|
<jackson-bom2.version>2.17.1</jackson-bom2.version>
|
||||||
<fastjson.version>2.0.51</fastjson.version>
|
<fastjson.version>2.0.51</fastjson.version>
|
||||||
<fst.version>3.0.4-jdk17</fst.version>
|
|
||||||
|
|
||||||
<snakeyaml.version>2.2</snakeyaml.version>
|
<snakeyaml.version>2.2</snakeyaml.version>
|
||||||
<glassfish-jaxb.version>2.3.9</glassfish-jaxb.version>
|
<glassfish-jaxb.version>2.3.9</glassfish-jaxb.version>
|
||||||
|
|||||||
Reference in New Issue
Block a user