Giter VIP home page Giter VIP logo

kryo's People

Contributors

adler3d avatar amiton avatar backpaper0 avatar cerko2 avatar cypherdare avatar dependabot[bot] avatar gdela avatar hierynomus avatar isaki avatar kleptine avatar magro avatar mikee805 avatar nathansweet avatar nonvirtualthunk avatar pilgr avatar prasanthj avatar pron avatar puneetlakhina avatar purpledrazi avatar qxo avatar romix avatar serverperformance avatar sritchie avatar sschuberth avatar stau avatar theigl avatar timotta avatar tobiasschaefer avatar williamdo avatar yokotaso 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  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

kryo's Issues

Accessing non-public fields with bytecode

From [email protected] on September 02, 2010 16:55:48

This is not an issue but rather a proposal.

You write that you use generated bytecode to access public fields and cached reflection to access protected and private fields.

I propose that you use bytecode corresponding to the example below to also access protected fields (and with a variant also package visible fields) but improved speed.

// an existing class with a non-private field x:
class Existing {
protected byte x;
}

// a serializer which can access x within java rules:
class Serializer extends Existing {
public static void writeObject(final ByteBuffer b, final Existing t) {
b.put(t.x);
}
}

The idea is to create a class which inherits from the class in question (which allows to access the field) but not to use instances of that class (we have no use for it anyway).

Accessing package visible fields is also possible with a variant of this method - provided the package is not protected by the SecurityManager. Just generate a class in that package.

Looking at your code I think that a fairly straitforward variant or your MethodAccess code should do it.

Accessing private fields is of course no possible with this approach as that would require geenrating access code in the class at question which is not possible after that class is loaded.

In the long run you might consider providing a ClassLoader which intercepts class load calls and adds special custom serialization methods in all classes of your choice. Then you'd only need to call those methods during serialization.

Yours

Gunnar Zarncke

Original issue: http://code.google.com/p/kryo/issues/detail?id=25

Build Kryo 1.04

From [email protected] on November 18, 2011 09:56:04

Hello,

i want to build kryo 1.04 as maven project.
The problem is that in the pom.xml the version is 1.1-SNAPSHOT and
if i want to build this it returns:
The following artifacts could not be resolved: com.esotericsoftware:reflectasm:jar:0.8, com.esotericsoftware:minlog:jar:1.2

Were can i get this artifacts? The tags i can find are in the wrong version. I need this as maven project in svn or git.

Original issue: http://code.google.com/p/kryo/issues/detail?id=48

BufferUnderflowException in CompatibleFieldSerializer

From [email protected] on December 22, 2010 22:51:25

What steps will reproduce the problem?
Serializing large objects extends the Context.getByteArray() indefinitely ( and it seems it is not reset under any conditions ). On subsequent calls to serialize ( another or the same object ) the temp byte array is still very large and may exceed the length of available bytes in the buffer on buffer.get()


What is the expected output? What do you see instead?
BufferUnderflowException thrown at line 189 of CompatibleFieldSerializer


What version of the Kryo are you using?
1.03

Please provide any additional information below.

Original issue: http://code.google.com/p/kryo/issues/detail?id=35

Optimization for objectbuffer

From [email protected] on March 09, 2011 01:28:44

Hi -

One suggestion to improve performance of ObjectBuffer on large objects (when at runtime its unknown that they're large, so the buffer's initial capacity is low) -- Is it possible for the buffer to determine by how much its underallocated when it finds that its max capacity is insufficient? E.g. in our case we're Kryoing an object that contains a byte[], and the byte[] is very large, but it should be possible for Kryo to know how much extra room it needs, and rather than just double the capacity, it could keep doubling until it the new allocated amount meets the new allocation requirement.

Hope that makes sense

Thanks!

Original issue: http://code.google.com/p/kryo/issues/detail?id=42

exception thrown when using the remote object

From [email protected] on July 19, 2011 16:04:11

What steps will reproduce the problem?
1.install java 7
2.run java program

What is the expected output? What do you see instead?
not to throw a exception, exception thrown saying the proxy class isnt registered

What version of the Kryo are you using?
newest

Please provide any additional information below.
it worked before i installed the new java

Original issue: http://code.google.com/p/kryo/issues/detail?id=46

IllegalArgumentException thrown using CompatibleFieldSerializer during deserialization

From [email protected] on December 22, 2010 19:16:15

What steps will reproduce the problem?
No problems in serializing / deserializing using a default FieldSerializer. Uisng the CompatibleFieldSerializer serializing / deserializing round-trips work for shallow graphs but for deeply nested collections the round-trip fails by throwing an IllegalArgumentException ( usually during deserialization and when passing a null value to a primitive value field ). Cant tell if its the deserialization thats broken or the serialized stream is incomplete / wrong.

Registering the classes to use the CompatibleFieldSerializer remedies the problem in some cases ( such as the example attached ) but in others it has no effect ( not attached ).

What is the expected output? What do you see instead?
Expected round trip serializing / deserializing to produce equivalent objects - instead the test case attached errors out when using CompatibleFieldSerializer

What version of the Kryo are you using?
1.03

Please provide any additional information below.
Attached test case and MultiMap / aggregate object to reproduce the error

Attachment: KryoTest.java Finger.java MultiMap.java

Original issue: http://code.google.com/p/kryo/issues/detail?id=34

Wrong buffer contents (bytes) when using ObjectBuffer to read object data

From [email protected] on March 23, 2010 21:18:20

Detailed Problem Description:

The issue appears when the ObjectBuffer is created with an initial capacity
that is lower than the object data to read. (If the initial capacity is
greater than the size of the object to read, the issue does not appear).

The source of the problem seems to reside in the resizeBuffer method in the
following statement:
if (preserveContents) newBuffer.put(buffer);

newBuffer.put only transfers the REMAINING bytes of buffer (the source
buffer). I think the statement should be corrected to:
if (preserveContents) {
buffer.position(0);
newBuffer.put(buffer);
}

What is the expected output? What do you see instead?
Without the fix above I get a wrong sequence of bytes due to copying only
remaining bytes when resizing the buffer.


