Program: 60968
Project: 60968
Buggy source:
@Override protected String doExecute() throws JobExecutionException {
  if (!(task instanceof SyncTask)) {
    throw new JobExecutionException("String_Node_Str" + taskId + "String_Node_Str");
  }
  final SyncTask syncTask=(SyncTask)this.task;
  ConnectorFacadeProxy connector;
  try {
    connector=connInstanceLoader.getConnector(syncTask.getResource());
  }
 catch (  BeansException e) {
    final String msg=String.format("String_Node_Str" + "String_Node_Str",syncTask.getResource(),syncTask.getResource().getConnector());
    throw new JobExecutionException(msg,e);
  }
  List<SyncDelta> deltas;
  try {
    deltas=connector.sync(syncTask.getResource().getConnector().getSyncToken());
  }
 catch (  Throwable t) {
    throw new JobExecutionException("String_Node_Str",t);
  }
  SchemaMapping accountIdMap=syncTask.getResource().getAccountIdMapping();
  if (accountIdMap == null) {
    throw new JobExecutionException("String_Node_Str" + syncTask.getResource());
  }
  Set<String> defaultResources=new HashSet<String>(syncTask.getDefaultResources().size());
  for (  ExternalResource resource : syncTask.getDefaultResources()) {
    defaultResources.add(resource.getName());
  }
  Set<Long> defaultRoles=new HashSet<Long>(syncTask.getDefaultRoles().size());
  for (  SyncopeRole role : syncTask.getDefaultRoles()) {
    defaultRoles.add(role.getId());
  }
  int createdCounter=0;
  int updatedCounter=0;
  int deletedCounter=0;
  int failCreatedCounter=0;
  int failUpdatedCounter=0;
  int failDeletedCounter=0;
  List<SyncopeUser> users;
  List<Long> userIds;
  SyncopeUser userToUpdate;
  for (  SyncDelta delta : deltas) {
    users=findExistingUsers(accountIdMap.getIntAttrName(),delta.getUid().getUidValue(),delta.getPreviousUid() == null ? null : delta.getPreviousUid().getUidValue());
switch (delta.getDeltaType()) {
case CREATE_OR_UPDATE:
      if (users.isEmpty()) {
        try {
          UserTO userTO=getUserTO(delta.getObject(),syncTask.getResource().getMappings(),defaultRoles,defaultResources);
          Map.Entry<Long,Boolean> created=wfAdapter.create(userTO);
          createdCounter++;
          List<PropagationTask> tasks=propagationManager.getCreateTaskIds(created.getKey(),userTO.getPassword(),null,created.getValue());
          propagationManager.execute(tasks);
        }
 catch (        PropagationException e) {
          LOG.error("String_Node_Str" + delta.getUid().getUidValue(),e);
        }
catch (        Throwable t) {
          failCreatedCounter++;
          LOG.error("String_Node_Str" + delta.getUid().getUidValue(),t);
        }
      }
 else       if (users.size() == 1) {
        if (syncTask.isUpdateIdentities()) {
          userToUpdate=users.iterator().next();
          try {
            UserMod userMod=getUserMod(userToUpdate.getId(),delta.getObject(),syncTask.getResource().getMappings(),defaultRoles,defaultResources);
            Map.Entry<Long,PropagationByResource> updated=wfAdapter.update(userMod);
            updatedCounter++;
            List<PropagationTask> tasks=propagationManager.getUpdateTaskIds(updated.getKey(),userMod.getPassword(),null,null,null,updated.getValue());
            propagationManager.execute(tasks);
          }
 catch (          PropagationException e) {
            LOG.error("String_Node_Str" + delta.getUid().getUidValue(),e);
          }
catch (          Throwable t) {
            failUpdatedCounter++;
            LOG.error("String_Node_Str" + delta.getUid().getUidValue(),t);
          }
        }
      }
 else {
        LOG.error("String_Node_Str",users);
      }
    break;
case DELETE:
  LOG.debug("String_Node_Str",users);
userIds=new ArrayList<Long>(users.size());
for (SyncopeUser user : users) {
userIds.add(user.getId());
}
for (Long userId : userIds) {
try {
List<PropagationTask> tasks=propagationManager.getDeleteTaskIds(userId);
propagationManager.execute(tasks);
}
 catch (Exception e) {
LOG.error("String_Node_Str" + userId,e);
}
try {
wfAdapter.delete(userId);
deletedCounter++;
}
 catch (Throwable t) {
failDeletedCounter++;
LOG.error("String_Node_Str" + userId,t);
}
}
break;
default :
}
}
StringBuilder result=new StringBuilder();
result.append("String_Node_Str").append(createdCounter).append('/').append(failCreatedCounter).append(' ').append("String_Node_Str").append(updatedCounter).append('/').append(failUpdatedCounter).append(' ').append("String_Node_Str").append(deletedCounter).append('/').append(failDeletedCounter);
LOG.debug("String_Node_Str",result);
try {
syncTask.getResource().getConnector().setSyncToken(connector.getLatestSyncToken());
connInstanceDAO.save(syncTask.getResource().getConnector());
}
 catch (Throwable t) {
throw new JobExecutionException("String_Node_Str",t);
}
return result.toString();
}

