spring-attic / spring-social-facebook

Facebook API binding and connect support.
http://projects.spring.io/spring-social-facebook
Apache License 2.0
248 stars 269 forks source link

NullPointerException invocating SocialContextOperations#getAllMutualFriends(java.lang.String) #219

Open troig opened 8 years ago

troig commented 8 years ago

There is a NullPointerException invocating the method getAllMutualFriends of org.springframework.social.facebook.api.SocialContextOperations.

According to the facebook graph API documentation, the attribute ID can be optional.

The ID will be returned for a mutual friend only if the given user has installed your app and granted the user_friends permission.

So, the NPE occurs iterating the response, when the attribute is accessed to retrieve the value. Method org.springframework.social.facebook.api.impl.SocialContextTemplate#getSocialContext, line 135: itemNode.get("id") is null and we get NPE:

for (JsonNode itemNode : dataNode) {
    results.add(new Reference(itemNode.get("id").textValue(), itemNode.get("name").textValue()));
}
``
`