What version of the Kryo are you using?
Version 1.0

Original issue: http://code.google.com/p/kryo/issues/detail?id=11

Implement exception with details on unregistered class, or callback

From [email protected] on February 27, 2010 20:06:03

Steps will reproduce the problem:

  1. kryo.writeClassAndObject(buffer, object); // when object's class or some
    class from its graph is not registered
  2. you get IllegalArgumentException exception with textual description of
    class, like "Class is not registered: "

Instead, it would be better to throw an exception with explicit Class
property in it, to make it possible to see which class was not registered.
With the code like this:

throw new KryoUnregisteredException(type, "Class is not registered: "...)

This addition is needed to register classes dynamically in runtime, and
retry the serialization until all classes are registered.

Alternative solution would be to use user-supplied callback code which
performs registration instead of throwing an exception.

Original issue: http://code.google.com/p/kryo/issues/detail?id=7

Incorrect (de)serialization of java.util.Date

From [email protected] on August 03, 2010 13:48:36

What steps will reproduce the problem?

  1. Make a new Kryo object and register java.util.Date class.
  2. Make a new Date object and serialize it.
  3. Deserialize the Date object.

    What is the expected output? What do you see instead?
    The original date object and the deserialized one should be identical.

    What version of the Kryo are you using?
    1.01

    Quick google'ing on this problem reveals a related note: http://stackoverflow.com/questions/2725233/kryo-serialization-library-is-it-used-in-production

    The workaroud provided there is to override the Date serializer:
    [code]
    kryo.register(Date.class,
    new SimpleSerializer<Date>() {
    @OverRide public void write (ByteBuffer b, Date d) { b.putLong(d.getTime()); }
    @OverRide public Date read (ByteBuffer b) { return new Date(b.getLong()); }
    });
    [/code]

    I attached a unit test to reproduce the problem. It also contains the workaround code.

Attachment: KryoDateDefect.java

Original issue: http://code.google.com/p/kryo/issues/detail?id=23

Serializes items that can't be deserialized

From [email protected] on December 20, 2010 18:23:03

What steps will reproduce the problem?

  1. Register a number of classes with Kryo, including 'Class.class'
  2. Serialize something containing a Class as a field with Kryo
  3. Deserialize with Kryo

    What is the expected output? What do you see instead?
    We'd expect that it would fail serializing given that it won't be able to deserialize due to the 'newInstance' constraint w/ Class. Instead it serializes just fine, but a VM with the same registration properties as the current one can't deserialize it.


    What version of the Kryo are you using?
    Latest


    Please provide any additional information below.

Original issue: http://code.google.com/p/kryo/issues/detail?id=33

Not able to Serialize a class which had EnumSet as a member variable.

From [email protected] on September 30, 2010 06:53:56

What steps will reproduce the problem?

  1. Register a class which has EnumSet in it
    2.
    3.

    What is the expected output? What do you see instead?

    Caused by: java.lang.IllegalArgumentException: Class is not registered: java.util.RegularEnumSet
    at com.esotericsoftware.kryo.Kryo.getRegisteredClass(Kryo.java:311)
    at com.esotericsoftware.kryo.Kryo.writeClass(Kryo.java:366)
    at com.esotericsoftware.kryo.serialize.FieldSerializer.writeObjectData(FieldSerializer.java:165)
    ... 3 more

    What version of the Kryo are you using?
    1.03


    Please provide any additional information below.
    RegularEnumSet is not public so not able to register I could register EnumSet but not working.

Original issue: http://code.google.com/p/kryo/issues/detail?id=28

Public final fields are being set through ASM instead of reflection in FieldSerializer

From [email protected] on November 09, 2010 08:49:33

What steps will reproduce the problem?

  1. Create and serialize a class with a public final field
  2. Try to deserialize it

    What is the expected output? What do you see instead?

    A java.lang.IllegalAccessError is thrown when the ASM-generated helper class tries to set the field's value.

    One would expect the changes in issue #15 to call setAccessible on the field, but because the field gets put into the publicFields array list in FieldSerializer.rebuildCachedFields, it is handled with ASM regardless of the fact that it's final.

    What version of the Kryo are you using?

    1.03

    Please provide any additional information below.

    The fix is very simple -- in the if statement in FieldSerializer.java that adds elements to publicFields (line 99 in Kryo 1.03), add the condition !Modifier.isFinal(modifiers).

Original issue: http://code.google.com/p/kryo/issues/detail?id=30

Provide maven pom.xml

From martin.grotzke on April 05, 2010 21:17:40

In kryo-serializers I just wanted to reference the latest kryo from trunk without just referencing the projects
in eclipse :-)

For this I created a very simple pom.xml (for maven2) that builds kryo, see the file attached.
As version I chose 1.1-SNAPSHOT as a wild guess. Stuff like scm info, license, mailing list etc. is left out...

When you run "$ mvn install" maven tells you that neither minlog nor reflectasm is available in public repos
and that you need to install them. So just do
$ mvn install:install-file -DgroupId=com.esotericsoftware -DartifactId=reflectasm -Dversion=0.8 -
Dpackaging=jar -Dfile=lib/reflectasm-0.8.jar
and
$ mvn install:install-file -DgroupId=com.esotericsoftware -DartifactId=minlog -Dversion=1.2 -
Dpackaging=jar -Dfile=lib/minlog-1.2.jar
and afterwards again
$ mvn install

Then everything's fine.

It would be great to find this or s.th. similar in kryo. :)

Attachment: pom.xml

Original issue: http://code.google.com/p/kryo/issues/detail?id=14

Memory consumption

From [email protected] on March 20, 2010 14:29:26

Any use of the library requires one to know the size of the serialized
object which is not always true. Allocating 10 MB per thread in a server
setting just "to be sure" is not ideal.

For instance:
Kryo kryo = new Kryo();
kryo.setAllowUnregisteredClasses(true);
ByteBuffer buffer = ByteBuffer.allocate(1024 * 1024 * 10);
kryo.writeClassAndObject(buffer, "This is a test");

What is the expected output? What do you see instead?

I would expect a version of ther API to work with Outputstream for writing
and InputStream for reading, not ByteBuffer.

