'Value for map.compute is always null

I'm trying to use .compute() on my map but the else statement is never fired.

public void onInviteUser(int adapterPosition) {
        Log.d(TAG, "onInviteUser: " + adapterPosition); //not null
        mapInvitedFriends.compute(adapterPosition, (k, v) -> {
            Log.d(TAG, "onInviteUser: " + adapterPosition); 
            if (v == null) {
                Log.d(TAG, "onInviteUser: " + v);
                mapInvitedFriends.put(adapterPosition, listFriends.get(adapterPosition));
                Log.d(TAG, "onInviteUser: " + listFriends.get(adapterPosition).toString());
                return v;
            } else {
                //Never gets fired
                Log.d(TAG, "onInviteUser: " + v);
                mapInvitedFriends.remove(adapterPosition);
                return v;
            }
        });
}

I've logged everthing, but I can't figure out why the value v is always null.

Edit:

The types for the map is:

private final Map<Integer, Friend> mapInvitedFriends = new HashMap<>();
private final List<Friend> listFriends = new ArrayList<>();


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source