Program: 18595
Project: 18595
Buggy source:
public void setMetric(ConsumerMetric m,MetricData result){
  SummaryPanel panel=null;
  String date1Header="String_Node_Str";
  String date2Header="String_Node_Str";
  if (result != null) {
    String d1=ConsoleUtil.timeFormat.format(new Date(result.getMetricCriteria().date1));
    String d2=ConsoleUtil.timeFormat.format(new Date(result.getMetricCriteria().date2));
    date1Header=d1 + "String_Node_Str" + (result.getMetricCriteria().durationSec / (60 * 60))+ ConsoleUtil.constants.hr();
    date2Header=d2 + "String_Node_Str" + (result.getMetricCriteria().durationSec / (60 * 60))+ ConsoleUtil.constants.hr();
  }
switch (m) {
case CallVolume:
{
      String[] columns={ConsoleUtil.constants.consumers(),(result == null ? ConsoleUtil.constants.count() : date2Header + "String_Node_Str" + ConsoleUtil.constants.count()),(result == null ? ConsoleUtil.constants.count() : date1Header + "String_Node_Str" + ConsoleUtil.constants.count()),"String_Node_Str" + ConsoleUtil.constants.change()};
      List<Widget[]> rows=new ArrayList<Widget[]>();
      if (result != null) {
        for (int i=0; i < result.getReturnData().size(); i++) {
          MetricGroupData rd=result.getReturnData().get(i);
          Widget[] rowData=new Widget[4];
          rowData[0]=new Label(rd.getCriteriaInfo().getConsumerName());
          rowData[1]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
          rowData[2]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
          rowData[3]=new Label(rd.getDiff());
          rows.add(rowData);
        }
      }
      setTabularData(callVolumeTable,columns,rows);
      for (int i=1; i < callVolumeTable.getRowCount(); i++) {
        Widget w=callVolumeTable.getWidget(i,0);
        w.addStyleName("String_Node_Str");
      }
      panel=callVolumePanel;
      break;
    }
case Performance:
{
    String[] columns={ConsoleUtil.constants.consumers(),(result == null ? ConsoleUtil.constants.average() : date2Header + "String_Node_Str" + ConsoleUtil.constants.average()+ "String_Node_Str"),(result == null ? ConsoleUtil.constants.average() : date1Header + "String_Node_Str" + ConsoleUtil.constants.average()+ "String_Node_Str"),"String_Node_Str" + ConsoleUtil.constants.change()};
    List<Widget[]> rows=new ArrayList<Widget[]>();
    if (result != null) {
      for (int i=0; i < result.getReturnData().size(); i++) {
        MetricGroupData rd=result.getReturnData().get(i);
        Widget[] rowData=new Widget[4];
        rowData[0]=new Label(rd.getCriteriaInfo().getConsumerName());
        rowData[1]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
        rowData[2]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
        rowData[3]=new Label(rd.getDiff());
        rows.add(rowData);
      }
    }
    setTabularData(performanceTable,columns,rows);
    for (int i=1; i < performanceTable.getRowCount(); i++) {
      Widget w=performanceTable.getWidget(i,0);
      w.addStyleName("String_Node_Str");
    }
    panel=performancePanel;
    break;
  }
case Errors:
{
  String[] columns={ConsoleUtil.constants.consumers(),(result == null ? ConsoleUtil.constants.count() : date2Header + "String_Node_Str" + ConsoleUtil.constants.count()),(result == null ? ConsoleUtil.constants.count() : date1Header + "String_Node_Str" + ConsoleUtil.constants.count()),"String_Node_Str" + ConsoleUtil.constants.change()};
  List<Widget[]> rows=new ArrayList<Widget[]>();
  if (result != null) {
    for (int i=0; i < result.getReturnData().size(); i++) {
      MetricGroupData rd=result.getReturnData().get(i);
      Widget[] rowData=new Widget[4];
      rowData[0]=new Label(rd.getCriteriaInfo().getConsumerName());
      rowData[1]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
      rowData[2]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
      rowData[3]=new Label(rd.getDiff());
      rows.add(rowData);
    }
  }
  setTabularData(errorsTable,columns,rows);
  for (int i=1; i < errorsTable.getRowCount(); i++) {
    Widget w=errorsTable.getWidget(i,0);
    w.addStyleName("String_Node_Str");
  }
  panel=errorsPanel;
  break;
}
case TopVolume:
{
String col0=ConsoleUtil.constants.services();
if (result != null && result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Operation)) col0=ConsoleUtil.constants.operations();
String[] columns={col0,(result == null ? ConsoleUtil.constants.count() : date2Header + "String_Node_Str" + ConsoleUtil.constants.count()),(result == null ? ConsoleUtil.constants.count() : date1Header + "String_Node_Str" + ConsoleUtil.constants.count()),"String_Node_Str" + ConsoleUtil.constants.change()};
List<Widget[]> rows=new ArrayList<Widget[]>();
if (result != null) {
  for (int i=0; i < result.getReturnData().size(); i++) {
    MetricGroupData rd=result.getReturnData().get(i);
    Widget[] rowData=new Widget[4];
    if (result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Service))     rowData[0]=new Label(rd.getCriteriaInfo().getServiceName());
 else     if (result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Operation))     rowData[0]=new Label(rd.getCriteriaInfo().getOperationName());
    rowData[1]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
    rowData[2]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
    rowData[3]=new Label(rd.getDiff());
    rows.add(rowData);
  }
}
setTabularData(topVolumeTable,columns,rows);
for (int i=1; i < topVolumeTable.getRowCount(); i++) {
  Widget w=topVolumeTable.getWidget(i,0);
  w.addStyleName("String_Node_Str");
}
panel=topVolumePanel;
break;
}
case LeastPerformance:
{
String col0=ConsoleUtil.constants.services();
if (result != null && result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Operation)) col0=ConsoleUtil.constants.operations();
String[] columns={col0,(result == null ? ConsoleUtil.constants.average() : date2Header + "String_Node_Str" + ConsoleUtil.constants.average()+ "String_Node_Str"),(result == null ? ConsoleUtil.constants.average() : date1Header + "String_Node_Str" + ConsoleUtil.constants.average()+ "String_Node_Str"),"String_Node_Str" + ConsoleUtil.constants.change()};
List<Widget[]> rows=new ArrayList<Widget[]>();
if (result != null) {
for (int i=0; i < result.getReturnData().size(); i++) {
  MetricGroupData rd=result.getReturnData().get(i);
  Widget[] rowData=new Widget[4];
  if (result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Service))   rowData[0]=new Label(rd.getCriteriaInfo().getServiceName());
 else   if (result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Operation))   rowData[0]=new Label(rd.getCriteriaInfo().getOperationName());
  rowData[1]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
  rowData[2]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
  rowData[3]=new Label(rd.getDiff());
  rows.add(rowData);
}
}
setTabularData(leastPerformanceTable,columns,rows);
for (int i=1; i < leastPerformanceTable.getRowCount(); i++) {
Widget w=leastPerformanceTable.getWidget(i,0);
w.addStyleName("String_Node_Str");
}
panel=leastPerformancePanel;
break;
}
case TopServiceErrors:
{
boolean isOperation=false;
if (result != null && result.getMetricResourceCriteria() != null && result.getMetricResourceCriteria().resourceEntityRequests != null) {
for (ResourceEntityRequest r : result.getMetricResourceCriteria().resourceEntityRequests) {
if (r.resourceEntityType == Entity.Operation) isOperation=true;
}
}
String col0=ConsoleUtil.constants.services();
if (isOperation) col0=ConsoleUtil.constants.operations();
String[] columns={col0,ConsoleUtil.constants.errors(),(result == null ? ConsoleUtil.constants.count() : date1Header + "String_Node_Str" + ConsoleUtil.constants.count()),(result == null ? ConsoleUtil.constants.count() : date2Header + "String_Node_Str" + ConsoleUtil.constants.count()),"String_Node_Str" + ConsoleUtil.constants.change()};
List<Widget[]> rows=new ArrayList<Widget[]>();
if (result != null) {
for (int i=0; i < result.getReturnData().size(); i++) {
MetricGroupData rd=result.getReturnData().get(i);
Widget[] rowData=new Widget[5];
if (isOperation) rowData[0]=new Label(rd.getCriteriaInfo().getOperationName());
 else rowData[0]=new Label(rd.getCriteriaInfo().getServiceName());
rowData[1]=new Label(rd.getCriteriaInfo().getMetricName());
rowData[2]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
rowData[3]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
rowData[4]=new Label(rd.getDiff());
rows.add(rowData);
}
}
setTabularData(topServiceErrorsTable,columns,rows);
for (int i=1; i < topServiceErrorsTable.getRowCount(); i++) {
Widget w=topServiceErrorsTable.getWidget(i,0);
w.addStyleName("String_Node_Str");
}
panel=topServiceErrorsPanel;
break;
}
case TopConsumerErrors:
{
String[] columns={ConsoleUtil.constants.errors(),(result == null ? ConsoleUtil.constants.count() : date2Header + "String_Node_Str" + ConsoleUtil.constants.count()),(result == null ? ConsoleUtil.constants.count() : date1Header + "String_Node_Str" + ConsoleUtil.constants.count()),"String_Node_Str" + ConsoleUtil.constants.change()};
List<Widget[]> rows=new ArrayList<Widget[]>();
if (result != null) {
for (int i=0; i < result.getReturnData().size(); i++) {
MetricGroupData rd=result.getReturnData().get(i);
Widget[] rowData=new Widget[4];
rowData[0]=new Label(rd.getCriteriaInfo().getMetricName());
rowData[1]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
rowData[2]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
rowData[3]=new Label(rd.getDiff());
rows.add(rowData);
}
}
setTabularData(topConsumerErrorsTable,columns,rows);
panel=topConsumerErrorsPanel;
break;
}
}
if (result != null && result.getReturnData() != null && panel != null) {
int rows=result.getReturnData().size() + 1;
double height=0;
if (rows > 10) height=10 * 2.5;
 else height=rows * 2.5;
panel.setContentContainerHeight(String.valueOf(height) + "String_Node_Str");
}
if (panel != null) {
if (result != null) panel.setInfo(result.getRestUrl());
show(panel);
}
}

