Nov11 / kryo

Automatically exported from code.google.com/p/kryo
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Cann't read serialized ArrayList or HashMap #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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 reported on code.google.com by yipen...@gmail.com on 9 Nov 2009 at 3:05

GoogleCodeExporter commented 9 years ago
If I switch to use writeObhectData and readObjectData, it's right.
I think canBeNull support is not ready.

Original comment by yipen...@gmail.com on 10 Nov 2009 at 5:08

GoogleCodeExporter commented 9 years ago
I find it's kryo writeObject(ByteBuffer buffer, Object object) method 
implementation's bug:

getRegisteredClass(object.getClass()).serializer.writeObjectData(buffer, 
object);

should be 

getRegisteredClass(object.getClass()).serializer.writeObject(buffer, object);

Original comment by yipen...@gmail.com on 10 Nov 2009 at 8:18

GoogleCodeExporter commented 9 years ago
Good find, thanks. Fix is in SVN.

Original comment by nathan.s...@gmail.com on 6 Jan 2010 at 6:47