Program: 29904
Project: 29904
Buggy source:
/** 
 * Perform an aggregate query for the given table and query parameters. The table must belong to this session's application. Query parameters are specific to the storage service managing the application. Common parameters are: <table> <tr><td>Name</td><td>Value</td><td>Description</td></tr> <tr><td>m</td> <td>metric list</td> <td>Required. Comma-separated list of metric expression(s) to compute.</td> </tr> <tr><td>q</td> <td>query expression</td> <td>Optional. Query expression that selects objects in the table. Default is "*", which selects all objects.</td> </tr> <tr><td>f</td> <td>grouping parameter</td> <td>Optional. Comma-separated list of grouping field expressions. When present, creates a grouped aggregate query instead of a global aggregate query.</td> </tr> <tr><td>pair</td> <td>pair list</td> <td>Optiona. A comma-separated of pair of link paths that define a special <i>dual role</i> query. See OLAP documentation about the operation of this special query type.</td> </tr> <tr><td>shards</td> <td>shard list</td> <td>Comma-separated list of shards to query. Either this or the "range" parameter must be provided, but not both.</td> </tr> <tr><td>range</td> <td><i>shard-from</i>[,<i>shard-to</i>]</td> <td>Defines a range of shards to query beginning with shards whose name is greater than or equal to the <i>shard-from</i> name. If a <i>shard-to</i> name is given, shard names must also be less than or equal to that name. Either this or the "shards" parameter must be provided, but not both.</td> </tr> <tr><td>xshards</td> <td>shard list</td> <td>Comma-separated list of shards that define the search scope of xlinks. This parameter is only meaningful when the aggregate query uses xlinks. Either this or the "xrange" parameter can be provided, but not both. If neither "xshards" nor "xrange" is specified, the search scope of xlinks is defined by the "shards" or "range" parameter.</td> </tr> <tr><td>xrange</td> <td><i>shard-from</i>[,<i>shard-to</i>]</td> <td>Defines a range of shards to query for xlink values beginning with shards whose name is greater than or equal to the <i>shard-from</i> name. If a <i>shard-to</i> name is given, shard names must also be less than or equal to that name. Either this or the "xshards" parameter can be provided, but not both. If neither "xshards" nor "xrange" is specified, the search scope of xlinks is defined by the "shards" or "range" parameter.</td> </tr> </table> Results are turned in the given   {@link AggregateResult} object. An exception is thrownif a parameter is invalid or a database error occurs.
 * @param tableName Name of table to query.
 * @param params    Names and values of aggregate query parameters. 
 * @return          {@link AggregateResult} containing results.
 */
@Override public AggregateResult aggregateQuery(String tableName,Map<String,String> params){
  Utils.require(!Utils.isEmpty(tableName),"String_Node_Str");
  Utils.require(params != null && params.size() > 0,"String_Node_Str");
  TableDefinition tableDef=m_appDef.getTableDef(tableName);
  Utils.require(tableDef != null,"String_Node_Str",m_appDef.getAppName(),tableName);
  StringBuilder uri=new StringBuilder();
  uri.append(uriRoot());
  uri.append(Utils.urlEncode(m_appDef.getAppName()));
  uri.append("String_Node_Str");
  uri.append(Utils.urlEncode(tableDef.getTableName()));
  uri.append("String_Node_Str");
  Utils.require(params.containsKey("String_Node_Str"),"String_Node_Str");
  uri.append("String_Node_Str");
  uri.append(Utils.urlEncode(params.get("String_Node_Str")));
  for (  String name : params.keySet()) {
    String value=params.get(name);
switch (name) {
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
      uri.append("String_Node_Str");
    uri.append(name);
  uri.append("String_Node_Str");
uri.append(Utils.urlEncode(value));
break;
case "String_Node_Str":
break;
default :
Utils.require(false,"String_Node_Str",name);
}
}
try {
RESTResponse response=m_restClient.sendRequest(HttpMethod.GET,uri.toString());
m_logger.debug("String_Node_Str",response.toString());
AggregateResult result=new AggregateResult();
if (response.getCode() != HttpCode.OK) {
result.setErrorMessage(response.getBody());
}
 else {
result.parse(UNode.parse(response.getBody(),response.getContentType()));
}
return result;
}
 catch (Exception e) {
throw new RuntimeException(e);
}
}