Fixed version (ground truth):
public void setMetric(ConsumerMetric m,MetricData result){
  SummaryPanel panel=null;
  String date1Header="String_Node_Str";
  String date2Header="String_Node_Str";
  if (result != null) {
    String d1=ConsoleUtil.timeFormat.format(new Date(result.getMetricCriteria().date1));
    String d2=ConsoleUtil.timeFormat.format(new Date(result.getMetricCriteria().date2));
    date1Header=d1 + "String_Node_Str" + (result.getMetricCriteria().durationSec / (60 * 60))+ ConsoleUtil.constants.hr();
    date2Header=d2 + "String_Node_Str" + (result.getMetricCriteria().durationSec / (60 * 60))+ ConsoleUtil.constants.hr();
  }
switch (m) {
case CallVolume:
{
      String[] columns={ConsoleUtil.constants.consumers(),(result == null ? ConsoleUtil.constants.count() : date2Header + "String_Node_Str" + ConsoleUtil.constants.count()),(result == null ? ConsoleUtil.constants.count() : date1Header + "String_Node_Str" + ConsoleUtil.constants.count()),"String_Node_Str" + ConsoleUtil.constants.change()};
      List<Widget[]> rows=new ArrayList<Widget[]>();
      if (result != null) {
        for (int i=0; i < result.getReturnData().size(); i++) {
          MetricGroupData rd=result.getReturnData().get(i);
          Widget[] rowData=new Widget[4];
          rowData[0]=new Label(rd.getCriteriaInfo().getConsumerName());
          rowData[1]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
          rowData[2]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
          rowData[3]=new Label(rd.getDiff());
          rows.add(rowData);
        }
      }
      setTabularData(callVolumeTable,columns,rows);
      for (int i=1; i < callVolumeTable.getRowCount(); i++) {
        Widget w=callVolumeTable.getWidget(i,0);
        w.addStyleName("String_Node_Str");
      }
      panel=callVolumePanel;
      break;
    }
case Performance:
{
    String[] columns={ConsoleUtil.constants.consumers(),(result == null ? ConsoleUtil.constants.average() : date2Header + "String_Node_Str" + ConsoleUtil.constants.average()+ "String_Node_Str"),(result == null ? ConsoleUtil.constants.average() : date1Header + "String_Node_Str" + ConsoleUtil.constants.average()+ "String_Node_Str"),"String_Node_Str" + ConsoleUtil.constants.change()};
    List<Widget[]> rows=new ArrayList<Widget[]>();
    if (result != null) {
      for (int i=0; i < result.getReturnData().size(); i++) {
        MetricGroupData rd=result.getReturnData().get(i);
        Widget[] rowData=new Widget[4];
        rowData[0]=new Label(rd.getCriteriaInfo().getConsumerName());
        rowData[1]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
        rowData[2]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
        rowData[3]=new Label(rd.getDiff());
        rows.add(rowData);
      }
    }
    setTabularData(performanceTable,columns,rows);
    for (int i=1; i < performanceTable.getRowCount(); i++) {
      Widget w=performanceTable.getWidget(i,0);
      w.addStyleName("String_Node_Str");
    }
    panel=performancePanel;
    break;
  }
case Errors:
{
  String[] columns={ConsoleUtil.constants.consumers(),(result == null ? ConsoleUtil.constants.count() : date2Header + "String_Node_Str" + ConsoleUtil.constants.count()),(result == null ? ConsoleUtil.constants.count() : date1Header + "String_Node_Str" + ConsoleUtil.constants.count()),"String_Node_Str" + ConsoleUtil.constants.change()};
  List<Widget[]> rows=new ArrayList<Widget[]>();
  if (result != null) {
    for (int i=0; i < result.getReturnData().size(); i++) {
      MetricGroupData rd=result.getReturnData().get(i);
      Widget[] rowData=new Widget[4];
      rowData[0]=new Label(rd.getCriteriaInfo().getConsumerName());
      rowData[1]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
      rowData[2]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
      rowData[3]=new Label(rd.getDiff());
      rows.add(rowData);
    }
  }
  setTabularData(errorsTable,columns,rows);
  for (int i=1; i < errorsTable.getRowCount(); i++) {
    Widget w=errorsTable.getWidget(i,0);
    w.addStyleName("String_Node_Str");
  }
  panel=errorsPanel;
  break;
}
case TopVolume:
{
String col0=ConsoleUtil.constants.services();
if (result != null && result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Operation)) col0=ConsoleUtil.constants.operations();
String[] columns={col0,(result == null ? ConsoleUtil.constants.count() : date2Header + "String_Node_Str" + ConsoleUtil.constants.count()),(result == null ? ConsoleUtil.constants.count() : date1Header + "String_Node_Str" + ConsoleUtil.constants.count()),"String_Node_Str" + ConsoleUtil.constants.change()};
List<Widget[]> rows=new ArrayList<Widget[]>();
if (result != null) {
  for (int i=0; i < result.getReturnData().size(); i++) {
    MetricGroupData rd=result.getReturnData().get(i);
    Widget[] rowData=new Widget[4];
    if (result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Service))     rowData[0]=new Label(rd.getCriteriaInfo().getServiceName());
 else     if (result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Operation))     rowData[0]=new Label(rd.getCriteriaInfo().getOperationName());
    rowData[1]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
    rowData[2]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
    rowData[3]=new Label(rd.getDiff());
    rows.add(rowData);
  }
}
setTabularData(topVolumeTable,columns,rows);
for (int i=1; i < topVolumeTable.getRowCount(); i++) {
  Widget w=topVolumeTable.getWidget(i,0);
  w.addStyleName("String_Node_Str");
}
panel=topVolumePanel;
break;
}
case LeastPerformance:
{
String col0=ConsoleUtil.constants.services();
if (result != null && result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Operation)) col0=ConsoleUtil.constants.operations();
String[] columns={col0,(result == null ? ConsoleUtil.constants.average() : date2Header + "String_Node_Str" + ConsoleUtil.constants.average()+ "String_Node_Str"),(result == null ? ConsoleUtil.constants.average() : date1Header + "String_Node_Str" + ConsoleUtil.constants.average()+ "String_Node_Str"),"String_Node_Str" + ConsoleUtil.constants.change()};
List<Widget[]> rows=new ArrayList<Widget[]>();
if (result != null) {
for (int i=0; i < result.getReturnData().size(); i++) {
  MetricGroupData rd=result.getReturnData().get(i);
  Widget[] rowData=new Widget[4];
  if (result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Service))   rowData[0]=new Label(rd.getCriteriaInfo().getServiceName());
 else   if (result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Operation))   rowData[0]=new Label(rd.getCriteriaInfo().getOperationName());
  rowData[1]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
  rowData[2]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
  rowData[3]=new Label(rd.getDiff());
  rows.add(rowData);
}
}
setTabularData(leastPerformanceTable,columns,rows);
for (int i=1; i < leastPerformanceTable.getRowCount(); i++) {
Widget w=leastPerformanceTable.getWidget(i,0);
w.addStyleName("String_Node_Str");
}
panel=leastPerformancePanel;
break;
}
case TopServiceErrors:
{
boolean isOperation=false;
if (result != null && result.getMetricResourceCriteria() != null && result.getMetricResourceCriteria().resourceEntityRequests != null) {
for (ResourceEntityRequest r : result.getMetricResourceCriteria().resourceEntityRequests) {
if (r.resourceEntityType == Entity.Operation) isOperation=true;
}
}
String col0=ConsoleUtil.constants.services();
if (isOperation) col0=ConsoleUtil.constants.operations();
String[] columns={col0,ConsoleUtil.constants.errors(),(result == null ? ConsoleUtil.constants.count() : date2Header + "String_Node_Str" + ConsoleUtil.constants.count()),(result == null ? ConsoleUtil.constants.count() : date1Header + "String_Node_Str" + ConsoleUtil.constants.count()),"String_Node_Str" + ConsoleUtil.constants.change()};
List<Widget[]> rows=new ArrayList<Widget[]>();
if (result != null) {
for (int i=0; i < result.getReturnData().size(); i++) {
MetricGroupData rd=result.getReturnData().get(i);
Widget[] rowData=new Widget[5];
if (isOperation) rowData[0]=new Label(rd.getCriteriaInfo().getOperationName());
 else rowData[0]=new Label(rd.getCriteriaInfo().getServiceName());
rowData[1]=new Label(rd.getCriteriaInfo().getMetricName());
rowData[2]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
rowData[3]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
rowData[4]=new Label(rd.getDiff());
rows.add(rowData);
}
}
setTabularData(topServiceErrorsTable,columns,rows);
for (int i=1; i < topServiceErrorsTable.getRowCount(); i++) {
Widget w=topServiceErrorsTable.getWidget(i,0);
w.addStyleName("String_Node_Str");
}
panel=topServiceErrorsPanel;
break;
}
case TopConsumerErrors:
{
String[] columns={ConsoleUtil.constants.errors(),(result == null ? ConsoleUtil.constants.count() : date2Header + "String_Node_Str" + ConsoleUtil.constants.count()),(result == null ? ConsoleUtil.constants.count() : date1Header + "String_Node_Str" + ConsoleUtil.constants.count()),"String_Node_Str" + ConsoleUtil.constants.change()};
List<Widget[]> rows=new ArrayList<Widget[]>();
if (result != null) {
for (int i=0; i < result.getReturnData().size(); i++) {
MetricGroupData rd=result.getReturnData().get(i);
Widget[] rowData=new Widget[4];
rowData[0]=new Label(rd.getCriteriaInfo().getMetricName());
rowData[1]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
rowData[2]=new Label(NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
rowData[3]=new Label(rd.getDiff());
rows.add(rowData);
}
}
setTabularData(topConsumerErrorsTable,columns,rows);
panel=topConsumerErrorsPanel;
break;
}
}
if (result != null && result.getReturnData() != null && panel != null) {
int rows=result.getReturnData().size() + 1;
double height=0;
if (rows > 10) height=10 * 2.5;
 else height=rows * 2.5;
panel.setContentContainerHeight(String.valueOf(height) + "String_Node_Str");
}
if (panel != null) {
if (result != null) panel.setInfo(result.getRestUrl());
show(panel);
}
}