Giter Site home page Giter Site logo

kryo-serializers's Introduction

A project that provides kryo (v2, v3, v4) serializers for some jdk types and some external libs like e.g. joda time.

Build Status Coverage Status Maven Central

Provided serializers / supporting classes:

  • ArraysAsListSerializer - serializer for lists created via Arrays#asList(Object...)

  • CollectionsEmptyListSerializer - for Collections#EMPTY_LIST or lists created via Collections#emptyList()

  • CollectionsEmptyMapSerializer - for Collections#EMPTY_MAP or maps created via Collections#emptyMap()

  • CollectionsEmptySetSerializer - for Collections#EMPTY_SET or sets created via Collections#emptySet()

  • CollectionsSingletonListSerializer - for lists created via Collections#singletonList(Object)

  • CollectionsSingletonMapSerializer - for maps created via Collections#singletonMap(Object, Object)

  • CollectionsSingletonSetSerializer - for sets created via Collections#singleton(Object)

  • CopyForIterateCollectionSerializer - creates a copy of the source collection for writing object data.

  • CopyForIterateMapSerializer - creates a copy of the source map for writing object data.

  • DateSerializer - serializer for java.util.Date and subclasses (e.g. java.sql.Date, java.sql.Time, java.sql.Timestamp)

  • BitSetSerializer - serializer for java.util.BitSet

  • RegexSerializer - serializer for java.util.regex.Pattern

  • URISerializer - serializer for java.net.URI

  • UUIDSerializer - serializer for java.util.UUID

  • EnumMapSerializer - serializer for EnumMap

  • EnumSetSerializer - serializer for EnumSet

  • UnicodeBlockSerializer - serializer for Character.UnicodeBlock

  • FieldAnnotationAwareSerializer - field serializer that either ignores fields with user-specified annotations or exclusively considers such fields (e.g. useful to ignore all fields annotated with Springs @Autowired annotation).

  • GregorianCalendarSerializer - optimized serializer for (Gregorian)Calendar (24 bytes vs. 1323 bytes with FieldSerializer)

  • JdkProxySerializer - for jdk proxies (proxies created via Proxy.newProxyInstance)

  • KryoReflectionFactorySupport - kryo specialization that uses sun's ReflectionFactory to create new instances for classes without a default constructor

  • SubListSerializers - serializer for lists created via List#subList(int, int)

  • SynchronizedCollectionsSerializer - for synchronized Collections and Maps created via Collections.synchronized*.

  • UnmodifiableCollectionsSerializer - for unmodifiable Collections and Maps created via Collections.unmodifiable*.

  • cglib/CGLibProxySerializer - serializer for CGLib proxies

  • dexx/ListSerializer - serializer for dexx-collections' List

  • dexx/SetSerializer - serializer for dexx collecttions' Set

  • dexx/MapSerializer - serializer for dexx collections' Map

  • guava/ArrayListMultimapSerializer - serializer for guava-libraries' ArrayListMultimap

  • guava/ArrayTableSerializer - serializer for guava-libraries' ArrayTable

  • guava/HashBasedTableSerializer - serializer for guava-libraries' HashBasedTable

  • guava/HashMultimapSerializer -- serializer for guava-libraries' HashMultimap

  • guava/ImmutableListSerializer - serializer for guava-libraries' ImmutableList

  • guava/ImmutableSetSerializer - serializer for guava-libraries' ImmutableSet

  • guava/ImmutableMapSerializer - serializer for guava-libraries' ImmutableMap

  • guava/ImmutableMultimapSerializer - serializer for guava-libraries' ImmutableMultimap

  • guava/ImmutableSortedSetSerializer - serializer for guava-libraries' ImmutableSortedSet

  • guava/ImmutableTableSerializer - serializer for guava-libraries' ImmutableTable

  • guava/LinkedHashMultimapSerializer - serializer for guava-libraries' LinkedHashMultimap

  • guava/LinkedListMultimapSerializer - serializer for guava-libraries' LinkedListMultimap

  • guava/ReverseListSerializer - serializer for guava-libraries' Lists.ReverseList / Lists.reverse

  • guava/TreeBasedTableSerializer - serializer for guava-libraries' TreeBasedTable

  • guava/TreeMultimapSerializer - serializer for guava-libraries' TreeMultimap

  • guava/UnmodifiableNavigableSetSerializer - serializer for guava-libraries' UnmodifiableNavigableSet

  • jodatime/JodaDateTimeSerializer - serializer for joda's DateTime

  • jodatime/JodaIntervalSerializer - serializer for joda's Interval

  • jodatime/JodaLocalDateSerializer - serializer for joda's LocalDate

  • jodatime/JodaLocalDateTimeSerializer - serializer for joda's LocalDateTime

  • jodatime/JodaLocalTimeSerializer - serializer for joda's LocalTime

  • protobuf/ProtobufSerializer - serializer for protobuf GeneratedMessages

  • wicket/MiniMapSerializer - serializer for wicket's MiniMap

Usage

To be able to use the serializers you have to add the jar to your classpath. If your build tool support maven repositories you can use this dependency:

<dependency>
    <groupId>de.javakaffee</groupId>
    <artifactId>kryo-serializers</artifactId>
    <version>0.45</version>
</dependency>

It's available in maven central, so you don't need an additional repository definition. If you're managing the classpath differently you can get the jar from the downloads section or download from maven central.

