I have a frustrating issue that my app on Google Appengine throws NullPointerException like:
java.lang.NullPointerException
at com.google.appengine.api.users.User.equals(User.java:143)
My code looks like:
if (excludeUser.equals(someEntity.getProperty("user")))
The user property in the entity was another User object previously stored in the datastore. Even if I change the code to something like the following, it does not raise the exception:
if (excludeUser.equals(null))
So I guess it’s some internal logic in User.equals causes the problem, or some other tricky thing when storing the user object into the datastore?
In addition, the logic works well in development environment. The problem only happens on GAE.
I’m using the Google Accounts API, not the Federated login. I tried them both. The same result. Any clue is appreciated, thanks.
Things turn out to be special case from the UserService.getUser(). No idea why it returns a not-null user, with the following content:
Invoking .equals method on such object with other normal User objects results the NullPointerException. Guess this is somekind of the Federated Login weirdo?