For instance:
Kryo kryo = new Kryo();
kryo.setAllowUnregisteredClasses(true);
OutputStream outputStream = ...
kryo.writeClassAndObject(outputStream, "This is a test");

What version of the product are you using? On what operating system?
Kryo 1.0 on Ubuntu 9.10 & Win7

If there is not requirement for reading the buffer after the data is
written to it, this should be simple to fix, perhaps by adding a thin
wrapper to allow your API to accept ByteBuffer, InputStream/OutputStream, etc.

So I guess this boils down to:
Do you read back the buffer contents after you have started serializing an
object?

Thanks for your time! :)

Original issue: http://code.google.com/p/kryo/issues/detail?id=10

StringSerializer decode error

From [email protected] on October 31, 2009 00:53:14

StringSerializer's get() reads too much data from the buffer.

put() counts byte[]'s length, but get() reads char[length],
As some char is more then 1 byte(eg. chinese), it causes an error.

The fixed get() looks like:
static public String get (final ByteBuffer buffer) {
int length = IntSerializer.get(buffer, true);
Context context = Kryo.getContext();
byte[] bytes = (byte[])context.get("byteArray");
if (bytes == null || bytes.length < length) {
bytes = new byte[length];
context.put("byteArray", bytes);
}
buffer.get(bytes, 0, length);
return new String(bytes, 0, length, charset);
}

Original issue: http://code.google.com/p/kryo/issues/detail?id=3

The size of the serialized array which contains the same String refrence is larger than java built-in

From [email protected] on April 20, 2011 18:24:37

What steps will reproduce the problem?
1.create a string array which contains the same String reference
2.serialize the array with kryo and java built-in
3.you will see the size of kryo is much more than java

What is the expected output? What do you see instead?
I think the same String should only be serialized once.
And the size of the array should be smaller than java built-in.

What version of the Kryo are you using?
1.04

Please provide any additional information below.
the code is here:
@test
public void testStringSer() throws IOException{
char[] chars = new char[1500];
Arrays.fill(chars, 'a');
String str = new String(chars);
testStringSer(str);

String[] strArray = new String[]{str, str, str};
testStringArraySer(strArray);
}

private void testStringSer(String str) throws IOException{
Kryo kryo = new Kryo();
kryo.setRegistrationOptional(true);
ObjectBuffer ob = new ObjectBuffer(kryo, 5 * 1024);
byte[] bytesKryo = ob.writeObjectData(str);
System.out.println("kryo byte length of string:"+ bytesKryo.length);

ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(str);
byte[] bytesJava = bos.toByteArray();
bos.close();
oos.close();
System.out.println("java byte length of string:"+bytesJava.length);
}

private void testStringArraySer(String[] strArray) throws IOException{
Kryo kryo = new Kryo();
kryo.setRegistrationOptional(true);
ObjectBuffer ob = new ObjectBuffer(kryo, 5 * 1024);
byte[] bytesKryo = ob.writeObjectData(strArray);
System.out.println("kryo byte length of string array:"+ bytesKryo.length);

ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(strArray);
byte[] bytesJava = bos.toByteArray();
bos.close();
oos.close();
System.out.println("java byte length of string array:"+bytesJava.length);
}

and the result is:
kryo byte length of string:1502
java byte length of string:1507
kryo byte length of string array:4511
java byte length of string array:1557

Original issue: http://code.google.com/p/kryo/issues/detail?id=43

Deserializing a class with transient field that requires deserialization of another class

From [email protected] on February 14, 2012 12:49:56

I have a class B which contains a transient field that its initialization requires deserialization of class A. Trying to deserialize class B completely breaks Kryo (running a single thread). I thought that maybe calling 'Kryo.getContext().reset()' would solve the issue but that didn't help.

What steps will reproduce the problem?

Run the attached code (also given below).

What is the expected output? What do you see instead?

I expect the program to end successfully. Instead I get an exception.

What version of the Kryo are you using?

1.04

Please provide any additional information below.

The code to reproduce the problem:


-------------------------------------------------------------------

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Vector;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.ObjectBuffer;

public class Main {

public static <T> void serialize(T obj, String filename) throws FileNotFoundException, IOException
{
Kryo kryo = new Kryo();
kryo.setRegistrationOptional(true);
//Kryo.getContext().reset();
ObjectBuffer buffer = new ObjectBuffer(kryo, 100000);
OutputStream os = new FileOutputStream(filename);
buffer.writeClassAndObject(os, obj);
os.close();
}

@SuppressWarnings("unchecked")
public static <T> T deserialize(String filename) throws IOException, ClassNotFoundException
{
Kryo kryo = new Kryo();
kryo.setRegistrationOptional(true);
//Kryo.getContext().reset();
InputStream is = new FileInputStream(filename);
ObjectBuffer buffer = new ObjectBuffer(kryo, 100000);
Object obj = buffer.readClassAndObject(is);
is.close();
return (T) obj;
}


public static class Class1
{
private Vector<float[]> values = new Vector<float[]>();
public Class1() {
for(int i=0; i < 2; ++i) values.add(new float[i+1]);
}
public float[] getValue(int i) { return values.get(i); }
}

public static class Class2
{
private Map<String, Vector<LinkedList<Float>>> data = new HashMap<String, Vector<LinkedList<Float>>>();
private transient Class1 class_1 = readClass1();
public Class2() {

Vector<LinkedList<Float>> value1 = new Vector<LinkedList<Float>>();
value1.add(new LinkedList<Float>());
value1.lastElement().add(1.1f);
value1.lastElement().add(1.2f);
value1.add(new LinkedList<Float>());
value1.lastElement().add(2.1f);
value1.lastElement().add(2.2f);

Vector<LinkedList<Float>> value2 = new Vector<LinkedList<Float>>();
value2.add(new LinkedList<Float>());
value2.lastElement().add(1.1f);
value2.lastElement().add(1.2f);
value2.add(new LinkedList<Float>());
value2.lastElement().add(2.1f);
value2.lastElement().add(2.2f);
value2.add(new LinkedList<Float>());
value2.lastElement().add(3.1f);
value2.lastElement().add(3.2f);

data.put("key1", value1);
data.put("key2", value2);
}
public float[] getValue() { return class_1.getValue(1); }

private Class1 readClass1()
{
try {
return deserialize("d:/test_java_class_1.dat");
} catch (Exception e) {
throw new Error("Can't deserialize !", e);
}
}
}


public static void main(String[] args) throws Exception
{
com.esotericsoftware.minlog.Log.TRACE = true;

Class1 base = new Class1();
serialize(base, "d:/test_java_class_1.dat");
Class2 one = new Class2();
System.out.println(one.getValue().length);
serialize(one, "d:/test_java_class_2.dat");
Class2 two = deserialize("d:/test_java_class_2.dat");
System.out.println(two.getValue().length);
}

}