After that's done you can register the custom serializers at the kryo instance. The following code snippet shows how this is done for serializers that can be registered statically (directly for a known class).

kryo.register( Arrays.asList( "" ).getClass(), new ArraysAsListSerializer() );
kryo.register( Collections.EMPTY_LIST.getClass(), new CollectionsEmptyListSerializer() );
kryo.register( Collections.EMPTY_MAP.getClass(), new CollectionsEmptyMapSerializer() );
kryo.register( Collections.EMPTY_SET.getClass(), new CollectionsEmptySetSerializer() );
kryo.register( Collections.singletonList( "" ).getClass(), new CollectionsSingletonListSerializer() );
kryo.register( Collections.singleton( "" ).getClass(), new CollectionsSingletonSetSerializer() );
kryo.register( Collections.singletonMap( "", "" ).getClass(), new CollectionsSingletonMapSerializer() );
kryo.register( GregorianCalendar.class, new GregorianCalendarSerializer() );
kryo.register( InvocationHandler.class, new JdkProxySerializer() );
UnmodifiableCollectionsSerializer.registerSerializers( kryo );
SynchronizedCollectionsSerializer.registerSerializers( kryo );

// custom serializers for non-jdk libs

// register CGLibProxySerializer, works in combination with the appropriate action in handleUnregisteredClass (see below)
kryo.register( CGLibProxySerializer.CGLibProxyMarker.class, new CGLibProxySerializer( kryo ) );
// dexx
ListSerializer.registerSerializers( kryo );
MapSerializer.registerSerializers( kryo );
SetSerializer.registerSerializers( kryo );
// joda DateTime, LocalDate, LocalDateTime and LocalTime
kryo.register( DateTime.class, new JodaDateTimeSerializer() );
kryo.register( LocalDate.class, new JodaLocalDateSerializer() );
kryo.register( LocalDateTime.class, new JodaLocalDateTimeSerializer() );
kryo.register( LocalDateTime.class, new JodaLocalTimeSerializer() );
// protobuf
kryo.register( SampleProtoA.class, new ProtobufSerializer() ); // or override Kryo.getDefaultSerializer as shown below
// wicket
kryo.register( MiniMap.class, new MiniMapSerializer() );
// guava ImmutableList, ImmutableSet, ImmutableMap, ImmutableMultimap, ImmutableTable, ReverseList, UnmodifiableNavigableSet
ImmutableListSerializer.registerSerializers( kryo );
ImmutableSetSerializer.registerSerializers( kryo );
ImmutableMapSerializer.registerSerializers( kryo );
ImmutableMultimapSerializer.registerSerializers( kryo );
ImmutableTableSerializer.registerSerializers( kryo );
ReverseListSerializer.registerSerializers( kryo );
UnmodifiableNavigableSetSerializer.registerSerializers( kryo );
// guava ArrayListMultimap, HashMultimap, LinkedHashMultimap, LinkedListMultimap, TreeMultimap, ArrayTable, HashBasedTable, TreeBasedTable
ArrayListMultimapSerializer.registerSerializers( kryo );
HashMultimapSerializer.registerSerializers( kryo );
LinkedHashMultimapSerializer.registerSerializers( kryo );
LinkedListMultimapSerializer.registerSerializers( kryo );
TreeMultimapSerializer.registerSerializers( kryo );
ArrayTableSerializer.registerSerializers( kryo );
HashBasedTableSerializer.registerSerializers( kryo );
TreeBasedTableSerializer.registerSerializers( kryo );

The following code snippet shows how to use the KryoReflectionFactorySupport (can only be used with sun/oracle jdk!) and how other serializers are registered via the getDefaultSerializer lookup. If you don't want to use the KryoReflectionFactorySupport you can override the getDefaultSerializer method for your new Kryo() instance.

final Kryo kryo = new KryoReflectionFactorySupport() {

    @Override
    public Serializer<?> getDefaultSerializer(final Class clazz) {
        if ( EnumSet.class.isAssignableFrom( clazz ) ) {
            return new EnumSetSerializer();
        }
        if ( EnumMap.class.isAssignableFrom( clazz ) ) {
            return new EnumMapSerializer();
        }
        if ( SubListSerializers.canSerialize( clazz ) ) {
            return SubListSerializers.createFor( clazz );
        }
        if ( copyCollectionsForSerialization ) {
            if ( Collection.class.isAssignableFrom( clazz ) ) {
                return new CopyForIterateCollectionSerializer();
            }
            if ( Map.class.isAssignableFrom( clazz ) ) {
                return new CopyForIterateMapSerializer();
            }
        }
        if ( Date.class.isAssignableFrom( type ) ) {
            return new DateSerializer( type );
        }
        // see if the given class is a cglib proxy
        if ( CGLibProxySerializer.canSerialize( type ) ) {
            // return the serializer registered for CGLibProxyMarker.class (see above)
            return getSerializer( CGLibProxySerializer.CGLibProxyMarker.class );
        }
        // protobuf
        if ( com.google.protobuf.GeneratedMessage.class.isAssignableFrom( type ) ) {
            return new ProtobufSerializer();
        }
        return super.getDefaultSerializer( clazz );
    }

};

Where to get help

You can contact me via github or submit an issue.

How to contribute

If you want to contribute to this project you can fork the sources on github, make your changes and submit a pull request. Alternatively you can submit an issue with a patch attached.

kryo-serializers's People

Contributors

