Hello,
We are seeing the following exception sometimes
java.lang.NullPointerException
at com.smartfoxserver.v2.api.SFSApi.sendExtensionResponse(SFSApi.java:1540)
at com.smartfoxserver.v2.extensions.BaseSFSExtension.send(BaseSFSExtension.java:487)
Can someone help us? Do we need to check something before calling send to make sure this doesn't happen.
Regards,
Durga
NPE in Extension Send
-
- Posts: 9
- Joined: 28 Apr 2020, 14:40
Re: NPE in Extension Send
Hi,
can you show the code that seems to trigger this error?
Thanks
can you show the code that seems to trigger this error?
Thanks
-
- Posts: 9
- Joined: 28 Apr 2020, 14:40
Re: NPE in Extension Send
Hi Lapo,
The calling code is pretty basic
Can you share the line which is causing the NPE may be we can check what variable is null
Regards,
Durga.
The calling code is pretty basic
Code: Select all
public void sendToPlayer(
GameOutbox.Cmds cmd, DiffResponse diffResponse, Game originalGame, Player player) {
if (player.isBot()) return;
User user = extension.getApi().getUserById(player.getSfsUserId());
ISFSObject params = diffResponse.toSFSFor(originalGame, player);
log(cmd, params, player.getId());
extension.send(cmd.getCmd(), params, user, false);
}
Can you share the line which is causing the NPE may be we can check what variable is null
Regards,
Durga.
-
- Posts: 9
- Joined: 28 Apr 2020, 14:40
Re: NPE in Extension Send
Hi Lapo,
Any update on this?
Right now we kill the gameroom whenever such exception occurs. Can we know why this is happening and how to recover from it if possible.
Regards,
Durga
Any update on this?
Right now we kill the gameroom whenever such exception occurs. Can we know why this is happening and how to recover from it if possible.
Regards,
Durga
Re: NPE in Extension Send
It may be that the user you're passing is null?
The line number doesn't correspond to anything significant in the current code base. What version of SFS2X are you using?
Thanks
The line number doesn't correspond to anything significant in the current code base. What version of SFS2X are you using?
Thanks
-
- Posts: 9
- Joined: 28 Apr 2020, 14:40
Re: NPE in Extension Send
Hi Lapo, We are using 2.17.0.
Re: NPE in Extension Send
An easy solution would just be to make sure you're not passing null parameters to the send() method.
We'll make sure to add these checks ourselves in the API for the next release. In particular I am referring to the User object.
Cheers
We'll make sure to add these checks ourselves in the API for the next release. In particular I am referring to the User object.
Cheers
Who is online
Users browsing this forum: No registered users and 100 guests