Attachment: Main.java

Original issue: http://code.google.com/p/kryo/issues/detail?id=50

Forward and backward compatibility

From [email protected] on March 25, 2010 02:11:19

Current Kryo object graph serializers (eg, FieldSerializer) use the Java
class definition as a schema. This reduces serialized size because the data
for an object's fields is written in a known order; there is no need to
write field identifiers. The drawback is that any change to the class
definition invalidates serialized bytes made with the old class definition.

Both scenarios should be supported. Some uses of Kryo have short-lived
serialized bytes (eg, IPC or a networked game) and gladly sacrifice
forward/backward compatibility for smaller serialized size. Other uses keep
serialized bytes around for a long time (eg, storing them on disk or in a
database) and it would be unacceptable to invalidate all existing data when
a class is modified.

To support forward/backward compatibility, during serialization, the first
time an object type is encountered the field names would be written. This
defines the order the field values will appear in the serialized bytes for
that type. If a field no longer exists, it is ignored. Fields not in the
serialized bytes are left unchanged.

It isn't terribly efficient to write the field name as Strings. Possibly an
annotation could be provided that would allow fields to be given an
ordinal, allowing the field to be referenced with just 1 byte rather than 1
byte per character in its name.

Original issue: http://code.google.com/p/kryo/issues/detail?id=12

ReferenceFieldSerializerTest failure: non static inner class

From [email protected] on April 12, 2010 21:52:41

Hi Nate,

I've checked out the latest revision of kryo from svn and built using
Netbeans 6.0.1

$ uname -a
SunOS bluto 5.10 Generic_137111-06 sun4u sparc SUNW,Ultra-80

$ java -version
java version "1.6.0_07"
Java(TM) Platform, Standard Edition for Business (build 1.6.0_07-b06)
Java HotSpot(TM) Server VM (build 10.0-b23, mixed mode)

These are the failure results, all other tests are passing:

Testsuite: com.esotericsoftware.kryo.serialize.ReferenceFieldSerializerTest
Tests run: 5, Failures: 2, Errors: 0, Time elapsed: 1.028 sec

Testcase:
testNonStaticInnerClassPublicConstructor(com.esotericsoftware.kryo.serialize.ReferenceFieldSerializerTest):
FAILED
Incorrect length. expected:<18> but was:<15>
junit.framework.AssertionFailedError: Incorrect length. expected:<18> but
was:<15>
at
com.esotericsoftware.kryo.KryoTestCase.roundTripKryo(KryoTestCase.java:86)
at
com.esotericsoftware.kryo.KryoTestCase.roundTrip(KryoTestCase.java:74)
at
com.esotericsoftware.kryo.serialize.ReferenceFieldSerializerTest.testNonStaticInnerClassPublicConstructor(ReferenceFieldSerializerTest.java:76)

Testcase:
testNonStaticInnerClassPrivateConstructor(com.esotericsoftware.kryo.serialize.ReferenceFieldSerializerTest):
FAILED
Incorrect length. expected:<18> but was:<15>
junit.framework.AssertionFailedError: Incorrect length. expected:<18> but
was:<15>
at
com.esotericsoftware.kryo.KryoTestCase.roundTripKryo(KryoTestCase.java:86)
at
com.esotericsoftware.kryo.KryoTestCase.roundTrip(KryoTestCase.java:74)
at
com.esotericsoftware.kryo.serialize.ReferenceFieldSerializerTest.testNonStaticInnerClassPrivateConstructor(ReferenceFieldSerializerTest.java:91)

Test com.esotericsoftware.kryo.serialize.ReferenceFieldSerializerTest FAILED

Original issue: http://code.google.com/p/kryo/issues/detail?id=16

Can't figure out how to get rid of some loggings

From [email protected] on September 28, 2010 00:07:45

What steps will reproduce the problem?

  1. file read
  2. kryo.register(MarketData.class, new DeltaCompressor(kryo, new FieldSerializer(kryo, MarketData.class)));
  3. buffer.writeObject(fileOutputStream, o);

    What is the expected output? What do you see instead?
    no logging

    I see:
    compress APPEND 10: -64,-115,-73,1,-14,-59,-119,-105,-127,66,
    compress APPEND 29: 63,-26,92,-111,-47,78,59,-51,-96,-128,-79,1,63,-26,90,28,-84,8,49,39,-64,-124,61,-56,-35,-119,-105,-127,66,
    compress COPY at 0, length 14: 63,-26,92,-111,-47,78,59,-51,-96,-128,-79,1,63,-26,

    What version of the Kryo are you using?
    1.03

    Actually it's not minlog logs, in code there are system.outs, and some debug boolean, do I have to set it to false somehow?

Original issue: http://code.google.com/p/kryo/issues/detail?id=27

CompatibleSerializer deserializes wrongly if subclass has the same field as super class

From [email protected] on May 04, 2011 09:33:48

What steps will reproduce the problem?

  1. Run the code attached.
    jvm arg: -Djava.io.tmpdir=<tempdir to stored the output file>

    //For default FieldSerializer
    test.withDefault();

    //For CompatibleFieldSerializer
    test.withCompatibleFieldSerializer;

  2. If the file is not there it will serialize a sample object to a file and save it to tempdir.
    If the file has already existed, the program will deserialize it.

    3.

    What is the expected output? What do you see instead?

    //Output with default FieldSerializer:
    class[class com.scb.saturn.services.position.NewKryoTest$ChildModel];field1[f1];field2[f2];longField[25];

    //Output with CompatibleFieldSerializer:
    class[class com.scb.saturn.services.position.NewKryoTest$ChildModel];field1[f1];field2[f2];longField[0];

    Expected the same output from both FieldSerializer and CompatibleFieldSerializer


    What version of the Kryo are you using?
    1.04

    Please provide any additional information below.

