Program: 35458
Project: 35458
Buggy source:
public List<LocationsResult> findLocations(LocationsRequest request) throws Exception {
  List<LocationsResult> results=new ArrayList<LocationsResult>();
  Connection connection=null;
  Exception exception=null;
  try {
    connection=_dataSource.getConnection();
    connection.setAutoCommit(false);
    StopWatch sw=null;
    if (LOGGER.isDebugEnabled()) {
      sw=new StopWatch();
      sw.start();
    }
    PreparedStatement statement=null;
    ResultSet resSet=null;
    if (LOGGER.isDebugEnabled()) {
      StopWatch sw2=new StopWatch();
      sw2.start();
      statement=createLocationsStatement(request,connection);
      sw2.stop();
      LOGGER.debug(String.format("String_Node_Str",sw2.getSeconds()));
      sw2.start();
      resSet=statement.executeQuery();
      sw2.stop();
      LOGGER.debug(String.format("String_Node_Str",sw2.getSeconds()));
    }
 else {
      statement=createLocationsStatement(request,connection);
      resSet=statement.executeQuery();
    }
    QueryColumnsInfo queryColumns=COLUMNS_INFO[request.getDetails()];
    int nColumns=queryColumns.getCount();
    if (request.getGeometry() instanceof Polygon)     nColumns--;
    WKBReader wkbReader=new WKBReader();
    while (resSet.next()) {
      try {
        LocationsResult lr=new LocationsResult();
        for (int i=0; i < nColumns; i++) {
          if (i != _geomColumnIndex) {
            String value=resSet.getString(i + 1);
            if (!Helper.isEmpty(value))             lr.addProperty(queryColumns.getName(i),value);
          }
 else {
            byte[] bytes=resSet.getBytes(_geomColumnIndex + 1);
            if (bytes != null)             lr.setGeometry(wkbReader.read(bytes));
          }
        }
        results.add(lr);
      }
 catch (      Exception ex) {
        LOGGER.error(ex);
        throw new IOException(ex.getMessage());
      }
    }
    resSet.close();
    statement.close();
    if (LOGGER.isDebugEnabled()) {
      sw.stop();
      LOGGER.debug(String.format("String_Node_Str",results.size(),sw.getSeconds()));
    }
  }
 catch (  Exception ex) {
    LOGGER.error(ex);
    exception=new InternalServerException(LocationsErrorCodes.UNKNOWN,"String_Node_Str");
  }
 finally {
    if (connection != null)     connection.close();
  }
  if (exception != null)   throw exception;
  return results;
}

Fixed version (ground truth):
public List<LocationsResult> findLocations(LocationsRequest request) throws Exception {
  List<LocationsResult> results=new ArrayList<LocationsResult>();
  Connection connection=null;
  PreparedStatement statement=null;
  Exception exception=null;
  try {
    connection=_dataSource.getConnection();
    connection.setAutoCommit(false);
    StopWatch sw=null;
    if (LOGGER.isDebugEnabled()) {
      sw=new StopWatch();
      sw.start();
    }
    ResultSet resSet=null;
    if (LOGGER.isDebugEnabled()) {
      StopWatch sw2=new StopWatch();
      sw2.start();
      statement=createLocationsStatement(request,connection);
      sw2.stop();
      LOGGER.debug(String.format("String_Node_Str",sw2.getSeconds()));
      sw2.start();
      resSet=statement.executeQuery();
      sw2.stop();
      LOGGER.debug(String.format("String_Node_Str",sw2.getSeconds()));
    }
 else {
      statement=createLocationsStatement(request,connection);
      resSet=statement.executeQuery();
    }
    QueryColumnsInfo queryColumns=COLUMNS_INFO[request.getDetails()];
    int nColumns=queryColumns.getCount();
    if (request.getGeometry() instanceof Polygon || request.getGeometry() == null)     nColumns--;
    WKBReader wkbReader=new WKBReader();
    while (resSet.next()) {
      try {
        LocationsResult lr=new LocationsResult();
        for (int i=0; i < nColumns; i++) {
          if (i != _geomColumnIndex) {
            String value=resSet.getString(i + 1);
            if (!Helper.isEmpty(value))             lr.addProperty(queryColumns.getName(i),value);
          }
 else {
            byte[] bytes=resSet.getBytes(_geomColumnIndex + 1);
            if (bytes != null)             lr.setGeometry(wkbReader.read(bytes));
          }
        }
        results.add(lr);
      }
 catch (      Exception ex) {
        LOGGER.error(ex);
        throw new IOException(ex.getMessage());
      }
    }
    resSet.close();
    if (LOGGER.isDebugEnabled()) {
      sw.stop();
      LOGGER.debug(String.format("String_Node_Str",results.size(),sw.getSeconds()));
    }
  }
 catch (  Exception ex) {
    LOGGER.error(ex);
    exception=new InternalServerException(LocationsErrorCodes.UNKNOWN,"String_Node_Str");
  }
 finally {
    if (statement != null)     statement.close();
    if (connection != null)     connection.close();
  }
  if (exception != null)   throw exception;
  return results;
}