payamrastogi / kryo

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

Equals objects produce different byte sequences. #105

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

  1. Create a composite Object (object0) . Serialize the object0 to a   file0 with default settings.
  2. Save the object0, for example, to a database.
  3. Restore the object (object1) from the database.
  4. Be sure that the object1 equals object0;
  5. Serialize object1 to a file1.
  6. Compare file0 and file1. They are different.

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

  Equals objects produce equals byte sequence; 

What version of the Kryo are you using?
2.20

Please provide any additional information below.
There is a workaround - kryo.setReferences(false);

Original issue reported on code.google.com by a.solov...@tinkoffdigital.ru on 22 Mar 2013 at 9:16

Attachments:

GoogleCodeExporter commented 9 years ago
Sorry for an inaccuracy. 
I`ve serialized a List<Object> not a Object. The difference was between two 
List<> from different data sources. 
There was no proxy on Database object. 
Code snippet:
(the parameter List<X> described in ObjectStructure.7z)

  private static  Kryo kryo =new Kryo();
 private static MessageDigest md5= MessageDigest.getInstance("MD5");

  public static  byte[] getMd5(List<X> object){
      ByteArrayOutputStream b=  new ByteArrayOutputStream(1000);
      Output output = new Output(b);
      serialize(object,output);

      return md5.digest(b.toByteArray());
   }
  private static void serialize(Object object, Output output){
      try{
         kryo.writeObject(output, output);

      }finally{
         output.close();
      }
   }

Original comment by a.solov...@tinkoffdigital.ru on 2 Apr 2013 at 9:57