Attachment: NewKryoTest.java

Original issue: http://code.google.com/p/kryo/issues/detail?id=45

BufferOverflowException

From [email protected] on March 08, 2011 07:00:51

What steps will reproduce the problem?
1.create a bean class, holding a reference to another one, like
public class Dinner
{
private Dinner next;

public Dinner getNext()
{
return next;
}

public void setNext(Dinner next)
{
this.next = next;
}
}
2.instantiate one and set the next to itself,
Dinner d = new Dinner();
d.setNext(d);
3.Use kryo ( version 1.01 ) to serialize it,
byte[] bytes = buffer.writeObjectData(src);

You will get the BufferOverflowException for sure.

Original issue: http://code.google.com/p/kryo/issues/detail?id=41

Provide possibility to set the RegisteredClass for a given type - putRegisteredClass(Class, RegisteredClass)

From martin.grotzke on June 25, 2010 22:16:35

Hi Nate,

I'd like to have the possibility to set a given RegisteredClass for a certain type, e.g. via s.th. like
void putRegisteredClass( Class type, RegisteredClass registeredClass )

My situation is the following: I have a serializer for cglib proxies that I register using a marker class:
kryo.register( CGLibProxySerializer.CGLibProxyMarker.class, new CGLibProxySerializer( kryo ) );

When a cglib proxy class is written via Kryo.writeClass, this proxy class is not yet known as it's s.th. like
MSM_de.javakaffee.kryoserializers.cglib.CGLibProxySerializerTest$MyServiceImpl$$EnhancerByCGLIB$$d0595dcf

For this class I want to register the previously registered CGLibProxySerializer, so that this one is used for the actual proxy class.

I know that I could override getRegisteredClass(Class) like this:
public RegisteredClass getRegisteredClass( final Class type ) {
if ( CGLibProxySerializer.canSerialize( type ) ) {
return super.getRegisteredClass( CGLibProxySerializer.CGLibProxyMarker.class );
}
return super.getRegisteredClass( type );
}

Unfortunately, CGLibProxySerializer.canSerialize( type ) is rather expensive and this would be called for each writeClass, so I'd prefer to just override handleUnregisteredClass(Class):
protected void handleUnregisteredClass( final Class type ) {
if ( CGLibProxySerializer.canSerialize( type ) ) {
putRegisteredClass( type, getRegisteredClass( CGLibProxySerializer.CGLibProxyMarker.class ) );
}
else {
super.handleUnregisteredClass( type );
}
}

The patch for putRegisteredClass(Class, RegisteredClass) is attached.

Can you include this or s.th. similar in kryo?

Thx && cheers,
Martin

Attachment: Kryo_putRegisteredClass.patch

Original issue: http://code.google.com/p/kryo/issues/detail?id=22

Weak References to Class files

From [email protected] on April 13, 2010 12:42:21

This is a very preliminary rough patch. I have some other ideas that I'd
also like to experiment, I've posted it here so others may experiment with
it also.

New BSD License as per Kryo.

This builds and all the tests pass, note that this patch is set to weak
references in Kryo's constructor by default.

You've got some performance testing code also I believe?

Cheers,

Peter.

Attachment: kryoWeakLinks.patch

Original issue: http://code.google.com/p/kryo/issues/detail?id=17

Cann't read serialized ArrayList or HashMap

From [email protected] on November 09, 2009 16:05:34

What steps will reproduce the problem?
Kryo kryo = new Kryo();
kryo.register(ArrayList.class);
//TestClass stc = new TestClass();
ArrayList al = new ArrayList(Arrays.asList("1", "2", "3"));
ByteBuffer buffer = ByteBuffer.allocate(1024);

kryo.writeObject(buffer,al);
buffer.flip();
ArrayList stc1 = kryo.readObject(buffer, ArrayList.class);
System.out.println(stc1.get(1));
What is the expected output? What do you see instead?
Exception is java.nio.BufferUnderflowException

What version of the product are you using? On what operating system?

0.92, XP SP2 and jdk 1.6
Please provide any additional information below.

Original issue: http://code.google.com/p/kryo/issues/detail?id=4

Unable to deserialize with CompatibleFieldSerializer

From [email protected] on May 03, 2011 08:45:55

What steps will reproduce the problem?

  1. Create any class with an enum field
  2. Register the class and enum in step 1 with CompatibleFieldSerializer
  3. Serialize the class and deserialize it with CompatibleFieldSerializer

    What is the expected output? What do you see instead?

    Expected output: the object should be deserialized correctly

    Received exception:

    Class cannot be created (missing no-arg constructor): test.KryoBackwardCompatiblityTest$TestEnumSer
    Serialization trace:
    testEnum (test.KryoBackwardCompatiblityTest$AModel)
    at com.esotericsoftware.kryo.Kryo.newInstance(Kryo.java:688)
    at com.esotericsoftware.kryo.Serializer.newInstance(Serializer.java:75)
    at com.esotericsoftware.kryo.serialize.CompatibleFieldSerializer.readObjectData(CompatibleFieldSerializer.java:215)
    at com.esotericsoftware.kryo.Serializer.readObject(Serializer.java:61)
    at com.esotericsoftware.kryo.serialize.CompatibleFieldSerializer.readObjectData(CompatibleFieldSerializer.java:283)
    at com.esotericsoftware.kryo.serialize.CompatibleFieldSerializer.readObjectData(CompatibleFieldSerializer.java:215)
    at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:566)


    What version of the Kryo are you using?

    1.03
    1.04

    Please provide any additional information below.

Original issue: http://code.google.com/p/kryo/issues/detail?id=44

Zip archive does not expand into a directory

From [email protected] on December 31, 2010 02:14:15

