SFS2X 2.12 NullPointer

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
arodrigo
Posts: 24
Joined: 22 Jul 2011, 10:03
Location: Spain
Contact:

SFS2X 2.12 NullPointer

Postby arodrigo » 10 Nov 2016, 08:22

Hi,

We are trying to update to the new version. All works as expected except for this null pointer.

Code: Select all

java.lang.NullPointerException
        at com.smartfoxserver.v2.api.response.SFSResponseApi.notifyUserVariablesUpdate(SFSResponseApi.java:492)
        at com.smartfoxserver.v2.api.SFSApi.fireUserVariablesEvent(SFSApi.java:1702)
        at com.smartfoxserver.v2.api.SFSApi.setUserVariables(SFSApi.java:1594)
        at com.smartfoxserver.v2.api.SFSApi.setUserVariables(SFSApi.java:1583)


Debugging we think that the problem is when a user change his variables in a room flagged with USER_VARIABLES_UPDATE_EVENT as false the NullPointer is throw

Code: Select all

Removed


I hope this information helps you, if you need any thing more do not hesitate to ask.

Regards
Last edited by arodrigo on 10 Nov 2016, 09:23, edited 2 times in total.
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFS2X 2.12 NullPointer

Postby Lapo » 10 Nov 2016, 09:02

Hi,
1) if the Room is flagged not to use UserVariables I am not sure why you're using them anyways.
2) even in the above case you still need to pass a valid recipient collection. Passing a null as recipient is simply not supported
3) there is no need to "debug" our code. In fact the EULA accompanying every SFS2X installation clearly prohibits binary decompilation. Failing to do so will immediately stop any support from us.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
arodrigo
Posts: 24
Joined: 22 Jul 2011, 10:03
Location: Spain
Contact:

Re: SFS2X 2.12 NullPointer

Postby arodrigo » 10 Nov 2016, 09:19

1) if the Room is flagged not to use UserVariables I am not sure why you're using them anyways.


We have this flag in some rooms with allot of user who don't need the variables. This variables are used usually and they can be updated asynchronously.

This wasn't a problem in any previous versions.

2) even in the above case you still need to pass a valid recipient collection. Passing a null as recipient is simply not supported


I just do this as always with the user and the vars correctly initialized

Code: Select all

getApi().setUserVariables(user, toUpdate);


If you simply remove the event USER_VARIABLES_UPDATE_EVENT from a room you will receive a null pointer every time a user of this rooms updates its variables.

3) there is no need to "debug" our code. In fact the EULA accompanying every SFS2X installation clearly prohibits binary decompilation. Failing to do so will immediately stop any support from us.

Ups sorry for that the Intellij IDE just do it automatically when an exception is throw on debug mode. We only share it in order to help with the error. We are going to disable the functionality on your libs.

Thanks
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFS2X 2.12 NullPointer

Postby Lapo » 10 Nov 2016, 11:02

Thanks for the clarification.
I was able to reproduce the issue. A couple of comments:

I am not sure why you would use UserVariable in the context of Rooms that never send any such updates. It would be more convenient (and optimized) not to use them at all.

By doing so you're adding an extra layer of wrapping (and creating extra objects) that is never used. It is much easier to attach these server-side-only values directly to the User object via its setProperty/getProperty methods. This will also allow you to use any Java type instead of being restricted to the UserVariable narrow selection of types.

Ups sorry for that the Intellij IDE just do it automatically when an exception is throw on debug mode. We only share it in order to help with the error. We are going to disable the functionality on your libs.

Fair enough. No need to disable features in your IDE.
I just warned you because it's not the first time that folks send us pieces of decompiled code and then asking for help :)

It's okay.
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
arodrigo
Posts: 24
Joined: 22 Jul 2011, 10:03
Location: Spain
Contact:

Re: SFS2X 2.12 NullPointer

Postby arodrigo » 10 Nov 2016, 11:39

Hi Lapo,

Thank you for the explanation you are absolutely right and we don't usually do that.

We have this behavior in a legacy variable used to contain the common data of the user like the points and the coins that any one can see inside the game. This wasn't a problem until when started to have more than 5k of users in the lobby room and the broadcast of changes of variables was causing troubles to us. So the fastest way to solve it was disable the update of variables on the lobby.

We learned a lot about how to use your system correctly this last 5 years and we know that we still have some 'workarounds' in our code that we are not proud but we will fix it.

Could you provide a patch for this bug? We love the new feature of private variables!
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFS2X 2.12 NullPointer

Postby Lapo » 10 Nov 2016, 12:11

Sure, we're in the process of uploading the updated installers.
Meanwhile you can grab the jar file that needs to be replaced under SFS2X/lib/ at this link.

cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
arodrigo
Posts: 24
Joined: 22 Jul 2011, 10:03
Location: Spain
Contact:

Re: SFS2X 2.12 NullPointer

Postby arodrigo » 10 Nov 2016, 12:33

Thank you, it works!
Andy
Posts: 1
Joined: 05 Jul 2013, 11:49

Re: SFS2X 2.12 NullPointer

Postby Andy » 16 Dec 2016, 11:17

We have a similar problem in V 2.12.0

Code: Select all

 java.lang.NullPointerException
        at com.smartfoxserver.v2.api.response.SFSResponseApi.notifyUserVariablesUpdate(SFSResponseApi.java:492)
        at com.smartfoxserver.v2.api.SFSApi.fireUserVariablesEvent(SFSApi.java:1705)
        at com.smartfoxserver.v2.api.SFSApi.setUserVariables(SFSApi.java:1597)



And where or how can i set this flag?
1) if the Room is flagged not to use UserVariables I am not sure why you're using them anyways.
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFS2X 2.12 NullPointer

Postby Lapo » 16 Dec 2016, 15:16

Andy,
please update to 2.12.1, here:
http://www.smartfoxserver.com/download/sfs2x#p=updates

And where or how can i set this flag?

In the RoomSetting.setRoomPermissions(...) object via client side API or equivalent server side API.
Also from the AdminTool > Zone Configurator, when creating a Room.

cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: kapacb and 72 guests