Program: 13154
Project: 13154
Buggy source:
/** 
 * Convert the given incoming request object to repo format. This converts _ref fields to secondId and populates first* fields.
 * @param firstResourcePath The path of the first object in a relationship instance
 * @param object A {@link JsonValue} object from a resource response or incoming request to be converted forstorage in the repo
 * @return A new JsonValue containing the converted object in a format accepted by the repo
 * @see #getFormatResponseNoException()
 */
protected JsonValue convertToRepoObject(final ResourcePath firstResourcePath,final JsonValue object){
  final JsonValue properties=object.get(FIELD_PROPERTIES);
  if (properties != null) {
    properties.remove(FIELD_CONTENT_ID);
    properties.remove(FIELD_CONTENT_REVISION);
  }
  if (isRevereseRelationship) {
    if (firstResourcePath.toString().compareTo(object.get(FIELD_REFERENCE).asString()) < 0) {
      return json(object(field(REPO_FIELD_FIRST_ID,firstResourcePath.toString()),field(REPO_FIELD_FIRST_PROPERTY_NAME,propertyName.toString()),field(REPO_FIELD_SECOND_ID,object.get(FIELD_REFERENCE).asString()),field(REPO_FIELD_SECOND_PROPERTY_NAME,reversePropertyName.toString()),field(REPO_FIELD_PROPERTIES,properties == null ? null : properties.asMap())));
    }
 else {
      return json(object(field(REPO_FIELD_FIRST_ID,object.get(FIELD_REFERENCE).asString()),field(REPO_FIELD_FIRST_PROPERTY_NAME,reversePropertyName.toString()),field(REPO_FIELD_SECOND_ID,firstResourcePath.toString()),field(REPO_FIELD_SECOND_PROPERTY_NAME,propertyName.toString()),field(REPO_FIELD_PROPERTIES,properties == null ? null : properties.asMap())));
    }
  }
 else {
    return json(object(field(REPO_FIELD_FIRST_ID,firstResourcePath.toString()),field(REPO_FIELD_FIRST_PROPERTY_NAME,propertyName.toString()),field(REPO_FIELD_SECOND_ID,object.get(FIELD_REFERENCE).asString()),field(REPO_FIELD_SECOND_PROPERTY_NAME,null),field(REPO_FIELD_PROPERTIES,properties == null ? null : properties.asMap())));
  }
}

Fixed version (ground truth):
/** 
 * Convert the given incoming request object to repo format. This converts _ref fields to secondId and populates first* fields.
 * @param firstResourcePath The path of the first object in a relationship instance
 * @param object A {@link JsonValue} object from a resource response or incoming request to be converted forstorage in the repo
 * @return A new JsonValue containing the converted object in a format accepted by the repo
 * @see #getFormatResponseNoException()
 */
protected JsonValue convertToRepoObject(final ResourcePath firstResourcePath,final JsonValue object){
  final JsonValue properties=object.get(FIELD_PROPERTIES);
  if (properties != null) {
    properties.remove(FIELD_CONTENT_ID);
    properties.remove(FIELD_CONTENT_REVISION);
  }
  if (isReverseRelationship) {
    if (firstResourcePath.toString().compareTo(object.get(FIELD_REFERENCE).asString()) < 0) {
      return json(object(field(REPO_FIELD_FIRST_ID,firstResourcePath.toString()),field(REPO_FIELD_FIRST_PROPERTY_NAME,propertyName.toString()),field(REPO_FIELD_SECOND_ID,object.get(FIELD_REFERENCE).asString()),field(REPO_FIELD_SECOND_PROPERTY_NAME,reversePropertyName.toString()),field(REPO_FIELD_PROPERTIES,properties == null ? null : properties.asMap())));
    }
 else {
      return json(object(field(REPO_FIELD_FIRST_ID,object.get(FIELD_REFERENCE).asString()),field(REPO_FIELD_FIRST_PROPERTY_NAME,reversePropertyName.toString()),field(REPO_FIELD_SECOND_ID,firstResourcePath.toString()),field(REPO_FIELD_SECOND_PROPERTY_NAME,propertyName.toString()),field(REPO_FIELD_PROPERTIES,properties == null ? null : properties.asMap())));
    }
  }
 else {
    return json(object(field(REPO_FIELD_FIRST_ID,firstResourcePath.toString()),field(REPO_FIELD_FIRST_PROPERTY_NAME,propertyName.toString()),field(REPO_FIELD_SECOND_ID,object.get(FIELD_REFERENCE).asString()),field(REPO_FIELD_SECOND_PROPERTY_NAME,null),field(REPO_FIELD_PROPERTIES,properties == null ? null : properties.asMap())));
  }
}