aaronpoweruser avatar amitsela avatar ben-manes avatar crim avatar detrevid avatar ec-omikron avatar elrodro83 avatar f4lco avatar fabienrenaud avatar fgaule avatar imonteroperez avatar knightofiam avatar magneticflux- avatar magro avatar maiser avatar marcmil avatar mtbc avatar pr0methean avatar psmarcos avatar renniepet avatar rocketraman avatar serverperformance avatar sritchie avatar supercargo avatar tinnet avatar y-higuchi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kryo-serializers's Issues

UnmodifiableCollectionsSerializer fails to copy values of unmodifiable map

I recently found that UnmodifiableCollectionsSerializer fails to copy values of unmodifiable map, as a workaround I am taking a copy of the values before, well, cloning.. ๐Ÿ˜ฑ

    public static void main(String[] args) {
        Map<Integer, Integer> map = Collections.unmodifiableMap(new HashMap<Integer, Integer>() {{
            put(1, 1);
        }});
        KryoPool kryoPool = new KryoPool.Builder(() -> {
            Kryo kryo = new Kryo();
            kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
            UnmodifiableCollectionsSerializer.registerSerializers(kryo);
            return kryo;
        }).softReferences().build();
        kryoPool.run(kryo -> kryo.copy(map.values()));
    }

Fails with..

Exception in thread "main" java.lang.UnsupportedOperationException
	at java.util.AbstractCollection.add(AbstractCollection.java:262)
	at com.esotericsoftware.kryo.serializers.CollectionSerializer.copy(CollectionSerializer.java:149)
	at com.esotericsoftware.kryo.serializers.CollectionSerializer.copy(CollectionSerializer.java:40)
	at com.esotericsoftware.kryo.Kryo.copy(Kryo.java:914)
	at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.copy(UnmodifiableCollectionsSerializer.java:95)
	at com.esotericsoftware.kryo.Kryo.copy(Kryo.java:914)

Missing serializers for Joda-Time LocalDate and LocalDateTime

Am I correct in thinking that these are not implemented?

I'm not an expert in Java or Joda-Time, but my understanding is that at least LocalDate can be useful, even in a distributed system that spans time zones. It can be used to specify a date, for example Christmas 2015 = 25 Dec. 2015, that is independent of time zone.

LocalDateTime is perhaps not so useful for serialization/deserialization screnarios, but maybe for cloning of objects that use it?

Make protocol buffers a separate dependency

I am using a library that requires kryo-serializers as a dependency, called PaperDb. The library doesn't use any protobuf, but because of this dependency it adds almost ~7k methods because of it. In Android, method count is highly important because it affects app startup time, and some limitations around 65k methods before some VM hackery is required.

Sadly, the dependency cannot be transitively removed by maven/gradle either. I'd like to ask that a separate module is created containing just the protobuf code and dependency, if possible.

Java 7: missing CollectionsEmptySortedSetSerializer for Collections.emptySortedSet()

In Java 7, Collections.emptySortedSet() deserialization fails.
It would be nice to add its serializer once this project hits Java 7:

class CollectionsEmptySortedSetSerializer extends Serializer<SortedSet<?>> {

		@Override
		public void write(Kryo kryo, Output output, SortedSet<?> object) {

		}

		@Override
		public SortedSet<?> read(Kryo kryo, Input input, Class<SortedSet<?>> type) {
			return Collections.emptySortedSet();
		}
	}

ImmutableList serializer registration incomplete

The ImmutableListSerializer attempts to register ImmutableList$Sublist like this

kryo.register(ImmutableList.of(1,2,3).subList(1, 2).getClass(), serializer);

However length 1 sublists are actually of type SingletonImmutableLists now so this method no longer works.

RegexSerializer should write/read the flags

Hi,

Although not commonly used, Patterns can have flags. I think the serializer should look like:

public void write(final Kryo kryo, final Output output, final Pattern pattern) {
    output.writeString(pattern.pattern());
    output.writeInt(pattern.flags(), true);
}

public Pattern read(final Kryo kryo, final Input input, final Class<Pattern> patternClass) {
    String regex = input.readString();
    int flags = input.readInt(true);
    return Pattern.compile(regex, flags);
}

Data Type Changed Problem

Hello
I have a field state(String), it was serialized. And then I change the state from String to Enum.How can I solve the deserialize problem?
THANKS!

Serializer for Java Serializable types

public class SerializableSerializer<T> extends Serializer<T> {

    private static final Log LOG = LogFactory.getLog(KryoSerializableSerializer.class);

    @Override
    public void write(Kryo kryo, Output output, T object) {
        try {
            ByteArrayOutputStream buf = new ByteArrayOutputStream();
            ObjectOutputStream out = new ObjectOutputStream(buf);
            out.writeObject(object);
            out.close();

            output.writeInt(buf.size());
            buf.writeTo(output);
        } catch (IOException e) {
            throw Throwables.propagate(e);
        }
    }

    @Override
    public T read(Kryo kryo, Input input, Class<T> type) {
        LOG.info("Reading an instance of " + type);
        try {
            int length = input.readInt();
            byte[] data = input.readBytes(length);
            ByteArrayInputStream buf = new ByteArrayInputStream(data);
            ObjectInputStream in = new ObjectInputStream(buf);
            return type.cast(in.readObject());
        } catch (IOException e) {
            throw Throwables.propagate(e);
        } catch (ClassNotFoundException e) {
            throw Throwables.propagate(e);
        }
    }
}

