Program: 61368
Project: 61368
Buggy source:
public SchemaMapping getSchemaMapping(Resource resource,SchemaMappingTO mapping) throws SyncopeClientCompositeErrorException {
  SyncopeClientCompositeErrorException compositeErrorException=new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
  SyncopeClientException requiredValuesMissing=new SyncopeClientException(SyncopeClientExceptionType.RequiredValueMissing);
  if (mapping == null) {
    if (log.isErrorEnabled()) {
      log.error("String_Node_Str");
    }
    return null;
  }
  if (mapping.getField() == null) {
    requiredValuesMissing.addElement("String_Node_Str");
  }
  UserSchema userSchema=null;
  if (mapping.getUserSchema() != null) {
    userSchema=schemaDAO.find(mapping.getUserSchema(),UserSchema.class);
  }
  RoleSchema roleSchema=null;
  if (mapping.getRoleSchema() != null) {
    roleSchema=schemaDAO.find(mapping.getUserSchema(),RoleSchema.class);
  }
  if (userSchema == null && roleSchema == null) {
    requiredValuesMissing.addElement("String_Node_Str");
  }
  if (resource == null) {
    requiredValuesMissing.addElement("String_Node_Str");
  }
  if (!requiredValuesMissing.getElements().isEmpty()) {
    compositeErrorException.addException(requiredValuesMissing);
  }
  if (compositeErrorException.hasExceptions()) {
    throw compositeErrorException;
  }
  SchemaMapping schemaMapping=new SchemaMapping();
  BeanUtils.copyProperties(mapping,schemaMapping,ignoreMappingProperties);
  schemaMapping.setResource(resource);
  resource.addMapping(schemaMapping);
  schemaMapping.setUserSchema(userSchema);
  userSchema=schemaMapping.getUserSchema();
  if (userSchema != null)   userSchema.addMapping(schemaMapping);
  schemaMapping.setRoleSchema(roleSchema);
  roleSchema=schemaMapping.getRoleSchema();
  if (roleSchema != null)   roleSchema.addMapping(schemaMapping);
  return schemaMapping;
}

Fixed version (ground truth):
public SchemaMapping getSchemaMapping(Resource resource,SchemaMappingTO mapping) throws SyncopeClientCompositeErrorException {
  SyncopeClientCompositeErrorException compositeErrorException=new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
  SyncopeClientException requiredValuesMissing=new SyncopeClientException(SyncopeClientExceptionType.RequiredValueMissing);
  if (mapping == null) {
    if (log.isErrorEnabled()) {
      log.error("String_Node_Str");
    }
    return null;
  }
  if (mapping.getField() == null) {
    requiredValuesMissing.addElement("String_Node_Str");
  }
  UserSchema userSchema=null;
  if (mapping.getUserSchema() != null) {
    userSchema=schemaDAO.find(mapping.getUserSchema(),UserSchema.class);
  }
  RoleSchema roleSchema=null;
  if (mapping.getRoleSchema() != null) {
    roleSchema=schemaDAO.find(mapping.getRoleSchema(),RoleSchema.class);
  }
  if (userSchema == null && roleSchema == null) {
    requiredValuesMissing.addElement("String_Node_Str");
  }
  if (resource == null) {
    requiredValuesMissing.addElement("String_Node_Str");
  }
  if (!requiredValuesMissing.getElements().isEmpty()) {
    compositeErrorException.addException(requiredValuesMissing);
  }
  if (compositeErrorException.hasExceptions()) {
    throw compositeErrorException;
  }
  SchemaMapping schemaMapping=new SchemaMapping();
  BeanUtils.copyProperties(mapping,schemaMapping,ignoreMappingProperties);
  schemaMapping.setResource(resource);
  resource.addMapping(schemaMapping);
  schemaMapping.setUserSchema(userSchema);
  userSchema=schemaMapping.getUserSchema();
  if (userSchema != null)   userSchema.addMapping(schemaMapping);
  schemaMapping.setRoleSchema(roleSchema);
  roleSchema=schemaMapping.getRoleSchema();
  if (roleSchema != null)   roleSchema.addMapping(schemaMapping);
  return schemaMapping;
}