Program: 139909
Project: 139909
Buggy source:
@Override protected boolean runAnalysis(Analysis analysis,String sqlStatement){
  boolean ok=true;
  TypedReturnCode<Connection> trc=this.getConnection(analysis);
  if (!trc.isOk()) {
    return traceError("String_Node_Str" + analysis.getName() + "String_Node_Str"+ trc.getMessage());
  }
  Connection connection=trc.getObject();
  try {
    Map<ModelElement,List<Indicator>> elementToIndicator=new HashMap<ModelElement,List<Indicator>>();
    Collection<Indicator> indicators=IndicatorHelper.getIndicatorLeaves(analysis.getResults());
    for (    Indicator indicator : indicators) {
      if (indicator instanceof CompositeIndicator) {
        continue;
      }
      String catalogName=getCatalogOrSchemaName(indicator.getAnalyzedElement());
      if (catalogName != null) {
        changeCatalog(catalogName,connection);
      }
      Expression query=dbms().getInstantiatedExpression(indicator);
      if (query == null || !executeQuery(indicator,connection,query.getBody())) {
        ok=traceError("String_Node_Str" + indicator.getName() + "String_Node_Str"+ ((query == null) ? "String_Node_Str" : "String_Node_Str" + query.getBody()));
      }
 else {
        indicator.setComputed(true);
      }
      MultiMapHelper.addUniqueObjectToListMap(indicator.getAnalyzedElement(),indicator,elementToIndicator);
    }
    connection.close();
    Set<ModelElement> analyzedElements=elementToIndicator.keySet();
    for (    ModelElement modelElement : analyzedElements) {
      RowCountIndicator rowCount=getRowCountIndicator(modelElement,elementToIndicator);
      NullCountIndicator nullCount=getNullCountIndicator(modelElement,elementToIndicator);
      List<Indicator> list=elementToIndicator.get(modelElement);
      for (      Indicator ind : list) {
        if (rowCount != null) {
          ind.setCount(rowCount.getCount());
        }
        if (nullCount != null) {
          ind.setNullCount(nullCount.getNullCount());
        }
      }
    }
  }
 catch (  SQLException e) {
    log.error(e,e);
    this.errorMessage=e.getMessage();
    ok=false;
  }
 finally {
    ConnectionUtils.closeConnection(connection);
  }
  return ok;
}

Fixed version (ground truth):
@Override protected boolean runAnalysis(Analysis analysis,String sqlStatement){
  boolean ok=true;
  TypedReturnCode<Connection> trc=this.getConnection(analysis);
  if (!trc.isOk()) {
    return traceError("String_Node_Str" + analysis.getName() + "String_Node_Str"+ trc.getMessage());
  }
  Connection connection=trc.getObject();
  try {
    Map<ModelElement,List<Indicator>> elementToIndicator=new HashMap<ModelElement,List<Indicator>>();
    Collection<Indicator> indicators=IndicatorHelper.getIndicatorLeaves(analysis.getResults());
    for (    Indicator indicator : indicators) {
      if (indicator instanceof CompositeIndicator) {
        continue;
      }
      String catalogName=getCatalogOrSchemaName(indicator.getAnalyzedElement());
      if (catalogName != null) {
        changeCatalog(catalogName,connection);
      }
      Expression query=dbms().getInstantiatedExpression(indicator);
      if (query == null || !executeQuery(indicator,connection,query.getBody())) {
        ok=traceError("String_Node_Str" + indicator.getName() + "String_Node_Str"+ ((query == null) ? "String_Node_Str" : "String_Node_Str" + query.getBody()));
      }
 else {
        indicator.setComputed(true);
      }
      MultiMapHelper.addUniqueObjectToListMap(indicator.getAnalyzedElement(),indicator,elementToIndicator);
    }
    connection.close();
    setRowCountAndNullCount(elementToIndicator);
  }
 catch (  SQLException e) {
    log.error(e,e);
    this.errorMessage=e.getMessage();
    ok=false;
  }
 finally {
    ConnectionUtils.closeConnection(connection);
  }
  return ok;
}