Program: 61234
Project: 61234
Buggy source:
/** 
 * Propagate provision/update the resource indicated.
 * @param user to be created.
 * @param resource to be provisioned.
 * @param type to be performed on the specified resource
 * @throws NoSuchBeanDefinitionException if the connector bean doesn'texist.
 * @throws IllegalStateException if propagation fails.
 */
private void propagate(SyncopeUser user,TargetResource resource,Type type) throws NoSuchBeanDefinitionException, IllegalStateException {
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + user + "String_Node_Str"+ user.getAttributes());
  }
  ConnectorInstance connectorInstance=resource.getConnector();
  ConnectorFacade connector=getConnectorFacade(connectorInstance.getId().toString());
  if (connector == null) {
    log.error("String_Node_Str" + connectorInstance.getId().toString() + "String_Node_Str");
    throw new NoSuchBeanDefinitionException("String_Node_Str");
  }
  String password=user.getPassword();
  List<SchemaMapping> mappings=resource.getMappings();
  Set<Attribute> attrs=new HashSet<Attribute>();
  Class castToBeApplied=null;
  String accountId=null;
  String field=null;
  Set objValues=null;
  String schemaName=null;
  SchemaType schemaType=null;
  UserAttribute userAttribute=null;
  SchemaValueType schemaValueType=null;
  List<UserAttributeValue> values=null;
  for (  SchemaMapping mapping : mappings) {
    try {
      field=mapping.getField();
      schemaName=mapping.getSchemaName();
      schemaType=mapping.getSchemaType();
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + schemaName + "String_Node_Str"+ schemaType.getClassName()+ "String_Node_Str");
      }
      AbstractSchema schema=null;
      try {
        schemaType.getSchemaType().asSubclass(AbstractSchema.class);
        schema=schemaDAO.find(schemaName,schemaType.getSchemaType());
      }
 catch (      ClassCastException e) {
        if (log.isDebugEnabled())         log.debug("String_Node_Str" + schemaType.getClassName());
      }
      if (schema != null) {
        schemaValueType=schema.getType();
        userAttribute=user.getAttribute(schemaName);
        values=userAttribute != null ? userAttribute.getAttributeValues() : Collections.EMPTY_LIST;
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + userAttribute + "String_Node_Str"+ schemaName+ "String_Node_Str"+ schemaType.getClassName()+ "String_Node_Str"+ values);
        }
      }
 else {
        schemaValueType=SchemaValueType.String;
        UserAttributeValue userAttributeValue=new UserAttributeValue();
        userAttributeValue.setStringValue(SchemaType.AccountId.equals(schemaType) ? user.getId().toString() : password);
        values=Collections.singletonList(userAttributeValue);
      }
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + "String_Node_Str" + field + "String_Node_Str"+ mapping.isAccountid()+ "String_Node_Str"+ (mapping.isPassword() || schemaType.equals(SchemaType.Password))+ "String_Node_Str"+ mapping.isNullable()+ "String_Node_Str"+ schemaName+ "String_Node_Str"+ schemaType.toString()+ "String_Node_Str"+ schemaValueType.getClassName()+ "String_Node_Str"+ values);
      }
      objValues=new HashSet();
      for (      UserAttributeValue value : values) {
        castToBeApplied=Class.forName(schemaValueType.getClassName());
        if (!FrameworkUtil.isSupportedAttributeType(castToBeApplied)) {
          castToBeApplied=String.class;
          objValues.add(value.getValueAsString());
        }
 else {
          objValues.add(value.getValue());
        }
      }
      if (mapping.isAccountid()) {
        accountId=objValues.iterator().next().toString();
        attrs.add(new Name(accountId));
      }
      if (mapping.isPassword()) {
        attrs.add(AttributeBuilder.buildPassword(objValues.iterator().next().toString().toCharArray()));
      }
      Object objValue=null;
      if (!objValues.isEmpty()) {
        objValue=objValues.iterator().next();
      }
      if (!mapping.isPassword() && !mapping.isAccountid()) {
        if (schema.isMultivalue()) {
          attrs.add(AttributeBuilder.build(field,objValues));
        }
 else {
          attrs.add(AttributeBuilder.build(field,castToBeApplied.cast(objValue)));
        }
      }
    }
 catch (    ClassNotFoundException e) {
      if (log.isWarnEnabled()) {
        log.warn("String_Node_Str" + schemaValueType.getClassName(),e);
      }
    }
catch (    Throwable t) {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + schemaName + "String_Node_Str",t);
      }
    }
  }
  Uid userUid=null;
switch (type) {
case CREATE:
    userUid=connector.create(ObjectClass.ACCOUNT,attrs,null);
  break;
case UPDATE:
userUid=connector.resolveUsername(ObjectClass.ACCOUNT,accountId,null);
if (userUid != null) {
userUid=connector.update(ObjectClass.ACCOUNT,userUid,attrs,null);
}
 else {
userUid=connector.create(ObjectClass.ACCOUNT,attrs,null);
}
break;
case DELETE:
connector.delete(ObjectClass.ACCOUNT,new Uid(accountId),null);
break;
}
if (userUid == null && type != Type.DELETE) {
log.error("String_Node_Str" + resource);
throw new IllegalStateException("String_Node_Str");
}
}