In a pinch, this lets you serialize things which couldn't otherwise be serialized. It's dangerous to register this as a default serializer for Serializer.class as that breaks integer, list, etc. But for things like #25, it's ideal.

Serializers for Guava predicates

Most of the builtin Predicates in guava's Predicates.java implement Serializable but are not serializable by Kryo by default. Please can there be a utility class which registers these as a block, e.g. Predicates.containsPattern(String).getClass(), etc.

Use writeVarInt for enum ordinals

In things like EnumMapSerializer, VarInt encoding is smaller than int encoding for both lengths and ordinal() values. Please prefer it.

NullPointerException

kryo-serializers-0.37๏ผš

java.lang.NullPointerException: null
at reflectasm.java.lang.NullPointerExceptionConstructorAccess.newInstance(Unknown Source)
at com.esotericsoftware.kryo.Kryo$DefaultInstantiatorStrategy$1.newInstance(Kryo.java:1237)
at com.esotericsoftware.kryo.Kryo.newInstance(Kryo.java:1090)
at com.esotericsoftware.kryo.serializers.FieldSerializer.create(FieldSerializer.java:570)
at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:546)
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:790)
at com.alibaba.dubbo.common.serialize.support.kryo.KryoObjectInput.readObject(KryoObjectInput.java:125)
at com.alibaba.dubbo.rpc.protocol.dubbo.DecodeableRpcResult.decode(DecodeableRpcResult.java:94)
at com.alibaba.dubbo.rpc.protocol.dubbo.DecodeableRpcResult.decode(DecodeableRpcResult.java:117)
at com.alibaba.dubbo.rpc.protocol.dubbo.DubboCodec.decodeBody(DubboCodec.java:98)
at com.alibaba.dubbo.remoting.exchange.codec.ExchangeCodec.decode(ExchangeCodec.java:134)
at com.alibaba.dubbo.remoting.exchange.codec.ExchangeCodec.decode(ExchangeCodec.java:95)
at com.alibaba.dubbo.rpc.protocol.dubbo.DubboCountCodec.decode(DubboCountCodec.java:46)
at com.alibaba.dubbo.remoting.transport.netty.NettyCodecAdapter$InternalDecoder.messageReceived(NettyCodecAdapter.java:134)
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

spark serialization error during kryo.readObject when using UnmodifieableCollectionsSerializer

Serialization trace:
suppressedExceptions (com.package.SomeClass)
at com.esotericsoftware.kryo.serializers.FieldSerializer$ObjectField.read(FieldSerializer.java:626)
at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:221)
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:729)
at com.esotericsoftware.kryo.serializers.MapSerializer.read(MapSerializer.java:134)
at com.esotericsoftware.kryo.serializers.MapSerializer.read(MapSerializer.java:17)
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:729)
at com.esotericsoftware.kryo.serializers.MapSerializer.read(MapSerializer.java:134)
at com.esotericsoftware.kryo.serializers.MapSerializer.read(MapSerializer.java:17)
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:729)
at org.apache.spark.serializer.KryoDeserializationStream.readObject(KryoSerializer.scala:142)
at org.apache.spark.broadcast.TorrentBroadcast$.unBlockifyObject(TorrentBroadcast.scala:216)
at org.apache.spark.broadcast.TorrentBroadcast$$anonfun$readBroadcastBlock$1.apply(TorrentBroadcast.scala:177)
at org.apache.spark.util.Utils$.tryOrIOException(Utils.scala:1000)
... 18 more
Caused by: java.lang.NullPointerException
at java.util.Collections$UnmodifiableCollection.(Collections.java:1051)
at java.util.Collections$UnmodifiableList.(Collections.java:1204)
at java.util.Collections.unmodifiableList(Collections.java:1190)
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer$UnmodifiableCollection$2.create(UnmodifiableCollectionsSerializer.java:115)
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:72)
at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:648)
at com.esotericsoftware.kryo.serializers.FieldSerializer$ObjectField.read(FieldSerializer.java:605)
... 30 more

osgi import is broken for kryo

Hi all,

You still refer to the < 3.0 version of kryo in your osgi import statement - even if you have kryo 3.0 in your dependencies:

com.esotericsoftware.kryo*;version="[2.24.0,3.0)",

It would be great if you could fix this - i'll use a manually patched version in the meantime.

Thanks,
Mathias

missing Collections.nCopies serializer

Would it be possible to add a Serializer for the CopiesList class that's returned by Collections.nCopies()?

One exists already here but it would be convenient if it was included in this package.

Import-Package's kryo version range is wrong in the pom.xml.

I am not able to install Eclipse plugin that contains kryo-serializers due to not finding the correct version of kryo, even when the kryo 4.0.0 dependency is available.

Missing requirement: kryo serializers 0.41.0 (de.javakaffee.kryo-serializers 0.41.0) requires 'package com.esotericsoftware.kryo [3.0.3,4.0.0)' but it could not be found

As I started to look in the pom.xml I found this:

`

<Import-Package><![CDATA[
    com.esotericsoftware.kryo*;version="[3.0.3,4.0)",
    esotericsoftware.minlog*;version="[1.2,2.0)",
    reflect;resolution:=optional,*]]>
</Import-Package>
`

Shouldn't it be [3.0.3, 4.0] or [3.0.3, 5.0)?

Is Shipkit+Gradle wanted?

Using the Shipkit Gradle plugin could be pretty useful. It manages the release process by integrating with CI tools such as Travis CI, automatically compiling changelogs, author lists, and incrementing the patch version.

