Program: 18623
Project: 18623
Buggy source:
/** 
 * Get some metrics numbers from the server.
 * @param m the metric to fetch
 * @param service
 * @param operation
 * @param returnType
 * @param date1
 * @param date2
 * @param intervalHrs
 */
protected void fetchMetric(final ServiceMetric m,final SelectionContext selectionContext,Entity returnType,final long date1,final long date2,final int intervalHrs){
  List<EntityName> subject=new ArrayList<EntityName>();
  if (selectionContext.getSelection(ObjectType.ServiceName) != null) {
    EntityName serviceName=new EntityName();
    serviceName.type=Entity.Service;
    serviceName.add(selectionContext.getSelection(ObjectType.ServiceName));
    subject.add(serviceName);
  }
  if (selectionContext.getSelection(ObjectType.OperationName) != null) {
    EntityName opName=new EntityName();
    opName.type=Entity.Operation;
    opName.add(selectionContext.getSelection(ObjectType.OperationName));
    subject.add(opName);
  }
  MetricCriteria mc=MetricCriteria.newMetricCriteria(m.toMetricName(),date1,date2,intervalHrs,Ordering.Descending,10,Perspective.Server,false);
  MetricResourceCriteria rmc=MetricResourceCriteria.newMetricResourceCriteria(subject,returnType);
  String url=queryService.getMetricDataDownloadUrl(mc,rmc);
  ServicePresenter.this.view.setDownloadUrl(m,url);
  queryService.getMetricData(mc,rmc,new AsyncCallback<MetricData>(){
    public void onFailure(    Throwable error){
      if (!ConsoleUtil.messages.badOrMissingResponseData().equals(error.getMessage()))       ServicePresenter.this.view.error(ConsoleUtil.messages.serverError(error.getLocalizedMessage()));
 else       ServicePresenter.this.view.setMetric(m,null);
    }
    public void onSuccess(    MetricData metric){
      ServicePresenter.this.view.activate();
      ServicePresenter.this.view.setMetric(m,metric);
switch (m) {
case ConsumerErrors:
case ConsumerTraffic:
{
          List<HasClickHandlers> clickHandlers=view.getTableColumn(m,1,0);
          if (clickHandlers != null) {
            for (            HasClickHandlers h : clickHandlers) {
              h.addClickHandler(new ClickHandler(){
                public void onClick(                ClickEvent event){
                  Object o=event.getSource();
                  if (o instanceof HasText) {
                    String consumer=((HasText)o).getText();
                    SelectionContext tmpSelection=new SelectionContext();
                    tmpSelection.selectAll(selectionContext);
                    tmpSelection.select(ObjectType.ConsumerName,consumer);
                    insertHistory(ConsumerPresenter.CONSUMER_ID,tmpSelection,date1,date2,intervalHrs,true);
                  }
                }
              }
);
            }
          }
          break;
        }
    }
  }
}
);
CriteriaInfoImpl criteriaInfo=new CriteriaInfoImpl();
criteriaInfo.setMetricName("String_Node_Str");
criteriaInfo.setServiceName("String_Node_Str");
criteriaInfo.setRoleType("String_Node_Str");
queryService.getServiceCallTrend(new MetricValue(criteriaInfo,date1,2400l,5,"String_Node_Str"),new MetricValue(criteriaInfo,date2,2400l,5,"String_Node_Str"),new AsyncCallback<List<TimeSlotData>>(){
  @Override public void onSuccess(  List<TimeSlotData> dataRanges){
    ServicePresenter.this.view.setServiceCallTrendData(dataRanges);
  }
  @Override public void onFailure(  Throwable exception){
    GWT.log(exception.getMessage());
  }
}
);
}

Fixed version (ground truth):
/** 
 * Get some metrics numbers from the server.
 * @param m the metric to fetch
 * @param service
 * @param operation
 * @param returnType
 * @param date1
 * @param date2
 * @param intervalHrs
 */
protected void fetchMetric(final ServiceMetric m,final SelectionContext selectionContext,Entity returnType,final long date1,final long date2,final int intervalHrs){
  List<EntityName> subject=new ArrayList<EntityName>();
  if (selectionContext.getSelection(ObjectType.ServiceName) != null) {
    EntityName serviceName=new EntityName();
    serviceName.type=Entity.Service;
    serviceName.add(selectionContext.getSelection(ObjectType.ServiceName));
    subject.add(serviceName);
  }
  if (selectionContext.getSelection(ObjectType.OperationName) != null) {
    EntityName opName=new EntityName();
    opName.type=Entity.Operation;
    opName.add(selectionContext.getSelection(ObjectType.OperationName));
    subject.add(opName);
  }
  MetricCriteria mc=MetricCriteria.newMetricCriteria(m.toMetricName(),date1,date2,intervalHrs,Ordering.Descending,10,Perspective.Server,false);
  MetricResourceCriteria rmc=MetricResourceCriteria.newMetricResourceCriteria(subject,returnType);
  String url=queryService.getMetricDataDownloadUrl(mc,rmc);
  ServicePresenter.this.view.setDownloadUrl(m,url);
  queryService.getMetricData(mc,rmc,new AsyncCallback<MetricData>(){
    public void onFailure(    Throwable error){
      if (!ConsoleUtil.messages.badOrMissingResponseData().equals(error.getMessage()))       ServicePresenter.this.view.error(ConsoleUtil.messages.serverError(error.getLocalizedMessage()));
 else       ServicePresenter.this.view.setMetric(m,null);
    }
    public void onSuccess(    MetricData metric){
      ServicePresenter.this.view.activate();
      ServicePresenter.this.view.setMetric(m,metric);
switch (m) {
case ConsumerErrors:
case ConsumerTraffic:
{
          List<HasClickHandlers> clickHandlers=view.getTableColumn(m,1,0);
          if (clickHandlers != null) {
            for (            HasClickHandlers h : clickHandlers) {
              h.addClickHandler(new ClickHandler(){
                public void onClick(                ClickEvent event){
                  Object o=event.getSource();
                  if (o instanceof HasText) {
                    String consumer=((HasText)o).getText();
                    SelectionContext tmpSelection=new SelectionContext();
                    tmpSelection.selectAll(selectionContext);
                    tmpSelection.select(ObjectType.ConsumerName,consumer);
                    insertHistory(ConsumerPresenter.CONSUMER_ID,tmpSelection,date1,date2,intervalHrs,true);
                  }
                }
              }
);
            }
          }
          break;
        }
    }
  }
}
);
}