You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2018/08/03 06:43:42 UTC

[GitHub] kennyliao1982 opened a new issue #2178: please consider supporting Java 8 Date/Time type when serializing with Kryo

kennyliao1982 opened a new issue #2178: please consider supporting Java 8 Date/Time type when serializing with Kryo
URL: https://github.com/apache/incubator-dubbo/issues/2178
 
 
   ### Environment
   
   * Dubbo version: 2.6.2
   * Java version: 1.8
   
   I am using java.time.LocalDateTime and Dubbo complains "**class java.time.LocalDateTime has no zero-arg constructor and this will affect the serialization performance**", which is caused by Dubbo's wrapper class "**CompatibleKryo**"
   
   Any thoughts ??
   
   ```
   package com.alibaba.dubbo.common.serialize.kryo;
   
   import com.alibaba.dubbo.common.logger.Logger;
   import com.alibaba.dubbo.common.logger.LoggerFactory;
   import com.alibaba.dubbo.common.serialize.kryo.utils.ReflectionUtils;
   
   import com.esotericsoftware.kryo.Kryo;
   import com.esotericsoftware.kryo.Serializer;
   import com.esotericsoftware.kryo.serializers.JavaSerializer;
   
   public class CompatibleKryo extends Kryo {
   
       private static final Logger logger = LoggerFactory.getLogger(CompatibleKryo.class);
   
       @Override
       public Serializer getDefaultSerializer(Class type) {
           if (type == null) {
               throw new IllegalArgumentException("type cannot be null.");
           }
   
           if (!type.isArray() && !type.isEnum() && !ReflectionUtils.checkZeroArgConstructor(type)) {
               if (logger.isWarnEnabled()) {
                   logger.warn(type + " has no zero-arg constructor and this will affect the serialization performance");
               }
               return new JavaSerializer();
           }
           return super.getDefaultSerializer(type);
       }
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org