Using Shipkit requires moving to the Gradle build system. That could be a plus or a minus depending on who you talk to, but I feel in general that it is a plus. I believe all of the current Maven plugins used in this build already have Gradle counterparts.

Additionally, the Spotless Gradle plugin could be used to enforce a consistent code style. From a cursory review of the test files, I can already see some odd spacing around generic types and around method arguments, as well as some detected redundant statements/logic.

I'm asking first so I don't go to all the trouble of updating and changing things only to find out you'd rather stick with Maven. It's your call, @magro.

New Release?

When are we going to get a new release? It looks like there hasn't been one since October 2015. It would also be nice if you published snapshots to Sonatype.

valueOfId() does not work for actual ISOChronology

IdentifiableChronology.valueOfId() only appears to use ISOChronology as a fallback when the provided id is null. In my case, however, the id as returned by input.readString() in readChronology() is "org.joda.time.chrono.ISOChronology".

This obviously matches none of the "COPTIC", "ETHIOPIC" etc. identifiers. Therefore, ISOChronology is not identified and a "No chronology found for id" exception gets thrown.

I'm not using Kryo or kryo-serializers directly, but registering JodaLocalDateTimeSerializer with a framework (Apache Flink, as suggested on Stack Overflow), so I'm not in control of any parameters. But this behavior definitely looks strange to me.

Unable to find class

com.esotericsoftware.kryo.KryoException: Unable to find class: ameba.http.session.SessionStore๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝjava.lang.String
    at com.esotericsoftware.kryo.util.DefaultClassResolver.readName(DefaultClassResolver.java:156) ~[kryo-3.0.1.jar:na]
    at com.esotericsoftware.kryo.util.DefaultClassResolver.readClass(DefaultClassResolver.java:133) ~[kryo-3.0.1.jar:na]
    at com.esotericsoftware.kryo.Kryo.readClass(Kryo.java:667) ~[kryo-3.0.1.jar:na]
    at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:778) ~[kryo-3.0.1.jar:na]
    at ameba.cache.util.KryoSerializer$3.execute(KryoSerializer.java:87) ~[ameba-cache-core-0.1.7-20150612.185233-88.jar:na]
    at com.esotericsoftware.kryo.pool.KryoPoolQueueImpl.run(KryoPoolQueueImpl.java:61) ~[kryo-3.0.1.jar:na]
    at ameba.cache.util.KryoSerializer.asObject(KryoSerializer.java:82) ~[ameba-cache-core-0.1.7-20150612.185233-88.jar:na]
    at ameba.cache.util.Serializations.asObject(Serializations.java:32) ~[ameba-cache-core-0.1.7-20150612.185233-88.jar:na]
    at ameba.cache.util.Serializations.asObject(Serializations.java:38) ~[ameba-cache-core-0.1.7-20150612.185233-88.jar:na]
    at ameba.cache.Cache.get(Cache.java:365) ~[ameba-cache-core-0.1.7-20150612.185233-88.jar:na]
    at ameba.http.session.CacheSession.refresh(CacheSession.java:113) ~[ameba-session-0.1.7-20150612.180847-61.jar:na]
    at ameba.http.session.CacheSession.isInvalid(CacheSession.java:74) ~[ameba-session-0.1.7-20150612.180847-61.jar:na]
    at ameba.http.session.SessionFilter.filter(SessionFilter.java:68) ~[ameba-session-0.1.7-20150612.180847-61.jar:na]
    at org.glassfish.jersey.server.ContainerFilteringStage.apply(ContainerFilteringStage.java:132) ~[jersey-server-2.18.jar:na]
    at org.glassfish.jersey.server.ContainerFilteringStage.apply(ContainerFilteringStage.java:68) ~[jersey-server-2.18.jar:na]
    at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197) ~[jersey-common-2.18.jar:na]
    at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:300) ~[jersey-server-2.18.jar:na]
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [jersey-common-2.18.jar:na]
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [jersey-common-2.18.jar:na]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [jersey-common-2.18.jar:na]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [jersey-common-2.18.jar:na]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [jersey-common-2.18.jar:na]
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [jersey-common-2.18.jar:na]
    at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:291) [jersey-server-2.18.jar:na]
    at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1140) [jersey-server-2.18.jar:na]
    at ameba.container.grizzly.server.http.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:150) [ameba-container-grizzly-0.1.7-20150528.081010-13.jar:na]
    at org.glassfish.grizzly.http.server.HttpHandler$1.run(HttpHandler.java:224) [grizzly-http-server-2.3.20.jar:2.3.20]
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591) [grizzly-framework-2.3.20.jar:2.3.20]
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571) [grizzly-framework-2.3.20.jar:2.3.20]
    at java.lang.Thread.run(Thread.java:745) [na:1.7.0_80]
Caused by: java.lang.ClassNotFoundException: ameba.http.session.SessionStore๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝjava.lang.String
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366) ~[na:1.7.0_80]
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355) ~[na:1.7.0_80]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.7.0_80]
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354) ~[na:1.7.0_80]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425) ~[na:1.7.0_80]
    at ameba.dev.classloading.ReloadClassLoader.loadClass(ReloadClassLoader.java:158) ~[ameba-dev-0.1.7-20150611.090831-67.jar:0.1.7-SNAPSHOT]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ~[na:1.7.0_80]
    at java.lang.Class.forName0(Native Method) ~[na:1.7.0_80]
    at java.lang.Class.forName(Class.java:278) ~[na:1.7.0_80]
    at com.esotericsoftware.kryo.util.DefaultClassResolver.readName(DefaultClassResolver.java:154) ~[kryo-3.0.1.jar:na]
    ... 29 common frames omitted

