Skip to content

Commit

Permalink
kryo version upgrade from snapshot to newest release 3.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Korneliusz Rabczak committed Dec 9, 2015
1 parent 6222b90 commit cdc3fd1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
7 changes: 2 additions & 5 deletions airomem-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,11 @@
<scope>test</scope>
<type>jar</type>
</dependency>




<dependency>
<groupId>com.esotericsoftware.kryo</groupId>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
<version>2.24.1-SNAPSHOT</version>
<version>3.0.3</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.pool.KryoFactory;
import com.esotericsoftware.kryo.pool.KryoPool;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import com.esotericsoftware.kryo.serializers.ClosureSerializer;
import org.objenesis.strategy.StdInstantiatorStrategy;
import org.prevayler.foundation.serialization.JavaSerializer;

Expand All @@ -21,27 +24,23 @@ public class KryoSerializer extends JavaSerializer {

private ThreadLocal<Kryo> kryos = new ThreadLocal<Kryo>() {
protected Kryo initialValue() {
Kryo kryo = pool.borrow();
return kryo;
return pool.borrow();
}
;
};


private final KryoPool pool = new KryoPool(KryoSerializer::createCryo);

private static Kryo createCryo() {
KryoFactory factory = () -> {
final Kryo kryo = new Kryo();
((Kryo.DefaultInstantiatorStrategy) kryo.getInstantiatorStrategy()).setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
kryo.register(java.lang.invoke.SerializedLambda.class);
try {
kryo.register(Class.forName(Kryo.class.getName() + "$Closure"), new ClosureSerializer());
} catch (ClassNotFoundException e) {
}
kryo.setReferenceResolver(new ReferenceResolver());
return kryo;
}
};

public KryoSerializer() {
//kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
// kryo.register(ContextCommand.class, new ClosureSerializer());
// kryo.register(Command.class, new ClosureSerializer());
}
private final KryoPool pool = new KryoPool.Builder(factory).build();

private Kryo getKryo() {
return this.kryos.get();
Expand Down

0 comments on commit cdc3fd1

Please sign in to comment.