Skip to content

Commit

Permalink
Added ability to provide customizations to Kryo via a consumer (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
ceckhardt authored and JoeHegarty committed Jun 15, 2017
1 parent a00fe88 commit 6c2ba59
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.UUID;
import java.util.function.Consumer;

/**
* Kryo based message serializer and object cloning implementation.
Expand All @@ -79,6 +80,10 @@ public class KryoSerializer implements ExecutionObjectCloner, MessageSerializer
private final KryoPool kryoPool;

public KryoSerializer() {
this(kryo -> {});
}

public KryoSerializer(Consumer<Kryo> kryoConsumer) {
KryoFactory factory = new KryoFactory() {
@Override
public Kryo create() {
Expand Down Expand Up @@ -127,6 +132,8 @@ public Registration writeClass(Output output, Class type) {

kryo.register(ReferenceReplacement.class, new ReferenceReplacementSerializer());

kryoConsumer.accept(kryo);

return kryo;
}
};
Expand Down

0 comments on commit 6c2ba59

Please sign in to comment.