Program: 29909
Project: 29909
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. Either this or the 'cf' paramter can be provided, but not both.</td> </tr> <tr><td>cf</td> <td>composite 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. The 'cf' parameter causes a <i>composite</i> group to be generated for secondary groups. If single-level aggregate queries, 'cf' is the same as 'f'. Either this or the 'f' parameter can be specified, but not both.</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":
      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(getUNodeResult(response));
}
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. Either this or the 'cf' paramter can be provided, but not both.</td> </tr> <tr><td>cf</td> <td>composite 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. The 'cf' parameter causes a <i>composite</i> group to be generated for secondary groups. If single-level aggregate queries, 'cf' is the same as 'f'. Either this or the 'f' parameter can be specified, but not both.</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":
      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(getUNodeResult(response));
}
return result;
}
 catch (Exception e) {
throw new RuntimeException(e);
}
}