Program: 18566
Project: 18566
Buggy source:
/** 
 * Fetch metric.
 * @param m the m
 * @param ec the ec
 * @param mc the mc
 */
protected void fetchMetric(final ErrorMetric m,final ErrorCriteria ec,final MetricCriteria mc){
  queryService.getErrorData(ec,mc,new AsyncCallback<ErrorMetricData>(){
    public void onFailure(    Throwable err){
      view.error(err.getLocalizedMessage());
    }
    public void onSuccess(    ErrorMetricData data){
      view.setErrorMetricData(m,data);
switch (m) {
case TopApplicationErrors:
case TopRequestErrors:
case TopSystemErrors:
case TopCriticals:
case TopErrors:
case TopWarnings:
{
          List<HasClickHandlers> handlers=view.getTableColumn(m,0);
          for (          HasClickHandlers h : handlers) {
            h.addClickHandler(new ClickHandler(){
              public void onClick(              ClickEvent event){
                Object o=event.getSource();
                if (o instanceof HasText) {
                  String errorId=((HasText)o).getText();
                  SelectionContext ctx=new SelectionContext();
                  ctx.selectAll(selectionContext);
                  ctx.unselect(ObjectType.ErrorName);
                  ctx.select(ObjectType.ErrorId,errorId);
                  view.reset();
                  fetchErrorDetail(ctx);
                  fetchMetrics(Arrays.asList(new ErrorMetric[]{ErrorMetric.ConsumerError}),ctx,selectedDate1,selectedDate2,selectedDurationHrs);
                  insertHistory(ERROR_ID,ctx,selectedDate1,selectedDate2,selectedDurationHrs,false);
                }
              }
            }
);
          }
          handlers=view.getTableColumn(m,1);
          for (          HasClickHandlers h : handlers) {
            h.addClickHandler(new ClickHandler(){
              public void onClick(              ClickEvent event){
                Object o=event.getSource();
                if (o instanceof HasText) {
                  String errorName=((HasText)o).getText();
                  SelectionContext ctx=new SelectionContext();
                  ctx.selectAll(selectionContext);
                  ctx.unselect(ObjectType.ErrorId);
                  ctx.select(ObjectType.ErrorName,errorName);
                  view.reset();
                  fetchErrorDetail(ctx);
                  fetchMetrics(Arrays.asList(new ErrorMetric[]{ErrorMetric.ConsumerError}),ctx,selectedDate1,selectedDate2,selectedDurationHrs);
                  insertHistory(ERROR_ID,ctx,selectedDate1,selectedDate2,selectedDurationHrs,false);
                }
              }
            }
);
          }
          break;
        }
case ConsumerError:
{
        List<HasClickHandlers> handlers=view.getTableColumn(m,0);
        for (        HasClickHandlers h : handlers) {
          h.addClickHandler(new ClickHandler(){
            public void onClick(            ClickEvent event){
              Object o=event.getSource();
              if (o instanceof HasText) {
                String consumer=((HasText)o).getText();
                SelectionContext ctx=new SelectionContext();
                ctx.selectAll(selectionContext);
                ctx.select(ObjectType.ConsumerName,consumer);
                insertHistory(ConsumerPresenter.CONSUMER_ID,ctx,selectedDate1,selectedDate2,selectedDurationHrs,true);
              }
            }
          }
);
        }
        break;
      }
  }
}
}
);
}

Fixed version (ground truth):
/** 
 * Fetch metric.
 * @param m the m
 * @param ec the ec
 * @param mc the mc
 */
protected void fetchMetric(final ErrorMetric m,final ErrorCriteria ec,final MetricCriteria mc){
  queryService.getErrorData(ec,mc,new AsyncCallback<ErrorMetricData>(){
    public void onFailure(    Throwable err){
      view.error(err.getLocalizedMessage());
    }
    public void onSuccess(    ErrorMetricData data){
      view.setErrorMetricData(m,data);
      String downloadUrl=queryService.getErrorDataDownloadUrl(ec,mc);
      view.setDownloadUrl(m,downloadUrl);
switch (m) {
case TopApplicationErrors:
case TopRequestErrors:
case TopSystemErrors:
case TopCriticals:
case TopErrors:
case TopWarnings:
{
          List<HasClickHandlers> handlers=view.getTableColumn(m,0);
          for (          HasClickHandlers h : handlers) {
            h.addClickHandler(new ClickHandler(){
              public void onClick(              ClickEvent event){
                Object o=event.getSource();
                if (o instanceof HasText) {
                  String errorId=((HasText)o).getText();
                  SelectionContext ctx=new SelectionContext();
                  ctx.selectAll(selectionContext);
                  ctx.unselect(ObjectType.ErrorName);
                  ctx.select(ObjectType.ErrorId,errorId);
                  view.reset();
                  fetchErrorDetail(ctx);
                  fetchMetrics(Arrays.asList(new ErrorMetric[]{ErrorMetric.ConsumerError}),ctx,selectedDate1,selectedDate2,selectedDurationHrs);
                  insertHistory(ERROR_ID,ctx,selectedDate1,selectedDate2,selectedDurationHrs,false);
                }
              }
            }
);
          }
          handlers=view.getTableColumn(m,1);
          for (          HasClickHandlers h : handlers) {
            h.addClickHandler(new ClickHandler(){
              public void onClick(              ClickEvent event){
                Object o=event.getSource();
                if (o instanceof HasText) {
                  String errorName=((HasText)o).getText();
                  SelectionContext ctx=new SelectionContext();
                  ctx.selectAll(selectionContext);
                  ctx.unselect(ObjectType.ErrorId);
                  ctx.select(ObjectType.ErrorName,errorName);
                  view.reset();
                  fetchErrorDetail(ctx);
                  fetchMetrics(Arrays.asList(new ErrorMetric[]{ErrorMetric.ConsumerError}),ctx,selectedDate1,selectedDate2,selectedDurationHrs);
                  insertHistory(ERROR_ID,ctx,selectedDate1,selectedDate2,selectedDurationHrs,false);
                }
              }
            }
);
          }
          break;
        }
case ConsumerError:
{
        List<HasClickHandlers> handlers=view.getTableColumn(m,0);
        for (        HasClickHandlers h : handlers) {
          h.addClickHandler(new ClickHandler(){
            public void onClick(            ClickEvent event){
              Object o=event.getSource();
              if (o instanceof HasText) {
                String consumer=((HasText)o).getText();
                SelectionContext ctx=new SelectionContext();
                ctx.selectAll(selectionContext);
                ctx.select(ObjectType.ConsumerName,consumer);
                insertHistory(ConsumerPresenter.CONSUMER_ID,ctx,selectedDate1,selectedDate2,selectedDurationHrs,true);
              }
            }
          }
);
        }
        break;
      }
  }
}
}
);
}