My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 47: ISerializable#deserialize return object is not used
1 person starred this issue and may be notified of changes. Back to list
Status:  Verified
Owner:  alex.id....@gmail.com
Closed:  Jun 2011


 
Reported by jimlero...@gmail.com, Jun 20, 2011
* What steps will reproduce the problem?

1. Create a class that implements ISerializable. Return the serialized object as part of the returned object of the deserialized function.
2. Create a test case that deserializes an object of this custom serialization.
3. Expect the object to be deserialized correctly.

It isn't really an issue but the signature of the deserialize function and its lack of documentation can lead to confusion on how to properly use it. I had to delve into the source code to see the proper usage.

* What version of the product are you using? On what operating system?
flexxb 2.1.0
windows xp :(

* Please provide any additional information below.

This is the exact function signature of deserialize:

/**
 * Deserialize this object from its serialized representation.
 * @param source serialized data source
 */
function deserialize(source : Object) : Object;

The function mentions a return value of type Object and says this is the serialized data source. When I initially implemented this function, I returned the serialized object back to the caller. My test case gave me an instanciated object of the correct type but it was a blank object: it didn't have any of the deserialized fields.

By looking at the source code, I realized that the returned object is not used at all and in fact the proper implementation is to deserialized the fields directly in the instance of the ISerializable implementee:

//update object fields
if (mappingModel.descriptorStore.isCustomSerializable(objectClass)) {
	ISerializable(result).deserialize(serializedData);
}

Hence, while it works when you understand it, a proper 'fix' is to remove any possible confusion on how to implement this function: a) remove the return object in the signature and make it clear the function should deserialize in the instance where it operates or b) use the returned object rather than relying on the operating instance to get the fields serialization.

I hope my explanation is clear. Let me thank you too for flexxb, I really have the impression it improved a lot in version 2.

Regards,
Jimmy

Jun 20, 2011
Project Member #1 alex.id....@gmail.com
Good catch!
I'll take a look and fix it

Alex
Status: Accepted
Labels: -Priority-Medium Priority-Low
Jun 22, 2011
Project Member #2 alex.id....@gmail.com
(No comment was entered for this change.)
Labels: Milestone-2.2.0
Jun 22, 2011
Project Member #3 alex.id....@gmail.com
(No comment was entered for this change.)
Status: Fixed
Apr 14, 2012
Project Member #4 alex.id....@gmail.com
(No comment was entered for this change.)
Status: Verified
Owner: alex.id....@gmail.com

Powered by Google Project Hosting