Serialization bug...

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

Moderators: Lapo, Bax

sadensmol
Posts: 7
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: 20113
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
sadensmol
Posts: 7
Joined: 20 Feb 2018, 05:25

Re: Serialization bug...

Postby sadensmol » 28 Jun 2018, 14:12

Hi, Lapo.
Im not sure I have time to create you an examples.
The problem is quite simple where you have a POJO which contains 2 internal POJOs and serialise outer POJO to SFS object and then try to serialise it back it hangs. Every time.
First POJO gets deserialised and 2nd breaks the whole application.
I could say that out SFSObject looks good - all fields are in place.
When you comment out one of the internal POJOs it works well. so POJO ->SFSObject -> POJO works well.

When you have 2 internal POJOs (see my first post) it hangs during the deserialising 2nd pojo.
What i see in debugger -
https://www.dropbox.com/s/isfd7m397wq46 ... 3.png?dl=0

Please let me know if you able to fix this. We have lots of your licenses and use your server for a long long time.
If possible please share some email I could contact with your developer or share a video with a problem (not for forum). thanks.
User avatar
Lapo
Site Admin
Posts: 20113
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Serialization bug...

Postby Lapo » 29 Jun 2018, 08:09

Hi,
to be able to fix this we need to reproduce it. When you say a "POJO which contains 2 internal POJOs" it could be anything. We have a test suite doing exactly this (nested Java objects) that works perfectly fine.

Please send us the object structure you're using so that we can test it and reproduce the issue.
You can send the zipped classes (only the serializable objects, not your entire project of course) to our support@... mail box with a reference to this thread.

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