Program: 172053
Project: 172053
Buggy source:
/** 
 * Attempts to find the avatar   {@link NodeRef} for the user in supplied {@link ActivityFeedEntity}. As this is aimed at setting the   {@link NodeRef} from a client-side point of view there are a couple of activity types wherethe user is taken from the activity summary rather than from the poster (e.g. when a user role is changed). A cache should be passed in from which to retrieve previously fetched  {@link NodeRef}s for efficiency.
 * @param activityFeed ActivityFeedEntity
 * @param userIdToAvatarNodeRefCache Map<String, NodeRef>
 * @return NodeRef
 */
protected NodeRef getUserAvatarNodeRef(ActivityFeedEntity activityFeed,Map<String,NodeRef> userIdToAvatarNodeRefCache){
  NodeRef avatarNodeRef=null;
  String postUserId=null;
  if (activityFeed.getActivityType().equals("String_Node_Str")) {
    try {
      JSONObject j=new JSONObject(activityFeed.getActivitySummary());
      postUserId=j.get("String_Node_Str").toString();
    }
 catch (    JSONException e) {
    }
  }
 else {
    postUserId=activityFeed.getPostUserId();
  }
  if (postUserId == null) {
  }
 else   if (userIdToAvatarNodeRefCache.containsKey(postUserId)) {
    avatarNodeRef=userIdToAvatarNodeRefCache.get(postUserId);
  }
 else {
    try {
      NodeRef postPerson=this.personService.getPerson(postUserId);
      List<AssociationRef> assocRefs=this.nodeService.getTargetAssocs(postPerson,ContentModel.ASSOC_AVATAR);
      if (!assocRefs.isEmpty()) {
        avatarNodeRef=assocRefs.get(0).getTargetRef();
      }
    }
 catch (    NoSuchPersonException e) {
      if (logger.isDebugEnabled()) {
        logger.warn("String_Node_Str" + postUserId);
      }
    }
    userIdToAvatarNodeRefCache.put(postUserId,avatarNodeRef);
  }
  return avatarNodeRef;
}

Fixed version (ground truth):
/** 
 * Attempts to find the avatar   {@link NodeRef} for the user in supplied {@link ActivityFeedEntity}. As this is aimed at setting the   {@link NodeRef} from a client-side point of view there are a couple of activity types wherethe user is taken from the activity summary rather than from the poster (e.g. when a user role is changed). A cache should be passed in from which to retrieve previously fetched  {@link NodeRef}s for efficiency.
 * @param activityFeed ActivityFeedEntity
 * @return NodeRef
 */
protected NodeRef getUserAvatarNodeRef(ActivityFeedEntity activityFeed,Map<String,NodeRef> userIdToAvatarNodeRefCache){
  NodeRef avatarNodeRef=null;
  String postUserId=null;
  if (activityFeed.getActivityType().equals("String_Node_Str")) {
    try {
      JSONObject j=new JSONObject(activityFeed.getActivitySummary());
      postUserId=j.get("String_Node_Str").toString();
    }
 catch (    JSONException e) {
    }
  }
 else {
    postUserId=activityFeed.getPostUserId();
  }
  if (postUserId == null) {
  }
 else   if (userIdToAvatarNodeRefCache.containsKey(postUserId)) {
    avatarNodeRef=userIdToAvatarNodeRefCache.get(postUserId);
  }
 else {
    try {
      NodeRef postPerson=this.personService.getPerson(postUserId);
      List<AssociationRef> assocRefs=this.nodeService.getTargetAssocs(postPerson,ContentModel.ASSOC_AVATAR);
      if (!assocRefs.isEmpty()) {
        avatarNodeRef=assocRefs.get(0).getTargetRef();
      }
    }
 catch (    NoSuchPersonException e) {
      if (logger.isDebugEnabled()) {
        logger.warn("String_Node_Str" + postUserId);
      }
    }
    userIdToAvatarNodeRefCache.put(postUserId,avatarNodeRef);
  }
  return avatarNodeRef;
}