Serialized/Deserialized object not the same as original object!
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   rk_p
Posted On:   Thursday, February 3, 2005 08:18 AM

I am creating a class object and then serializing it using the following code. ByteArrayOutputStream ostream = new ByteArrayOutputStream(1024); ObjectOutputStream ooutput = new ObjectOutputStream(ostream); ooutput.writeObject(originalObject); ooutput.flush(); ostream.close(); byte[] inBuffer = ostream.toByteArray(); ByteArrayInputStream istream = new ByteArrayInputStream(inBuffer); ObjectInputStream oinput = new ObjectInputStream(istream); Object serialized = oinput.readObject(); istream.close(); After the serialization I check whether both the object are similar using the following code. assertEquals(MISMATCH_ERROR, original, seri   More>>

I am creating a class object and then serializing it using the following code.

ByteArrayOutputStream ostream = new ByteArrayOutputStream(1024);
ObjectOutputStream ooutput = new ObjectOutputStream(ostream);

ooutput.writeObject(originalObject);

ooutput.flush();
ostream.close();

byte[] inBuffer = ostream.toByteArray();
ByteArrayInputStream istream = new ByteArrayInputStream(inBuffer);
ObjectInputStream oinput = new ObjectInputStream(istream);

Object serialized = oinput.readObject();

istream.close();

After the serialization I check whether both the object are similar using the following code.

assertEquals(MISMATCH_ERROR, original, serialized);

For some objects, I am recieving the following error.

Serialized/Deserialized object not the same as original object! expected: but was:

In Some cases, I get the whole object listed instead of the object id. In such cases, when I manually compare the values, they are all the same.
Why do I get this error?

Thanks in Advance.
RK

   <<Less

Re: Serialized/Deserialized object not the same as original object!

Posted By:   Anonymous  
Posted On:   Tuesday, February 8, 2005 08:26 AM

The serialized object is read into memory at a different location from the original, of course, so the pointers are different, even though one is a clone of the other.
About | Sitemap | Contact