Program: 60792
Project: 60792
Buggy source:
/** 
 * Implementation of the provisioning feature.
 * @param user user to be provisioned
 * @param password cleartext password to be provisioned
 * @param enable wether user must be enabled or not
 * @param propByRes operation to be performed per resource
 * @return list of propagation tasks created
 * @throws PropagationException if anything goes wrong
 */
protected List<PropagationTask> provision(final SyncopeUser user,final String password,final Boolean enable,final PropagationByResource propByRes) throws NotFoundException {
  LOG.debug("String_Node_Str",user,propByRes);
  propByRes.purge();
  LOG.debug("String_Node_Str",propByRes);
  List<PropagationTask> tasks=new ArrayList<PropagationTask>();
  List<ExternalResource> resources=resourceDAO.findAllByPriority();
  List<ExternalResource> resourcesByPriority;
  Map.Entry<String,Set<Attribute>> preparedAttrs;
  PropagationTask task;
  for (  PropagationOperation type : PropagationOperation.values()) {
    resourcesByPriority=new ArrayList<ExternalResource>();
    for (    ExternalResource resource : resources) {
      if (propByRes.get(type).contains(resource.getName())) {
        resourcesByPriority.add(resource);
      }
    }
    for (    ExternalResource resource : resourcesByPriority) {
      preparedAttrs=prepareAttributes(user,password,enable,resource);
      task=new PropagationTask();
      task.setResource(resource);
      task.setResourceOperationType(type);
      task.setPropagationMode(resource.getPropagationMode());
      task.setAccountId(preparedAttrs.getKey());
      task.setOldAccountId(propByRes.getOldAccountId(resource.getName()));
      task.setAttributes(preparedAttrs.getValue());
      tasks.add(task);
      LOG.debug("String_Node_Str",task);
    }
  }
  return tasks;
}

Fixed version (ground truth):
/** 
 * Implementation of the provisioning feature.
 * @param user user to be provisioned
 * @param password cleartext password to be provisioned
 * @param enable wether user must be enabled or not
 * @param propByRes operation to be performed per resource
 * @return list of propagation tasks created
 */
protected List<PropagationTask> provision(final SyncopeUser user,final String password,final Boolean enable,final PropagationByResource propByRes){
  LOG.debug("String_Node_Str",user,propByRes);
  propByRes.purge();
  LOG.debug("String_Node_Str",propByRes);
  List<PropagationTask> tasks=new ArrayList<PropagationTask>();
  for (  PropagationOperation type : PropagationOperation.values()) {
    List<ExternalResource> resourcesByPriority=new ArrayList<ExternalResource>();
    for (    ExternalResource resource : resourceDAO.findAllByPriority()) {
      if (propByRes.get(type).contains(resource.getName())) {
        resourcesByPriority.add(resource);
      }
    }
    for (    ExternalResource resource : resourcesByPriority) {
      Map.Entry<String,Set<Attribute>> preparedAttrs=prepareAttributes(user,password,enable,resource);
      PropagationTask task=new PropagationTask();
      task.setResource(resource);
      task.setSyncopeUser(user);
      task.setResourceOperationType(type);
      task.setPropagationMode(resource.getPropagationMode());
      task.setAccountId(preparedAttrs.getKey());
      task.setOldAccountId(propByRes.getOldAccountId(resource.getName()));
      task.setAttributes(preparedAttrs.getValue());
      tasks.add(task);
      LOG.debug("String_Node_Str",task);
    }
  }
  return tasks;
}