Serialization bug...
Posted: 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).
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;
}
}
============
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).
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;
}
}
============