Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Complete
-
1.1.0.RELEASE
-
None
-
using spring social FB library 1.1.0-release, snapshot from April 2, 2012
Description
Using FQL to access the stream table, many of the json elements return are null at times.
if you call FqlResult.getList(String fieldName, FqlResultMapper<T> mapper) with a field that exists, but is null, a null pointer exception will be thrown:
java.lang.NullPointerException
at org.springframework.social.facebook.api.FqlResult.getList(FqlResult.java:163)
at com.inqmobile.inqcloud.domain.facebook.FbStreamItemMapper.mapObject(FbStreamItemMapper.java:58)
at com.inqmobile.inqcloud.domain.facebook.FbStreamItemMapper.mapObject(FbStreamItemMapper.java:1)
at org.springframework.social.facebook.api.impl.FqlTemplate.query(FqlTemplate.java:48)
which corresponds to
List<Map<String, Object>> arrayItems = (List<Map<String, Object>>) resultMap.get(fieldName);
for (Map<String, Object> arrayItem : arrayItems) { ~~~~~ this line ~~~~~
response.add(mapper.mapObject(new FqlResult(arrayItem)));
}
Expected behavior is to return null if the json value is null.
https://graph.facebook.com/fql?q=SELECT post_id, message, action_links FROM stream WHERE source_id=100002487294420 LIMIT 1
returns
{ "data": [
]
}
—
note that other getXYZ calls throw null pointer or number format exceptions if the value is null, as opposed to not present.
Facebook fql will sometimes return null for values documented as type 'int'
I would like the ability to call getLong without first checking if the original result is null.
Might also want to expose resultMap.containsKey() on the FqlResult class too.