It is convention to zip a directory so that on expansion you get a directory. Instead I got the contents of the kryo directory sprayed across my working area which I then had to go an clean up manually.

What steps will reproduce the problem?
1.unzip kryo.zip

What version of the Kryo are you using?
kryo-1.0.3

Please provide any additional information below.

Original issue: http://code.google.com/p/kryo/issues/detail?id=36

Buffer Allocation Fails when using Integer.MAX_VALUE

From [email protected] on March 06, 2011 14:34:02

What steps will reproduce the problem?

  1. Use an ObjectBuffer with a max allocation of Integer.MAX_VALUE
  2. Try allocate a very large object
  3. On the last increment of trying to double the buffer, the line that has int newCapacity = Math.min(maxCapacity, capacity * 2) results in a negative value because capacity*2 flips to negative.

    What is the expected output? What do you see instead?
    It should take maxCapacity over a negative value


    What version of the Kryo are you using?
    1.03


    Please provide any additional information below.

Original issue: http://code.google.com/p/kryo/issues/detail?id=40

Problem with deflate - wrong result?

From [email protected] on May 11, 2010 08:44:42

What steps will reproduce the problem?

  1. Run the attached program

    What is the expected output? What do you see instead?
    Expected: Same hash code for original object and de-serialized object
    Actual: Different hash codes

    What version of the Kryo are you using?
    1.01

    Please provide any additional information below:
    The application works (although the serialized size is mucgh larger than
    for Java serialization) when no compression is used.
    All the deserialized HashSets seem to be empty when compression is used.

    -------------------------------------------

    import com.esotericsoftware.kryo.Kryo;
    import com.esotericsoftware.kryo.compress.DeflateCompressor;
    import com.esotericsoftware.kryo.serialize.FieldSerializer;

    import java.io.;
    import java.nio.ByteBuffer;
    import java.util.
    ;


    public class Serializer {

    public static void close(final Closeable closeable) {
    if (closeable != null)
    try {
    closeable.close();
    } catch (IOException e) {
    // ignore
    }
    }

    public static byte[] serialize(final Serializable serializable)
    throws IOException {
    ByteArrayOutputStream os = null;
    BufferedOutputStream bos = null;
    ObjectOutputStream oos = null;
    try {
    os = new ByteArrayOutputStream();
    bos = new BufferedOutputStream(os);
    oos = new ObjectOutputStream(bos);
    oos.writeObject(serializable);
    oos.flush();
    bos.flush();
    os.flush();
    return os.toByteArray();
    } finally {
    CloseHelper.close(oos);
    close(bos);
    close(os);
    }
    }

    public static Serializable deserialize(final byte[] serialized)
    throws IOException {
    ByteArrayInputStream bais = null;
    BufferedInputStream bis = null;
    ObjectInputStream ois = null;
    try {
    bais = new ByteArrayInputStream(serialized);
    bis = new BufferedInputStream(bais);
    ois = new ObjectInputStream(bis);
    try {
    return (Serializable) ois.readObject();
    } catch (ClassNotFoundException e) {
    throw new IllegalStateException("Failed to create object!", e);
    }
    } finally {
    close(ois);
    close(bis);
    close(bais);
    }
    }

    private static Serializable buildStructure(int size) {
    Random random = new Random(123456789);
    ArrayList<Set<Object>> objects = new ArrayList<Set<Object>>();
    for (int i = 0; i < size; i++) {
    Set<Object> set = new HashSet<Object>();
    // Add some data
    final int numberOfIntegers = random.nextInt(5);
    for (int integers = 0; integers < numberOfIntegers; integers++)
    set.add(random.nextInt(10000));
    final int numberOfDoubles = random.nextInt(5);
    for (int doubles = 0; doubles < numberOfDoubles; doubles++)
    set.add(random.nextDouble());
    // Add some references
    final int numberOfReferences =
    random.nextInt(Math.min(random.nextInt(5) + 1, Math.max(objects.size(), 1)));
    for (int references = 0; references < numberOfReferences;
    references++)
    if (objects.size() > 0) {
    set.add(objects.get(random.nextInt(objects.size())));
    } else {
    set.add(objects);
    }
    objects.add(set);
    }
    return objects;
    }

    public static void main(String[] args) {
    final Serializable object = buildStructure(10000);
    Kryo kryo = new Kryo();
    kryo.register(HashSet.class, new DeflateCompressor(new
    FieldSerializer(kryo, HashSet.class)));
    kryo.register(ArrayList.class);
    ByteBuffer bb = ByteBuffer.allocate(10000000);
    long start = System.currentTimeMillis();
    kryo.writeObject(bb, object);
    bb.flip();
    System.out.println("Kryo size = " + bb.remaining());
    Object result = kryo.readObject(bb, ArrayList.class);
    long elapsedKryo = System.currentTimeMillis() - start;
    System.out.println("Original hashCode = " + object.hashCode() + ",
    Kryo result hashCode = " + result.hashCode() + ", elapsed = " + elapsedKryo);
    result = null;
    try {
    start = System.currentTimeMillis();
    byte[] serialized = serialize(object);
    System.out.println("Java Size = " + serialized.length);
    result = deserialize(serialized);
    long elapsedJava = System.currentTimeMillis() - start;
    System.out.println("Original hashCode = " + object.hashCode() +
    ", Java result hashCode = " + result.hashCode() + ", elapsed = " +
    elapsedJava);
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }

Original issue: http://code.google.com/p/kryo/issues/detail?id=19

"Can not set field to java.lang.Boolean"

From [email protected] on November 25, 2011 04:02:57

Using Kryonet we're having a bit of trouble when moving large-ish objects over a network connection. The error does not happen when connecting to localhost, only when connecting to a remote computer.

The error itself comes from the depths of Kryo where, for some reason, Kryo is trying to set a field of non-Boolean type to a Boolean value. The particular field which it tries to set is not always the same, either.

Any ideas on why this might be happening?

Using Kryo/Kryonet v1.04.

Original issue: http://code.google.com/p/kryo/issues/detail?id=49

Circular field-types

From [email protected] on March 01, 2010 09:08:41

Hello

I'm just investigating alternativs for java serialization. We are using
SpringHTTPInvoker to transmit objects. After it seems everything should run
now. I run into a Stackoverflow during serialisation. We have a quite
complex entity-structure where it is possible to navigate forth and back
through the object tree. When I look at the stacktrace I would say the
repeating fieldtypes are the problem.

java.lang.StackOverflowError
at java.lang.reflect.AccessibleObject.(AccessibleObject.java:137)
at java.lang.reflect.Field.(Field.java:104)
at java.lang.reflect.Field.copy(Field.java:127)
at java.lang.reflect.ReflectAccess.copyField(ReflectAccess.java:122)
at sun.reflect.ReflectionFactory.copyField(ReflectionFactory.java:289)
at java.lang.Class.copyFields(Class.java:2739)
at java.lang.Class.getDeclaredFields(Class.java:1743)
at
com.esotericsoftware.kryo.serialize.FieldSerializer.rebuildCachedFields(FieldSerializer.java:65)
at
com.esotericsoftware.kryo.serialize.FieldSerializer.(FieldSerializer.java:52)
at com.esotericsoftware.kryo.Kryo.getDefaultSerializer(Kryo.java:224)
at com.esotericsoftware.kryo.Kryo.getRegisteredClass(Kryo.java:240)
at
com.esotericsoftware.kryo.serialize.FieldSerializer.rebuildCachedFields(FieldSerializer.java:100)
at
com.esotericsoftware.kryo.serialize.FieldSerializer.(FieldSerializer.java:52)
at com.esotericsoftware.kryo.Kryo.getDefaultSerializer(Kryo.java:224)
at com.esotericsoftware.kryo.Kryo.getRegisteredClass(Kryo.java:240)
at
com.esotericsoftware.kryo.serialize.FieldSerializer.rebuildCachedFields(FieldSerializer.java:100)
at
com.esotericsoftware.kryo.serialize.FieldSerializer.(FieldSerializer.java:52)
at com.esotericsoftware.kryo.Kryo.getDefaultSerializer(Kryo.java:224)
at com.esotericsoftware.kryo.Kryo.getRegisteredClass(Kryo.java:240)
at
com.esotericsoftware.kryo.serialize.FieldSerializer.rebuildCachedFields(FieldSerializer.java:100)
at
com.esotericsoftware.kryo.serialize.FieldSerializer.(FieldSerializer.java:52)
at com.esotericsoftware.kryo.Kryo.getDefaultSerializer(Kryo.java:224)
at com.esotericsoftware.kryo.Kryo.getRegisteredClass(Kryo.java:240)

I'm wondering if kryo would have the same problem with repeated objects and
circular references.
Maybee an IdentiyHashMap would solve this during processing the fields.

Cheers
Marco

What version of the product are you using? On what operating system?
Windows Kryo 0.99

Please provide any additional information below.

Original issue: http://code.google.com/p/kryo/issues/detail?id=8

It is not possible to serialize classes without a zero-argument-constructor

From [email protected] on November 30, 2009 04:04:19

What steps will reproduce the problem?

  1. generate a class without default constructor
  2. serialize it with kryo

    What is the expected output? What do you see instead?
    expected: no output
    output: Exceptions about missing zero-argument constructor

    What version of the product are you using? On what operating system?
    0.92



    why not using the internal way of creating an empty object?
    example source attached

Attachment: createObject.java

Original issue: http://code.google.com/p/kryo/issues/detail?id=5

final fields should be handled by FieldSerializer if setFieldsAsAccessible is set to true

From martin.grotzke on April 05, 2010 23:10:33

The FieldSerializer right now does not handle final fields. It should do so if setFieldsAsAccessible is set to true
(default). As an alternative, it would be nice to have the possible to have s.th. like
setSupportFinalFields(boolean).

Attached is a patch for FieldSerializer that checks setFieldsAsAccessible and does not skip the field if
setFieldsAsAccessible is true.

Attachment: FieldSerializer_finalFields.patch

Original issue: http://code.google.com/p/kryo/issues/detail?id=15

Deserialization of SomeIFace[] with Enum as impl of SomeIFace fails

From martin.grotzke on May 26, 2010 00:44:30

The attached ArraySerializerTest fails with
java.lang.IllegalArgumentException: array element type mismatch
at java.lang.reflect.Array.set(Native Method)
at
com.esotericsoftware.kryo.serialize.ArraySerializer.readArray(ArraySerializ
er.java)

Just place the ArraySerializerTest in
test/com/esotericsoftware/kryo/serialize and execute.

I ran it against the kryo trunk (rev 108).

We have such a combination of an interface-array and enum implementations,
so this is a real issue for us.

Attachment: ArraySerializerTest.java

Original issue: http://code.google.com/p/kryo/issues/detail?id=20

2D arrays are incorrectly (de)serialized

From [email protected] on March 03, 2011 08:18:52

What steps will reproduce the problem?

  1. Run the following code:
    public static void main(String[] args)
    {
    Kryo kryo = new Kryo();
    kryo.setRegistrationOptional(true);
    ByteBuffer buffer = ByteBuffer.allocate(1024);

    float[][] array = new float[4][];
    array[0] = new float[]{0.0f,1.0f};
    array[1] = null;
    array[2] = new float[]{2.0f,3.0f};
    array[3] = new float[]{3.0f};
    print(array,"Original array:");

    kryo.writeClassAndObject(buffer, array);
    buffer.rewind();
    Object o = kryo.readClassAndObject(buffer);
    float[][] array_ = (float[][])o;
    print(array_,"Deserialized array:");
    }

    static void print(float[][] array, String header)
    {
    System.out.println(header);
    for(int i=0;i<array.length;i++)
    {
    System.out.println(Arrays.toString(array[i]));
    }
    System.out.println();
    }

    I get this:
    Original array:
    [0.0, 1.0]
    null
    [2.0, 3.0]
    [3.0]

    Deserialized array:
    [0.0, 1.0]
    [2.0, 3.0]
    [3.0, 0.0]
    [0.0, 0.0]

    What is the expected output? What do you see instead?
    I expect the data to be deserialized into array with the same data.
    Deserialized array should be the same as Original array, but it isn't.

    What version of the Kryo are you using?
    1.04

    Please provide any additional information below.
    With 1.02 I had an ArrayOutOfBoundsException in not the same, but similar situation.

Original issue: http://code.google.com/p/kryo/issues/detail?id=39

Collections/Map/Array references at not handled by the ReferenceFieldSerializer

From [email protected] on March 02, 2011 23:32:04

What steps will reproduce the problem?
1.When 2 objects reference the same collection/map/array and you make a roundtrip (serialize/deserialize), you end up with 2 collections/map/array instead of the same ones in each object.

What is the expected output? What do you see instead?
Serializing the same collection should result in only one collection after deserialization. Right now I end up with 2 collections. I understand the the ReferenceFieldSerializer is not intended to handle this case, because Collections/Map/Array are handled by other serializers so I made some modifications to the code to be able to handle this case with a decorator. If you want to integrate it to kryo, feel free to, or maybe you have a better approch to propose.

What version of the Kryo are you using?
1.04

Please provide any additional information below.
Attached is a patch for the modifications and a jUnit test for the case.

Attachment: kryo_collections_references.patch

Original issue: http://code.google.com/p/kryo/issues/detail?id=38

Support concurrent access of Kryo.register

From martin.grotzke on September 08, 2010 15:05:35

When Kryo is used in a multi-threaded environment external synchronization is required to ensure that the internally used HashMap classToRegisteredClass (and probably the IntHashMap idToRegisteredClass) cannot be broken which might cause infinite loops.

The suggested patch now synchronizes write access of classToRegisteredClass on exactly this object. From my understanding this is enough to ensure that the HashMap internal linked lists cannot be broken. As read access is not synchronized it might happen that some thread gets an "invalid" object from the map that is replaced by a second thread, but IMHO this isn't an issue as correct functionality/behavior is not affected by this.

As the synchronized block on classToRegisteredClass also included the idToRegisteredClass.put, I think this potential concurrency issue is also solved.

Is this patch acceptable? Can you apply it as soon as possible and make a new release? This would save the world for me right now :-)

Attachment: Kryo_concurrentHashMapAccess.patch

Original issue: http://code.google.com/p/kryo/issues/detail?id=26

BigDecimal and BigInteger Serialization Support

From [email protected] on March 11, 2010 04:51:10

Kryo should support BigDecimal and BigInteger classes out of the box.

They could probably stand to be optimized but I have attached Serializers
to provide the basic required functionality, and appropriate unit tests.

Attachment: BigDecimalSerializer.java BigIntegerSerializer.java BigDecimalSerializerTest.java BigIntegerSerializerTest.java

Original issue: http://code.google.com/p/kryo/issues/detail?id=9

Enums with Method definitions

From [email protected] on January 28, 2011 03:42:12

What steps will reproduce the problem?

  1. Create an Enum A where the constant values have method definitions. Create a class B with a public field of type A.
    2.Instantiate B and serialize it where handling of unregistered classes is enabled.
    3.Deserialize it.

    What is the expected output? What do you see instead?
    The expected output is that the original output gets recovered. Instead, a null pointer exception is thrown (which gets re-thrown as a serialization exception.

    What version of the Kryo are you using?
    I tried this with 1.03 and the current head of trunk.

    Please provide any additional information below.

    For Enums where the constant values have method definitions, Java assigns each enumeration value its own inner class. For an Enum A with values "One" and "Two", the class of A.One would be A$1. This seems to cause trouble with Kryo. When registration is mandatory, Kryo will fail on serialization because A$1 has not been registered even though A has. But even if I register A.One and A.Two explicitly, this still causes trouble inside the FieldSerializer for objects that use this enum as a field type.

    Maybe using the declaring class of an enum constant (i.e. A.One.getDeclaringClass()) rather than getClass() would solve the problem.

    Example stack trace:
    com.esotericsoftware.kryo.SerializationException: Unable to deserialize object of type: edu.umd.umiacs.dogma.diskgraph.serializer.test.TestClass
    at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:596)
    at edu.umd.umiacs.dogma.diskgraph.serializer.test.SerializerUnitTest.objectWriteRead(SerializerUnitTest.java:52)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
    at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    Caused by: com.esotericsoftware.kryo.SerializationException: Serialization trace:
    e (edu.umd.umiacs.dogma.diskgraph.serializer.test.TestClass)
    at com.esotericsoftware.kryo.serialize.FieldSerializer.readObjectData(FieldSerializer.java:237)
    at com.esotericsoftware.kryo.serialize.FieldSerializer.readObjectData(FieldSerializer.java:199)
    at com.esotericsoftware.kryo.Serializer.readObject(Serializer.java:61)
    at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:592)
    ... 25 more
    Caused by: java.lang.NullPointerException
    at com.esotericsoftware.kryo.serialize.EnumSerializer.readObjectData(EnumSerializer.java:24)
    at com.esotericsoftware.kryo.serialize.FieldSerializer.readObjectData(FieldSerializer.java:219)
    ... 28 more

Original issue: http://code.google.com/p/kryo/issues/detail?id=37

ByteArrayCompressor.compress() allocates byte array that is too short if input buffer length > 2048

From [email protected] on April 22, 2010 09:45:02

In Kryo 1.0, when ByteArrayCompressor.compress() is passed an inputBuffer
that contains more than 2048 bytes to be compressed, it throws an
IndexOutOfBoundsException.

Here's the code.

public void compress (ByteBuffer inputBuffer, Object object, ByteBuffer
outputBuffer) {
Context context = Kryo.getContext(); // 1
byte[] inputBytes = context.getBuffer(bufferSize).array(); // 2
int inputLength = inputBuffer.remaining(); // 3
inputBuffer.get(inputBytes, 0, inputLength); // 4
compress(inputBytes, inputLength, outputBuffer); // 5
}

The problem is that line 2 will normally return a byte array that is only
2048 bytes long and line 4 will throw an exception if the 'inputBytes'
array is shorter than 'inputLength'.

Original issue: http://code.google.com/p/kryo/issues/detail?id=18

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.