Fixed version (ground truth):
@Override protected String doExecute() throws JobExecutionException {
  if (!(task instanceof SyncTask)) {
    throw new JobExecutionException("String_Node_Str" + taskId + "String_Node_Str");
  }
  final SyncTask syncTask=(SyncTask)this.task;
  ConnectorFacadeProxy connector;
  try {
    connector=connInstanceLoader.getConnector(syncTask.getResource());
  }
 catch (  BeansException e) {
    final String msg=String.format("String_Node_Str" + "String_Node_Str",syncTask.getResource(),syncTask.getResource().getConnector());
    throw new JobExecutionException(msg,e);
  }
  List<SyncDelta> deltas;
  try {
    deltas=connector.sync(syncTask.getResource().getConnector().getSyncToken());
  }
 catch (  Throwable t) {
    throw new JobExecutionException("String_Node_Str",t);
  }
  SchemaMapping accountIdMap=syncTask.getResource().getAccountIdMapping();
  if (accountIdMap == null) {
    throw new JobExecutionException("String_Node_Str" + syncTask.getResource());
  }
  Set<String> defaultResources=new HashSet<String>(syncTask.getDefaultResources().size());
  for (  ExternalResource resource : syncTask.getDefaultResources()) {
    defaultResources.add(resource.getName());
  }
  Set<Long> defaultRoles=new HashSet<Long>(syncTask.getDefaultRoles().size());
  for (  SyncopeRole role : syncTask.getDefaultRoles()) {
    defaultRoles.add(role.getId());
  }
  int createdCounter=0;
  int updatedCounter=0;
  int deletedCounter=0;
  int failCreatedCounter=0;
  int failUpdatedCounter=0;
  int failDeletedCounter=0;
  List<SyncopeUser> users;
  List<Long> userIds;
  SyncopeUser userToUpdate;
  for (  SyncDelta delta : deltas) {
    users=findExistingUsers(accountIdMap.getIntAttrName(),delta.getUid().getUidValue(),delta.getPreviousUid() == null ? null : delta.getPreviousUid().getUidValue());
switch (delta.getDeltaType()) {
case CREATE_OR_UPDATE:
      if (users.isEmpty()) {
        try {
          UserTO userTO=getUserTO(delta.getObject(),syncTask.getResource().getMappings(),defaultRoles,defaultResources);
          Map.Entry<Long,Boolean> created=wfAdapter.create(userTO);
          createdCounter++;
          List<PropagationTask> tasks=propagationManager.getCreateTaskIds(created.getKey(),userTO.getPassword(),null,created.getValue(),syncTask.getResource().getName());
          propagationManager.execute(tasks);
        }
 catch (        PropagationException e) {
          LOG.error("String_Node_Str" + delta.getUid().getUidValue(),e);
        }
catch (        Throwable t) {
          failCreatedCounter++;
          LOG.error("String_Node_Str" + delta.getUid().getUidValue(),t);
        }
      }
 else       if (users.size() == 1) {
        if (syncTask.isUpdateIdentities()) {
          userToUpdate=users.iterator().next();
          try {
            UserMod userMod=getUserMod(userToUpdate.getId(),delta.getObject(),syncTask.getResource().getMappings(),defaultRoles,defaultResources);
            Map.Entry<Long,PropagationByResource> updated=wfAdapter.update(userMod);
            updatedCounter++;
            List<PropagationTask> tasks=propagationManager.getUpdateTaskIds(updated.getKey(),userMod.getPassword(),null,null,null,updated.getValue(),syncTask.getResource().getName());
            propagationManager.execute(tasks);
          }
 catch (          PropagationException e) {
            LOG.error("String_Node_Str" + delta.getUid().getUidValue(),e);
          }
catch (          Throwable t) {
            failUpdatedCounter++;
            LOG.error("String_Node_Str" + delta.getUid().getUidValue(),t);
          }
        }
      }
 else {
        LOG.error("String_Node_Str",users);
      }
    break;
case DELETE:
  LOG.debug("String_Node_Str",users);
userIds=new ArrayList<Long>(users.size());
for (SyncopeUser user : users) {
userIds.add(user.getId());
}
for (Long userId : userIds) {
try {
List<PropagationTask> tasks=propagationManager.getDeleteTaskIds(userId,syncTask.getResource().getName());
propagationManager.execute(tasks);
}
 catch (Exception e) {
LOG.error("String_Node_Str" + userId,e);
}
try {
wfAdapter.delete(userId);
deletedCounter++;
}
 catch (Throwable t) {
failDeletedCounter++;
LOG.error("String_Node_Str" + userId,t);
}
}
break;
default :
}
}
StringBuilder result=new StringBuilder();
result.append("String_Node_Str").append(createdCounter).append('/').append(failCreatedCounter).append(' ').append("String_Node_Str").append(updatedCounter).append('/').append(failUpdatedCounter).append(' ').append("String_Node_Str").append(deletedCounter).append('/').append(failDeletedCounter);
LOG.debug("String_Node_Str",result);
try {
syncTask.getResource().getConnector().setSyncToken(connector.getLatestSyncToken());
connInstanceDAO.save(syncTask.getResource().getConnector());
}
 catch (Throwable t) {
throw new JobExecutionException("String_Node_Str",t);
}
return result.toString();
}