When I login with invalid Identity, I am suppose to get fault code 3003 or whatever listed in below link, but I get fault code, BackendlessFault{ code: ‘0’, message: ‘java.lang.NullPointerException’ }
Unfortunately I cannot reproduce this issue. Can you please provide more information about this case? For example, what is the users identity in your app? Do you use any null values in the method? Are you calling this method from device or from pure java?
I’ve checked it with android SDK version 2.0.4. Are you using the same?
I pulled latest Android SDK from Github, but still getting the same result.
There’s no problem to login with user with valid id and password.
Do you use any null values in the method?
=> I don’t use null values in the method
Are you calling this method from device or from pure java?
=> I am calling from device (Android ICS)
what is the users identity in your app?
=> below is my code
String dummyId = “test”;
String dummyPass = “pass”;
Backendless.UserService.login(dummyId, dummyPass, new AsyncCallback<BackendlessUser>() {
…
I found way to reproduce.
I have following afterLogin servercode, if I disable servercode, there’s no problem.
If you add below servercode, you can reproduce the problem.
How do I check if user is logged in or not within “afterlogin”?
Should I check for result!=null && result.getResult!=null?
public void afterLogin( RunnerContext context, String login, String password, ExecutionResult<HashMap> result ) throws Exception
{
HashMap map = result.getResult();
map.put("loginTime", new Date());
Thanks for clarifying. Simply the presence of a no-op afterLogin function changes the response. I will open an internal ticket to investigate the problem.
I don’t know why but, now leaving handler empty does respond with proper fault code.
I always clean and build though - Yesterday I clean/build/redeployed 3 times with empty handler.
Regarding servercode, sometimes previously deployed servercode is executed, I’ve experienced at least 2 times, I don’t know if this is code runner deploy issue.
HashMap map = result.getResult();
map.put("loginTime", new Date());
This is where you were getting NullPointerException: you receive an error, thus result.getResult() returns null, and then you try to put a value to a null map.
Just add a check whether result.getResult() is not null.