From ad6760a0ddd7f52f6498f1ce1ff905913995b3b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=8C=E5=A4=AB?= Date: Tue, 7 Aug 2018 11:35:21 +0800 Subject: [PATCH] serialization-java8-date/time --- .../apache/dubbo/common/serialize/kryo/CompatibleKryo.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dubbo-serialization/dubbo-serialization-kryo/src/main/java/org/apache/dubbo/common/serialize/kryo/CompatibleKryo.java b/dubbo-serialization/dubbo-serialization-kryo/src/main/java/org/apache/dubbo/common/serialize/kryo/CompatibleKryo.java index dcd000767b0..eaeaaf242c6 100644 --- a/dubbo-serialization/dubbo-serialization-kryo/src/main/java/org/apache/dubbo/common/serialize/kryo/CompatibleKryo.java +++ b/dubbo-serialization/dubbo-serialization-kryo/src/main/java/org/apache/dubbo/common/serialize/kryo/CompatibleKryo.java @@ -24,6 +24,10 @@ import com.esotericsoftware.kryo.Serializer; import com.esotericsoftware.kryo.serializers.JavaSerializer; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; + public class CompatibleKryo extends Kryo { private static final Logger logger = LoggerFactory.getLogger(CompatibleKryo.class); @@ -34,7 +38,7 @@ public Serializer getDefaultSerializer(Class type) { throw new IllegalArgumentException("type cannot be null."); } - if (!type.isArray() && !type.isEnum() && !ReflectionUtils.checkZeroArgConstructor(type)) { + if (!type.isArray() && !type.isEnum() && !type.equals(LocalDate.class) && !type.equals(LocalDateTime.class) && !type.equals(LocalTime.class) && !ReflectionUtils.checkZeroArgConstructor(type)) { if (logger.isWarnEnabled()) { logger.warn(type + " has no zero-arg constructor and this will affect the serialization performance"); }