Program: 174728
Project: 174728
Buggy source:
public Person update(String personId,final Person person){
  validateUpdatePersonData(person);
  boolean isAdmin=isAdminAuthority();
  String currentUserId=AuthenticationUtil.getFullyAuthenticatedUser();
  if (!isAdmin && !currentUserId.equalsIgnoreCase(personId)) {
    throw new PermissionDeniedException();
  }
  final String personIdToUpdate=validatePerson(personId);
  final Map<QName,Serializable> properties=person.toProperties();
  updatePassword(isAdmin,personIdToUpdate,person);
  if (person.isEnabled() != null) {
    if (isAdminAuthority(personIdToUpdate)) {
      throw new PermissionDeniedException("String_Node_Str");
    }
    MutableAuthenticationService mutableAuthenticationService=(MutableAuthenticationService)authenticationService;
    mutableAuthenticationService.setAuthenticationEnabled(personIdToUpdate,person.isEnabled());
  }
  NodeRef personNodeRef=personService.getPerson(personIdToUpdate,false);
  if (person.wasSet(Person.PROP_PERSON_DESCRIPTION)) {
    properties.remove(ContentModel.PROP_PERSONDESC);
    savePersonDescription(person.getDescription(),personNodeRef);
  }
  if (person.getProperties() != null) {
    Map<String,Object> customProps=person.getProperties();
    properties.putAll(nodes.mapToNodeProperties(customProps));
  }
  AuthenticationUtil.runAsSystem(new RunAsWork<Void>(){
    @Override public Void doWork() throws Exception {
      personService.setPersonProperties(personIdToUpdate,properties,false);
      return null;
    }
  }
);
  nodes.updateCustomAspects(personNodeRef,person.getAspectNames(),EXCLUDED_ASPECTS);
  return getPerson(personId);
}

Fixed version (ground truth):
public Person update(String personId,final Person person){
  validateUpdatePersonData(person);
  boolean isAdmin=isAdminAuthority();
  String currentUserId=AuthenticationUtil.getFullyAuthenticatedUser();
  if (!isAdmin && !currentUserId.equalsIgnoreCase(personId)) {
    throw new PermissionDeniedException();
  }
  final String personIdToUpdate=validatePerson(personId);
  final Map<QName,Serializable> properties=person.toProperties();
  updatePassword(isAdmin,personIdToUpdate,person);
  if (person.isEnabled() != null) {
    if (isAdminAuthority(personIdToUpdate)) {
      throw new PermissionDeniedException("String_Node_Str");
    }
    MutableAuthenticationService mutableAuthenticationService=(MutableAuthenticationService)authenticationService;
    mutableAuthenticationService.setAuthenticationEnabled(personIdToUpdate,person.isEnabled());
  }
  NodeRef personNodeRef=personService.getPerson(personIdToUpdate,false);
  if (person.wasSet(Person.PROP_PERSON_DESCRIPTION)) {
    properties.remove(ContentModel.PROP_PERSONDESC);
    savePersonDescription(person.getDescription(),personNodeRef);
  }
  nodes.updateCustomAspects(personNodeRef,person.getAspectNames(),EXCLUDED_ASPECTS);
  if (person.getProperties() != null) {
    Map<String,Object> customProps=person.getProperties();
    properties.putAll(nodes.mapToNodeProperties(customProps));
  }
  AuthenticationUtil.runAsSystem(new RunAsWork<Void>(){
    @Override public Void doWork() throws Exception {
      personService.setPersonProperties(personIdToUpdate,properties,false);
      return null;
    }
  }
);
  return getPerson(personId);
}