The new code assigns an empty userid to memberId (we know this from check in line 708). I think this should be:

String memberId = member.getUserid();
if(StringUtil.isEmpty(memberId)) {
       // use email if no userid is set
       memberId = member.getEmail();
 }