Fixed version (ground truth):
/** 
 * Perform an aggregate query for the given table and query parameters. The table must belong to this session's application. Query parameters are specific to the storage service managing the application. Common parameters are: <table> <tr><td>Name</td><td>Value</td><td>Description</td></tr> <tr><td>m</td> <td>metric list</td> <td>Required. Comma-separated list of metric expression(s) to compute.</td> </tr> <tr><td>q</td> <td>query expression</td> <td>Optional. Query expression that selects objects in the table. Default is "*", which selects all objects.</td> </tr> <tr><td>f</td> <td>grouping parameter</td> <td>Optional. Comma-separated list of grouping field expressions. When present, creates a grouped aggregate query instead of a global aggregate query.</td> </tr> <tr><td>pair</td> <td>pair list</td> <td>Optiona. A comma-separated of pair of link paths that define a special <i>dual role</i> query. See OLAP documentation about the operation of this special query type.</td> </tr> <tr><td>shards</td> <td>shard list</td> <td>Comma-separated list of shards to query. Either this or the "range" parameter must be provided, but not both.</td> </tr> <tr><td>range</td> <td><i>shard-from</i>[,<i>shard-to</i>]</td> <td>Defines a range of shards to query beginning with shards whose name is greater than or equal to the <i>shard-from</i> name. If a <i>shard-to</i> name is given, shard names must also be less than or equal to that name. Either this or the "shards" parameter must be provided, but not both.</td> </tr> <tr><td>xshards</td> <td>shard list</td> <td>Comma-separated list of shards that define the search scope of xlinks. This parameter is only meaningful when the aggregate query uses xlinks. Either this or the "xrange" parameter can be provided, but not both. If neither "xshards" nor "xrange" is specified, the search scope of xlinks is defined by the "shards" or "range" parameter.</td> </tr> <tr><td>xrange</td> <td><i>shard-from</i>[,<i>shard-to</i>]</td> <td>Defines a range of shards to query for xlink values beginning with shards whose name is greater than or equal to the <i>shard-from</i> name. If a <i>shard-to</i> name is given, shard names must also be less than or equal to that name. Either this or the "xshards" parameter can be provided, but not both. If neither "xshards" nor "xrange" is specified, the search scope of xlinks is defined by the "shards" or "range" parameter.</td> </tr> </table> Results are turned in the given   {@link AggregateResult} object. An exception is thrownif a parameter is invalid or a database error occurs.
 * @param tableName Name of table to query.
 * @param params    Names and values of aggregate query parameters. 
 * @return          {@link AggregateResult} containing results.
 */
@Override public AggregateResult aggregateQuery(String tableName,Map<String,String> params){
  Utils.require(!Utils.isEmpty(tableName),"String_Node_Str");
  Utils.require(params != null && params.size() > 0,"String_Node_Str");
  TableDefinition tableDef=m_appDef.getTableDef(tableName);
  Utils.require(tableDef != null,"String_Node_Str",m_appDef.getAppName(),tableName);
  StringBuilder uri=new StringBuilder("String_Node_Str");
  uri.append(Utils.urlEncode(m_appDef.getAppName()));
  uri.append("String_Node_Str");
  uri.append(Utils.urlEncode(tableDef.getTableName()));
  uri.append("String_Node_Str");
  Utils.require(params.containsKey("String_Node_Str"),"String_Node_Str");
  uri.append("String_Node_Str");
  uri.append(Utils.urlEncode(params.get("String_Node_Str")));
  for (  String name : params.keySet()) {
    String value=params.get(name);
switch (name) {
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
case "String_Node_Str":
      uri.append("String_Node_Str");
    uri.append(name);
  uri.append("String_Node_Str");
uri.append(Utils.urlEncode(value));
break;
case "String_Node_Str":
break;
default :
Utils.require(false,"String_Node_Str",name);
}
}
addTenantParam(uri);
try {
RESTResponse response=m_restClient.sendRequest(HttpMethod.GET,uri.toString());
m_logger.debug("String_Node_Str",response.toString());
AggregateResult result=new AggregateResult();
if (response.getCode() != HttpCode.OK) {
result.setErrorMessage(response.getBody());
}
 else {
result.parse(UNode.parse(response.getBody(),response.getContentType()));
}
return result;
}
 catch (Exception e) {
throw new RuntimeException(e);
}
}