Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.json.JSONObject.NULL not handled properly wherever user authData is concerned #405

Closed
yuzeh opened this issue Feb 23, 2016 · 7 comments

Comments

@yuzeh
Copy link

yuzeh commented Feb 23, 2016

I'm getting this stack trace after logging in (to a self-hosted parse-server) from an anonymous user that's been saved to the cloud:

02-23 17:02:46.743 E/OMG     ( 3180): com.parse.ParseException: java.lang.ClassCastException: org.json.JSONObject$1 cannot be cast to java.util.Map
02-23 17:02:46.743 E/OMG     ( 3180):   at com.parse.ParseTaskUtils$2$1.run(ParseTaskUtils.java:114)
02-23 17:02:46.743 E/OMG     ( 3180):   at android.os.Handler.handleCallback(Handler.java:739)
02-23 17:02:46.743 E/OMG     ( 3180):   at android.os.Handler.dispatchMessage(Handler.java:95)
02-23 17:02:46.743 E/OMG     ( 3180):   at android.os.Looper.loop(Looper.java:148)
02-23 17:02:46.743 E/OMG     ( 3180):   at android.app.ActivityThread.main(ActivityThread.java:5417)
02-23 17:02:46.743 E/OMG     ( 3180):   at java.lang.reflect.Method.invoke(Native Method)
02-23 17:02:46.743 E/OMG     ( 3180):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
02-23 17:02:46.743 E/OMG     ( 3180):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
02-23 17:02:46.743 E/OMG     ( 3180): Caused by: java.lang.ClassCastException: org.json.JSONObject$1 cannot be cast to java.util.Map
02-23 17:02:46.743 E/OMG     ( 3180):   at com.parse.ParseUser.getAuthData(ParseUser.java:340)
02-23 17:02:46.743 E/OMG     ( 3180):   at com.parse.ParseUser.synchronizeAuthDataAsync(ParseUser.java:1245)
02-23 17:02:46.743 E/OMG     ( 3180):   at com.parse.ParseUser.synchronizeAllAuthDataAsync(ParseUser.java:1234)
02-23 17:02:46.743 E/OMG     ( 3180):   at com.parse.CachedCurrentUserController$1$2.then(CachedCurrentUserController.java:71)
02-23 17:02:46.743 E/OMG     ( 3180):   at com.parse.CachedCurrentUserController$1$2.then(CachedCurrentUserController.java:67)

Looks like ParseUser#getAuthData(String) is not handling org.json.JSONObject.NULL (I assume that's what org.json.JSONObject$1 is) properly.

I think the core of the problem is that ParseUser#getAuthData() has return type Map<String, Map<String, String>>. As it turns out, sometimes, you can encounter a JSONObject.NULL as a value in this map. The lack of JSONObject.NULL awareness causes a few other issues too:

This problem goes away when pointing to hosted Parse because the hosted Parse implementation will never send down "authData": {"anonymous": null} as part of the User object -- somehow, the "authData" property is cleaned of null values before being sent down. (Should I file a separate issue against parse-server?)

@grantland
Copy link
Contributor

This sounds like a bug with parse-server, as anonymous authData should never be null.

@yuzeh
Copy link
Author

yuzeh commented Feb 29, 2016

Sounds good. Closing this issue.

@yuzeh yuzeh closed this as completed Feb 29, 2016
@meilers
Copy link

meilers commented Apr 2, 2016

Also having the same issue. The issue was reported on the parse-server forum, and the issue was closed by saying that this bug should be resolved here in the android sdk.

parse-community/parse-server#935

@flovilmart
Copy link
Contributor

@grantland on parse-server side, Android is the only SDK that don't really play well with the leaky null. Maybe there is something to do here :)

@yuzeh
Copy link
Author

yuzeh commented Jul 18, 2016

I am, surprisingly, still dealing with this issue.

@yuzeh yuzeh reopened this Jul 18, 2016
@lxknvlk
Copy link

lxknvlk commented Oct 5, 2016

still occuring, anyone atleast have a workaround?

@natario1
Copy link
Contributor

This is a duplicate of #376 and was fixed in #724

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants