Program: 81984
Project: 81984
Buggy source:
/** 
 * Find the entity in the server data store, apply its setters, capture any violations, and return a  {@link com.google.gwt.requestfactory.server.JsonRequestProcessor.EntityData EntityData} encapsulating the results.<p> If a <i>set</i> method has side-effects, we will not notice.
 */
public EntityData getEntityDataForRecordWithSettersApplied(EntityKey entityKey,JSONObject recordObject,WriteOperation writeOperation) throws JSONException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, InstantiationException {
  Class<?> entityType=getEntityTypeForProxyType(entityKey.proxyType);
  Map<String,Property<?>> propertiesInProxy=getPropertiesFromRecordProxyType(entityKey.proxyType);
  Map<String,Class<?>> propertiesInDomain=updatePropertyTypes(propertiesInProxy,entityType);
  validateKeys(recordObject,propertiesInDomain.keySet());
  Object entityInstance=getEntityInstance(writeOperation,entityType,entityKey.decodedId(propertiesInProxy.get(Constants.ENTITY_ID_PROPERTY).getType()),propertiesInProxy.get(Constants.ENTITY_ID_PROPERTY).getType());
  cachedEntityLookup.put(entityKey,entityInstance);
  Iterator<?> keys=recordObject.keys();
  while (keys.hasNext()) {
    String key=(String)keys.next();
    Class<?> propertyType=propertiesInDomain.get(key);
    Property<?> dtoProperty=propertiesInProxy.get(key);
    if (writeOperation == WriteOperation.PERSIST && (Constants.ENTITY_ID_PROPERTY.equals(key))) {
      String id=generateIdForCreate(key);
      if (id != null) {
        entityType.getMethod(getMethodNameFromPropertyName(key,"String_Node_Str"),propertyType).invoke(entityInstance,id);
      }
    }
 else {
      Object propertyValue=null;
      if (recordObject.isNull(key)) {
      }
 else       if (dtoProperty instanceof CollectionProperty<?,?>) {
        Class<?> cType=dtoProperty.getType();
        Class<?> leafType=((CollectionProperty<?,?>)dtoProperty).getLeafType();
        Collection<Object> col=createCollection(cType);
        if (col != null) {
          JSONArray array=recordObject.getJSONArray(key);
          for (int i=0; i < array.length(); i++) {
            if (EntityProxy.class.isAssignableFrom(leafType)) {
              propertyValue=getPropertyValueFromRequestCached(array,i,dtoProperty);
            }
 else {
              propertyValue=decodeParameterValue(leafType,array.getString(i));
            }
            col.add(propertyValue);
          }
          propertyValue=col;
        }
      }
 else {
        propertyValue=getPropertyValueFromRequestCached(recordObject,propertiesInProxy,key,dtoProperty);
      }
      entityType.getMethod(getMethodNameFromPropertyName(key,"String_Node_Str"),propertiesInDomain.get(key)).invoke(entityInstance,propertyValue);
    }
  }
  Set<ConstraintViolation<Object>> violations=Collections.emptySet();
  Validator validator=null;
  try {
    ValidatorFactory validatorFactory=Validation.buildDefaultValidatorFactory();
    validator=validatorFactory.getValidator();
  }
 catch (  Exception e) {
    log.info(String.format("String_Node_Str" + "String_Node_Str",e.getClass().getName(),e.getLocalizedMessage()));
  }
  if (validator != null) {
    violations=validator.validate(entityInstance);
  }
  return new EntityData(entityInstance,(violations.isEmpty() ? null : getViolationsAsJson(violations)));
}

Fixed version (ground truth):
/** 
 * Find the entity in the server data store, apply its setters, capture any violations, and return a  {@link com.google.gwt.requestfactory.server.JsonRequestProcessor.EntityData EntityData} encapsulating the results.<p> If a <i>set</i> method has side-effects, we will not notice.
 */
public EntityData getEntityDataForRecordWithSettersApplied(EntityKey entityKey,JSONObject recordObject,WriteOperation writeOperation) throws JSONException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, InstantiationException {
  Class<?> entityType=getEntityTypeForProxyType(entityKey.proxyType);
  Map<String,Property<?>> propertiesInProxy=getPropertiesFromRecordProxyType(entityKey.proxyType);
  Map<String,Class<?>> propertiesInDomain=updatePropertyTypes(propertiesInProxy,entityType);
  validateKeys(recordObject,propertiesInDomain.keySet());
  Class<?> idType=getIdMethodForEntity(entityType).getReturnType();
  Object entityInstance=getEntityInstance(writeOperation,entityType,entityKey.decodedId(idType),idType);
  cachedEntityLookup.put(entityKey,entityInstance);
  Iterator<?> keys=recordObject.keys();
  while (keys.hasNext()) {
    String key=(String)keys.next();
    Property<?> dtoProperty=propertiesInProxy.get(key);
    if (writeOperation == WriteOperation.PERSIST && (Constants.ENTITY_ID_PROPERTY.equals(key))) {
      continue;
    }
 else {
      Object propertyValue=null;
      if (recordObject.isNull(key)) {
      }
 else       if (dtoProperty instanceof CollectionProperty<?,?>) {
        Class<?> cType=dtoProperty.getType();
        Class<?> leafType=((CollectionProperty<?,?>)dtoProperty).getLeafType();
        Collection<Object> col=createCollection(cType);
        if (col != null) {
          JSONArray array=recordObject.getJSONArray(key);
          for (int i=0; i < array.length(); i++) {
            if (EntityProxy.class.isAssignableFrom(leafType)) {
              propertyValue=getPropertyValueFromRequestCached(array,i,dtoProperty);
            }
 else {
              propertyValue=decodeParameterValue(leafType,array.getString(i));
            }
            col.add(propertyValue);
          }
          propertyValue=col;
        }
      }
 else {
        propertyValue=getPropertyValueFromRequestCached(recordObject,propertiesInProxy,key,dtoProperty);
      }
      entityType.getMethod(getMethodNameFromPropertyName(key,"String_Node_Str"),propertiesInDomain.get(key)).invoke(entityInstance,propertyValue);
    }
  }
  Set<ConstraintViolation<Object>> violations=Collections.emptySet();
  Validator validator=null;
  try {
    ValidatorFactory validatorFactory=Validation.buildDefaultValidatorFactory();
    validator=validatorFactory.getValidator();
  }
 catch (  Exception e) {
    log.info(String.format("String_Node_Str" + "String_Node_Str",e.getClass().getName(),e.getLocalizedMessage()));
  }
  if (validator != null) {
    violations=validator.validate(entityInstance);
  }
  return new EntityData(entityInstance,(violations.isEmpty() ? null : getViolationsAsJson(violations)));
}