redouane59 / twittered

Twitter API client for Java developers
Apache License 2.0
235 stars 64 forks source link

v2 getFollowers returns data = null when recursive call is set to false for user with no followers. #382

Closed john-baringhaus closed 2 years ago

john-baringhaus commented 2 years ago

I'm not sure if this is intended behavior, but when I use getFollowers("userId", AdditionalParameters.builder().recursiveCall(false).build() ) the UserList returned contains null for that data field.

If I exclude the AdditionalParameters the data field is an empty ArrayList.

The user I'm specifying doesn't have any followers.

redouane59 commented 2 years ago

Hey, can you share with me the userId that you are using please ?

john-baringhaus commented 2 years ago

1533931140729516034

john-baringhaus commented 2 years ago

I think part of the problem is in how twitter response to a user with no followers.

Since the JSON from Twitter for this user is "{"meta":{"result_count":0}}" OBJECT_MAPPER leaves the ArrayList null.

redouane59 commented 2 years ago

Yes, maybe a solution to have this more clean is to have a empty Array by default in the field data.

Like

  private List<UserData> data = new ArrayList<>();

here

Then we will always have an empty list in both methods. What do you think ?

john-baringhaus commented 2 years ago

That's what I ended up doing. I also removed the initializer in the builder in getUsersRecursively since it became redundant.