version : 3.0.1
source code https://github.com/icode/ameba-cache/blob/master/core/src/main/java/ameba/cache/util/KryoSerializer.java

EnumMapSerializer broken?

I'm using the EnumMapSerializer. if I put more than one entry in the map, the deserialization is broken. A single map entry works fine.

I've tried release 0.20 and 0.22-SNAPSHOT

UnmodifieableCollectionsSerializer: NPE when serializing list created by `Arrays.asList()`

This should be enough to reproduce it:

    public final class ClassWithUnmodifieableList {
        private List<String> names;

        public ClassWithUnmodifieableList(String...names) {
                this.names = Collections.unmodifiableList(Arrays.asList(names));
        }
    }

I'm getting this exception when attempting to deserialize this class:

com.hazelcast.nio.serialization.HazelcastSerializationException: com.esotericsoftware.kryo.KryoException: java.lang.NullPointerException
Serialization trace:
names (info.jerrinot.subzero.TestCustomerSerializers$ClassWithUnmodifieableList)

    at com.hazelcast.internal.serialization.impl.SerializationUtil.handleException(SerializationUtil.java:61)
    at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:178)
    at com.hazelcast.map.impl.proxy.MapProxySupport.toObject(MapProxySupport.java:1067)
    at com.hazelcast.map.impl.proxy.MapProxyImpl.get(MapProxyImpl.java:94)
    at info.jerrinot.subzero.TestCustomerSerializers.testSpecialRegistrationRegisteredInDefaultConfigFile(TestCustomerSerializers.java:87)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: com.esotericsoftware.kryo.KryoException: java.lang.NullPointerException
Serialization trace:
names (info.jerrinot.subzero.TestCustomerSerializers$ClassWithUnmodifieableList)
    at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:144)
    at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:540)
    at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:813)
    at info.jerrinot.subzero.internal.strategy.GlobalKryoStrategy.readObject(GlobalKryoStrategy.java:28)
    at info.jerrinot.subzero.internal.strategy.KryoStrategy.read(KryoStrategy.java:79)
    at info.jerrinot.subzero.AbstractSerializer.read(AbstractSerializer.java:30)
    at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:46)
    at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:172)
    ... 32 more
Caused by: java.lang.NullPointerException
    at java.util.Arrays$ArrayList.size(Arrays.java:3818)
    at java.util.AbstractList.add(AbstractList.java:108)
    at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:134)
    at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:40)
    at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:813)
    at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71)
    at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:731)
    at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:125)
    ... 39 more

when I change it to

        public ClassWithUnmodifieableList(String...names) {
            ArrayList<String> strings = new ArrayList<>(names.length);
            for (String name : names) {
                strings.add(name);
            }
            this.names = Collections.unmodifiableList(strings);
        }

then everything works as expected;

Provide kryo pool

A kryo pool like the one of chill would be useful (e.g. for msm).

How can EnumMapSerializer work with nested EnumMaps?

This is a feature request, not a bug.

If I have a nested map like so EnumMap<K1, EnumMap<K2, V>>, how can the EnumMapSerializer be modified to work with it?

At present, it doesn't quite work since the value of the top-level map is (de)serialized as an object instead of as another EnumMap.

Joda-Time DateTime serializer shouldn't "optimize" default time zone

This is a hypothetical problem - I haven't personally a case that would be affected by this, but I can imagine that it could be a problem.

The serializer for Joda-Time DateTime tests if the associated time zone is the default time zone, and serializes that to en empty string. The deserializer, when it receives an empty string, then uses the default time zone on the receiving system.

This is duly documented in the comments: "If the time zone is the default time zone ({@link DateTimeZone#getDefault()}), the time zone attribute is omitted. This requires different machines to have the same time zone settings."

So if two machines in different time zones are communicating via Kryo and using Joda-Time DateTime with their time zones set to the default time zone, things are going to go wrong.

It can maybe be argued that you shouldn't use DateTime in that way. DateTime is more typically used with the time zone set to UTC, so then there isn't a problem. Except that maybe one of the machines is a server, and its time zone actually is set to UTC, so UTC the default for that system but not for the client systems.

My suggestion: remove that "optimization" and always send the time zone info. Or is is conceivable that some usage of this program is now dependent on this behavior, so doing that would be a "breaking change"?

Supports kryo 3.0?

I assume it does not at the moment?

What is there to be done until this can be shipped with 3.0 support?

Remove obsolete serializers

Kryo now provides serializers for e.g. Collections singletonList/Map, emptyList/Map, EnumSet etc., so several kryo-serializers are not needed any more. They should be removed / be deprecated.

not able to deploy mule app

ERROR 2016-06-27 14:52:34,450 [main] org.mule.module.launcher.application.DefaultMuleApplication: null
java.lang.StackOverflowError
at com.esotericsoftware.kryo.util.DefaultClassResolver.readClass(DefaultClassResolver.java:127) ~[kryo-shaded-3.0.1.jar:?]
at com.esotericsoftware.kryo.Kryo.readClass(Kryo.java:667) ~[kryo-shaded-3.0.1.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:778) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:787) ~[kryo-shaded-3.0.1.jar:?]
at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.read(UnmodifiableCollectionsSerializer.java:71) ~[kryo-serializers-0.29.jar:?]

