Skip to content

Java8 lambda expression in PriorityQueue cannot be serialized #421

@Jiayi-Liao

Description

@Jiayi-Liao

When I'm using PriorityQueueSerializer from chill-java package, I got NPE when serializing PriorityQueue instance like this:

PriorityQueue<String> pq = new PriorityQueue<>((o1, o2) -> o1.length() - o2.length() - 1);
pq.add("1234135");
pq.add("12323424135");
java.lang.NullPointerException
	at com.esotericsoftware.kryo.util.DefaultClassResolver.writeClass(DefaultClassResolver.java:80)
	at com.esotericsoftware.kryo.Kryo.writeClass(Kryo.java:488)
	at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:593)

Perhaps it's because the lambda expression is not serializable. But the strange thing is that when I removed the registration of PriorityQueueSerializer from kryo's registrations, the serialization works.

Is this expected?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions