Serialization bug...

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

sadensmol
Posts: 3
Joined: 20 Feb 2018, 05:25

Serialization bug...

Postby sadensmol » 20 Feb 2018, 05:47

Hi, All.
I tried to find a bug tracker but with no luck, so posting my issue here, hope somebody could help me!

There is an issue Im experiencing with object deserialisation.
I have a class UserProfileResponse which has internal VO objects in it:
public long hwin;
public long mc;
...
public List<BuddyVO> friends;
public RoomInfoVO roomInfo;

I convert object to SFSObject with SFSObject.newFromObject(this) call.
I have correct serialised SFSObject at output with simple problem - it has roomInfo object serialised in a wrong way.
SFSObject has 2 root HashMaps: $C(has my class name) and $F which is correct.
When I look into the object I could find my RoomInfoVO inside as the latest SFSObject in internal array.
It has V,N values in internal HashMap and V has internal HashMaps with $C and $F values (please see attached screenshot).


Screenshot 2018-02-20 08.51.48.png
(171.81 KiB) Not downloaded yet


But the problem is this code:
UserProfileResponse response = (UserProfileResponse) DefaultSFSDataSerializer.getInstance().sfs2pojo(sfsObject);

It raises an error:
com.smartfoxserver.v2.exceptions.SFSRuntimeException: java.lang.IllegalArgumentException: Can not set <package_name>.RoomInfoVO field <package_name>.UserProfileResponse.roomInfo to java.util.HashMap

So the question: Why it tried to deserialise VO object with HashMap? Is structure of SFSObject wrong after serialisation?
The same version of SFS2x Java libs (latest).

The VO class :

===================
import com.smartfoxserver.v2.protocol.serialization.SerializableSFSType;

public class RoomInfoVO implements SerializableSFSType {

public int rid;
public boolean isMain;
public int crowns;
public boolean isSitting;
public boolean isPrivate;
public String type;

public RoomInfoVO() {}
public RoomInfoVO(int rid, boolean isMain, int crowns, boolean isSitting, boolean isPrivate, String rtype) {
this.rid = rid;
this.isMain = isMain;
this.crowns = crowns;
this.isSitting = isSitting;
this.isPrivate = isPrivate;
this.type = rtype;
}
}
============
User avatar
Lapo
Site Admin
Posts: 20049
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Serialization bug...

Postby Lapo » 20 Feb 2018, 10:06

sadensmol wrote:Hi, All.
I tried to find a bug tracker but with no luck, so posting my issue here, hope somebody could help me!

There is an issue Im experiencing with object deserialisation.
I have a class UserProfileResponse which has internal VO objects in it:


What is a VO object, exactly?

Can you send us a working proof of concept of the problem? You can zip and attach the java sources to your next post.

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 1 guest