Kryo 2 Upgrade

Hey,

I submitted a pull req some time ago to upgrade these serializers for Kryo 2. Is this project still active? I'd like to contribute more, but I don't see much movement.

It'd be great to be able to fold our serializers from https://github.com/Cascading/meat-locker into this project.

Sam

Supports Kryo 4.0?

Does the latest release support Kryo 4.0.x? It explicitly states that it supports 2/3, but no mention of 4.

ConcurrentModificationException when serializing using the JdkProxySerializer

2016-08-22 13:59:06,195 | ERROR | ult-dispatcher-2 | OneForOneStrategy                | 172 - com.typesafe.akka.slf4j - 2.4.7 | java.util.ConcurrentModificationException
Serialization trace:
classes (sun.misc.Launcher$AppClassLoader)
parent (org.eclipse.core.runtime.internal.adaptor.ContextFinder)
contextClassLoader (java.lang.Thread)
threads (java.lang.ThreadGroup)
groups (java.lang.ThreadGroup)
group (org.eclipse.osgi.framework.eventmgr.EventManager$EventThread)
thread (org.eclipse.osgi.framework.eventmgr.EventManager)
bundleFileCloserManager (org.eclipse.osgi.baseadaptor.bundlefile.MRUBundleFileList)
mruList (org.eclipse.osgi.baseadaptor.bundlefile.ZipBundleFile)
bundleFile (org.eclipse.osgi.internal.baseadaptor.SystemBundleData)
bundledata (org.eclipse.osgi.framework.internal.core.InternalSystemBundle)
bundle (org.eclipse.osgi.framework.internal.core.SystemBundleActivator)
activator (org.eclipse.osgi.framework.internal.core.BundleContextImpl)
context (org.eclipse.osgi.baseadaptor.BaseAdaptor)
adaptor (org.eclipse.osgi.baseadaptor.BaseData)
bundledata (org.eclipse.osgi.framework.internal.core.BundleHost)
bundle (org.eclipse.osgi.internal.loader.BundleLoader)
delegate (org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader)
referent (java.lang.ref.WeakReference)
clref (javassist.LoaderClassPath)
path (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
pathList (javassist.ClassPoolTail)
source (javassist.ClassPool)
classPool (org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils)
javassist (org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator)
generator (org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry)
registry (org.opendaylight.yangtools.binding.data.codec.impl.BindingCodecContext)
factory (org.opendaylight.yangtools.binding.data.codec.impl.DataContainerCodecPrototype)
prototype (org.opendaylight.yangtools.binding.data.codec.impl.KeyedListNodeCodecContext)
context (org.opendaylight.yangtools.binding.data.codec.impl.LazyDataObject)
cachedData (org.opendaylight.yangtools.binding.data.codec.impl.LazyDataObject)
augmentation (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder$TerminationPointImpl)
input (org.opendaylight.newfederation.impl.DTOFederatedObject)
com.esotericsoftware.kryo.KryoException: java.util.ConcurrentModificationException
Serialization trace:
classes (sun.misc.Launcher$AppClassLoader)
parent (org.eclipse.core.runtime.internal.adaptor.ContextFinder)
contextClassLoader (java.lang.Thread)
threads (java.lang.ThreadGroup)
groups (java.lang.ThreadGroup)
group (org.eclipse.osgi.framework.eventmgr.EventManager$EventThread)
thread (org.eclipse.osgi.framework.eventmgr.EventManager)
bundleFileCloserManager (org.eclipse.osgi.baseadaptor.bundlefile.MRUBundleFileList)
mruList (org.eclipse.osgi.baseadaptor.bundlefile.ZipBundleFile)
bundleFile (org.eclipse.osgi.internal.baseadaptor.SystemBundleData)
bundledata (org.eclipse.osgi.framework.internal.core.InternalSystemBundle)
bundle (org.eclipse.osgi.framework.internal.core.SystemBundleActivator)
activator (org.eclipse.osgi.framework.internal.core.BundleContextImpl)
context (org.eclipse.osgi.baseadaptor.BaseAdaptor)
adaptor (org.eclipse.osgi.baseadaptor.BaseData)
bundledata (org.eclipse.osgi.framework.internal.core.BundleHost)
bundle (org.eclipse.osgi.internal.loader.BundleLoader)
delegate (org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader)
referent (java.lang.ref.WeakReference)
clref (javassist.LoaderClassPath)
path (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
next (javassist.ClassPathList)
pathList (javassist.ClassPoolTail)
source (javassist.ClassPool)
classPool (org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils)
javassist (org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator)
generator (org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry)
registry (org.opendaylight.yangtools.binding.data.codec.impl.BindingCodecContext)
factory (org.opendaylight.yangtools.binding.data.codec.impl.DataContainerCodecPrototype)
prototype (org.opendaylight.yangtools.binding.data.codec.impl.KeyedListNodeCodecContext)
context (org.opendaylight.yangtools.binding.data.codec.impl.LazyDataObject)
cachedData (org.opendaylight.yangtools.binding.data.codec.impl.LazyDataObject)
augmentation (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder$TerminationPointImpl)
input (org.opendaylight.newfederation.impl.DTOFederatedObject)
at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:101)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:628)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.write(DefaultArraySerializers.java:366)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.write(DefaultArraySerializers.java:307)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:628)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.write(DefaultArraySerializers.java:366)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer.write(DefaultArraySerializers.java:307)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
.....
at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:628)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at de.javakaffee.kryoserializers.JdkProxySerializer.write(JdkProxySerializer.java:52)[334:de.javakaffee.kryo-serializers:0.38.0]
        at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:628)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:100)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:40)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:628)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.MapSerializer.write(MapSerializer.java:113)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.MapSerializer.write(MapSerializer.java:39)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:628)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at de.javakaffee.kryoserializers.JdkProxySerializer.write(JdkProxySerializer.java:52)[334:de.javakaffee.kryo-serializers:0.38.0]
        at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:628)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.DefaultSerializers$CollectionsSingletonMapSerializer.write(DefaultSerializers.java:588)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.DefaultSerializers$CollectionsSingletonMapSerializer.write(DefaultSerializers.java:580)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:518)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:534)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at org.opendaylight.newfederation.transform.FederationPublisherActor.onReceive(FederationPublisherActor.java:53)[335:org.opendaylight.federation.new-federation:0.1.0.SNAPSHOT]
        at akka.actor.UntypedActor$$anonfun$receive$1.applyOrElse(UntypedActor.scala:165)[171:com.typesafe.akka.actor:2.4.7]
        at akka.actor.Actor$class.aroundReceive(Actor.scala:484)[171:com.typesafe.akka.actor:2.4.7]
        at akka.actor.UntypedActor.aroundReceive(UntypedActor.scala:95)[171:com.typesafe.akka.actor:2.4.7]
        at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526)[171:com.typesafe.akka.actor:2.4.7]
        at akka.actor.ActorCell.invoke(ActorCell.scala:495)[171:com.typesafe.akka.actor:2.4.7]
        at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)[171:com.typesafe.akka.actor:2.4.7]
        at akka.dispatch.Mailbox.run(Mailbox.scala:224)[171:com.typesafe.akka.actor:2.4.7]
        at akka.dispatch.Mailbox.exec(Mailbox.scala:234)[171:com.typesafe.akka.actor:2.4.7]
        at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)[167:org.scala-lang.scala-library:2.11.8.v20160304-115712-1706a37eb8]
        at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)[167:org.scala-lang.scala-library:2.11.8.v20160304-115712-1706a37eb8]
        at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)[167:org.scala-lang.scala-library:2.11.8.v20160304-115712-1706a37eb8]
        at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)[167:org.scala-lang.scala-library:2.11.8.v20160304-115712-1706a37eb8]