Fixed version (ground truth):
/** 
 * Propagate provision/update the resource indicated.
 * @param user to be created.
 * @param resource to be provisioned.
 * @param type to be performed on the specified resource
 * @throws NoSuchBeanDefinitionException if the connector bean doesn'texist.
 * @throws IllegalStateException if propagation fails.
 */
private void propagate(SyncopeUser user,TargetResource resource,Type type) throws NoSuchBeanDefinitionException, IllegalStateException {
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + user + "String_Node_Str"+ user.getAttributes());
  }
  ConnectorInstance connectorInstance=resource.getConnector();
  ConnectorFacade connector=getConnectorFacade(connectorInstance.getId().toString());
  if (connector == null) {
    log.error("String_Node_Str" + connectorInstance.getId().toString() + "String_Node_Str");
    throw new NoSuchBeanDefinitionException("String_Node_Str");
  }
  String password=user.getPassword();
  List<SchemaMapping> mappings=resource.getMappings();
  Set<Attribute> attrs=new HashSet<Attribute>();
  Class castToBeApplied=null;
  String accountId=null;
  String field=null;
  Set objValues=null;
  String schemaName=null;
  SchemaType schemaType=null;
  UserAttribute userAttribute=null;
  SchemaValueType schemaValueType=null;
  List<UserAttributeValue> values=null;
  for (  SchemaMapping mapping : mappings) {
    try {
      field=mapping.getField();
      schemaName=mapping.getSchemaName();
      schemaType=mapping.getSchemaType();
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + schemaName + "String_Node_Str"+ schemaType.getClassName()+ "String_Node_Str");
      }
      AbstractSchema schema=null;
      try {
        schemaType.getSchemaType().asSubclass(AbstractSchema.class);
        schema=schemaDAO.find(schemaName,schemaType.getSchemaType());
      }
 catch (      ClassCastException e) {
        if (log.isDebugEnabled())         log.debug("String_Node_Str" + schemaType.getClassName());
      }
      if (schema != null) {
        schemaValueType=schema.getType();
        userAttribute=user.getAttribute(schemaName);
        values=userAttribute != null ? userAttribute.getAttributeValues() : Collections.EMPTY_LIST;
        if (log.isDebugEnabled()) {
          log.debug("String_Node_Str" + userAttribute + "String_Node_Str"+ schemaName+ "String_Node_Str"+ schemaType.getClassName()+ "String_Node_Str"+ values);
        }
      }
 else {
        schemaValueType=SchemaValueType.String;
        UserAttributeValue userAttributeValue=new UserAttributeValue();
        userAttributeValue.setStringValue(SchemaType.AccountId.equals(schemaType) ? user.getId().toString() : password);
        values=Collections.singletonList(userAttributeValue);
      }
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + "String_Node_Str" + field + "String_Node_Str"+ mapping.isAccountid()+ "String_Node_Str"+ (mapping.isPassword() || schemaType.equals(SchemaType.Password))+ "String_Node_Str"+ mapping.isNullable()+ "String_Node_Str"+ schemaName+ "String_Node_Str"+ schemaType.toString()+ "String_Node_Str"+ schemaValueType.getClassName()+ "String_Node_Str"+ values);
      }
      objValues=new HashSet();
      for (      UserAttributeValue value : values) {
        castToBeApplied=Class.forName(schemaValueType.getClassName());
        if (!FrameworkUtil.isSupportedAttributeType(castToBeApplied)) {
          castToBeApplied=String.class;
          objValues.add(value.getValueAsString());
        }
 else {
          objValues.add(value.getValue());
        }
      }
      if (mapping.isAccountid()) {
        accountId=objValues.iterator().next().toString();
        attrs.add(new Name(accountId));
      }
      if (mapping.isPassword()) {
        attrs.add(AttributeBuilder.buildPassword(objValues.iterator().next().toString().toCharArray()));
      }
      Object objValue=null;
      if (!objValues.isEmpty()) {
        objValue=objValues.iterator().next();
      }
      if (!mapping.isPassword() && !mapping.isAccountid()) {
        if (schema.isMultivalue()) {
          attrs.add(AttributeBuilder.build(field,objValues));
        }
 else {
          attrs.add(AttributeBuilder.build(field,castToBeApplied.cast(objValue)));
        }
      }
    }
 catch (    ClassNotFoundException e) {
      if (log.isWarnEnabled()) {
        log.warn("String_Node_Str" + schemaValueType.getClassName(),e);
      }
    }
catch (    Throwable t) {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + schemaName + "String_Node_Str",t);
      }
    }
  }
  Uid userUid=null;
switch (type) {
case CREATE:
    userUid=connector.create(ObjectClass.ACCOUNT,attrs,null);
  break;
case UPDATE:
try {
  userUid=connector.resolveUsername(ObjectClass.ACCOUNT,accountId,null);
}
 catch (RuntimeException ignore) {
}
if (userUid != null) {
userUid=connector.update(ObjectClass.ACCOUNT,userUid,attrs,null);
}
 else {
userUid=connector.create(ObjectClass.ACCOUNT,attrs,null);
}
break;
case DELETE:
connector.delete(ObjectClass.ACCOUNT,new Uid(accountId),null);
break;
}
if (userUid == null && type != Type.DELETE) {
log.error("String_Node_Str" + resource);
throw new IllegalStateException("String_Node_Str");
}
}