Program: 61051
Project: 61051
Buggy source:
private void setupRoleMod(final RoleTO roleTO){
  roleMod=new RoleMod();
  LOG.error("String_Node_Str",roleTO);
  LOG.error("String_Node_Str",oldRole);
  if (!oldRole.getName().equals(roleTO.getName())) {
    roleMod.setName(roleTO.getName());
  }
  final List<AttributeTO> newDerivedAttributes=roleTO.getDerivedAttributes();
  final List<AttributeTO> oldDerivedAttributes=oldRole.getDerivedAttributes();
  for (  AttributeTO oldDerivedAttribute : oldDerivedAttributes) {
    roleMod.addDerivedAttributeToBeRemoved(oldDerivedAttribute.getSchema());
  }
  for (  AttributeTO newDerivedAttribute : newDerivedAttributes) {
    roleMod.addDerivedAttributeToBeAdded(newDerivedAttribute.getSchema());
  }
  final List<AttributeTO> newVirtualAttributes=roleTO.getVirtualAttributes();
  final List<AttributeTO> oldVirtualAttributes=oldRole.getVirtualAttributes();
  for (  AttributeTO oldVirtualAttribute : oldVirtualAttributes) {
    roleMod.addVirtualAttributeToBeRemoved(oldVirtualAttribute.getSchema());
  }
  for (  AttributeTO newVirtualAttribute : newVirtualAttributes) {
    roleMod.addVirtualAttributeToBeAdded(newVirtualAttribute.getSchema());
  }
  LOG.error("String_Node_Str",roleMod);
  for (  AttributeTO attributeTO : roleTO.getAttributes()) {
    searchAndUpdateAttribute(attributeTO);
  }
  for (  String resource : roleTO.getResources()) {
    searchAndAddResource(resource);
  }
  for (  String resource : oldRole.getResources()) {
    searchAndDropResource(resource,roleTO);
  }
  if (!oldRole.getEntitlements().equals(roleTO.getEntitlements())) {
    roleMod.setEntitlements(roleTO.getEntitlements());
  }
  if (roleMod != null) {
    roleMod.setId(oldRole.getId());
    if (!oldRole.getEntitlements().equals(roleTO.getEntitlements())) {
      LOG.debug("String_Node_Str",oldRole.getEntitlements());
      LOG.debug("String_Node_Str",roleTO.getEntitlements());
      roleMod.setEntitlements(roleTO.getEntitlements());
    }
 else {
      roleMod.setEntitlements(oldRole.getEntitlements());
    }
  }
}

Fixed version (ground truth):
private void setupRoleMod(final RoleTO roleTO){
  roleMod=new RoleMod();
  if (!oldRole.getName().equals(roleTO.getName())) {
    roleMod.setName(roleTO.getName());
  }
  final List<AttributeTO> newDerivedAttributes=roleTO.getDerivedAttributes();
  final List<AttributeTO> oldDerivedAttributes=oldRole.getDerivedAttributes();
  for (  AttributeTO oldDerivedAttribute : oldDerivedAttributes) {
    roleMod.addDerivedAttributeToBeRemoved(oldDerivedAttribute.getSchema());
  }
  for (  AttributeTO newDerivedAttribute : newDerivedAttributes) {
    roleMod.addDerivedAttributeToBeAdded(newDerivedAttribute.getSchema());
  }
  final List<AttributeTO> newVirtualAttributes=roleTO.getVirtualAttributes();
  final List<AttributeTO> oldVirtualAttributes=oldRole.getVirtualAttributes();
  for (  AttributeTO oldVirtualAttribute : oldVirtualAttributes) {
    roleMod.addVirtualAttributeToBeRemoved(oldVirtualAttribute.getSchema());
  }
  for (  AttributeTO newVirtualAttribute : newVirtualAttributes) {
    roleMod.addVirtualAttributeToBeAdded(newVirtualAttribute.getSchema());
  }
  for (  AttributeTO attributeTO : roleTO.getAttributes()) {
    searchAndUpdateAttribute(attributeTO);
  }
  for (  String resource : roleTO.getResources()) {
    searchAndAddResource(resource);
  }
  for (  String resource : oldRole.getResources()) {
    searchAndDropResource(resource,roleTO);
  }
  if (!oldRole.getEntitlements().equals(roleTO.getEntitlements())) {
    roleMod.setEntitlements(roleTO.getEntitlements());
  }
  if (roleMod != null) {
    roleMod.setId(oldRole.getId());
    if (!oldRole.getEntitlements().equals(roleTO.getEntitlements())) {
      LOG.debug("String_Node_Str",oldRole.getEntitlements());
      LOG.debug("String_Node_Str",roleTO.getEntitlements());
      roleMod.setEntitlements(roleTO.getEntitlements());
    }
 else {
      roleMod.setEntitlements(oldRole.getEntitlements());
    }
  }
}