Caused by: java.util.ConcurrentModificationException
        at java.util.Vector$Itr.checkForComodification(Vector.java:1184)[:1.8.0_91]
        at java.util.Vector$Itr.next(Vector.java:1137)[:1.8.0_91]
        at com.esotericsoftware.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:92)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.CollectionSerializer.write(CollectionSerializer.java:40)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:552)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        at com.esotericsoftware.kryo.serializers.ObjectField.write(ObjectField.java:80)[332:com.esotericsoftware.kryo-shaded:3.0.3]
        ... 166 more

Guava 24.1+ issue. Missing serializers for new JdkBackedImmutable* classes

Guava 24.1 introduced new implementations of ImmutableSet, ImmutableMultiset, ImmutableMap and ImmutableBiMap. These new implementations do not get registered with kryo by the guava support classes in kryo-serializer.

e.g. ImmutableMapSerializer does not register a serializer for com.google.common.collect.JdkBackedImmutableMap

Serializing Guava ImmutableMap instances with kryo.setRegistrationRequired(true) can lead to Exceptions like this:

java.lang.IllegalArgumentException: Class is not registered: com.google.common.collect.JdkBackedImmutableMap
Note: To register this class use: kryo.register(com.google.common.collect.JdkBackedImmutableMap.class);
    at com.esotericsoftware.kryo.Kryo.getRegistration(Kryo.java:503)
    at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:557)

Updating to latest version of kryo 2

In a current project we updated from kryo 1.04 to 2.16. I found some of the serializers pretty useful, but they are still targeting some early version of kryo 2. So I started to adapt this project to the latest version.
In my kryo2 branch I fixed most of the issues resulting from this update. The serializers should work so far but there are still some test issues with the KryoReflectionFactorySupport that relies on some no more existing methods from Kryo itself and some removed serializers. Probably someone can assess if these constructs are still needed and remove or adapt the remaining tests.

Serializer for java.io.File

      kryo.register(File.class, new Serializer<File>() {
            @Override
            public void write(Kryo kryo, Output output, File object) {
                output.writeString(object.getPath());
            }

            @Override
            public File read(Kryo kryo, Input input, Class type) {
                return new File(input.readString());
            }
        });

Utilize Kryo's configured ClassLoader

Kryo offers the possibility to configure a custom ClassLoader via Kryo.setClassLoader(ClassLoader classLoader), but Kryo-Serializers does not use it.

The fix is very simple, but I'm not familiar with Git, so I describe it here:

In JdkProxySerializer, line 38, where it is:

    final ClassLoader classLoader = kryo.getClass().getClassLoader(); // TODO: can we do this?

I think it should be:

    final ClassLoader classLoader = kryo.getClassLoader();

We use a custom ClassLoader in Android, and are trying to use Kryo to restore the Activity state after the app process is killed, but it's not possible for us to use the same ClassLoader to load Kryo.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.