Program: 25027
Project: 25027
Buggy source:
/** 
 * <p>Process the ADQL query.</p> <p>This function calls the following function (in the same order):</p> <ol> <li>  {@link TAPFactory#getConnection(String)}</li> <li>  {@link #uploadTables()}</li> <li>  {@link #parseADQL()}</li> <li>  {@link #executeADQL(ADQLQuery)}</li> <li>  {@link #writeResult(TableIterator)}</li> <li>  {@link #dropUploadedTables()}</li> <li>  {@link TAPFactory#freeConnection(DBConnection)}</li> </ol> <p> The execution report is updated gradually. Besides a job parameter - progression - is set at each step of the process in order to notify the user of the progression of the query execution. This parameter is removed at the end of the execution if it is successful. </p> <p>The "interrupted" flag of the associated thread is often tested so that stopping the execution as soon as possible.</p>
 * @return	The updated execution report.
 * @throws TAPException			If any error occurs while executing the ADQL query.
 * @throws UWSException			If any error occurs while executing the ADQL query.
 * @throws IOException			If an error happens while writing the result in the specified {@link HttpServletResponse}. <i>That kind of error can be thrown only in synchronous mode. In asynchronous, the error is stored as job error report and is never propagated.</i>
 * @throws InterruptedException	If the job has been interrupted (by the user or a time-out).
 */
protected final TAPExecutionReport start() throws TAPException, UWSException, IOException, InterruptedException {
  logger.logTAP(LogLevel.INFO,report,"String_Node_Str",(report.synchronous ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str",null);
  long start=System.currentTimeMillis();
  TableIterator queryResult=null;
  try {
    initDBConnection(report.jobID);
    if (tapParams.getUploadedTables() != null && tapParams.getUploadedTables().length > 0) {
      startStep(ExecutionProgression.UPLOADING);
      uploadTables();
      endStep();
    }
    if (thread.isInterrupted())     throw new InterruptedException();
    startStep(ExecutionProgression.PARSING);
    ADQLQuery adqlQuery=null;
    try {
      adqlQuery=parseADQL();
    }
 catch (    ParseException pe) {
      if (report.synchronous)       throw new TAPException("String_Node_Str" + pe.getMessage(),pe,UWSException.BAD_REQUEST,tapParams.getQuery(),progression);
 else       throw new UWSException(UWSException.BAD_REQUEST,pe,"String_Node_Str" + pe.getMessage());
    }
    report.resultingColumns=adqlQuery.getResultingColumns();
    endStep();
    if (thread.isInterrupted())     throw new InterruptedException();
    startStep(ExecutionProgression.EXECUTING_ADQL);
    queryResult=executeADQL(adqlQuery);
    endStep();
    if (thread.isInterrupted())     throw new InterruptedException();
    startStep(ExecutionProgression.WRITING_RESULT);
    writeResult(queryResult);
    endStep();
    tapParams.remove(TAPJob.PARAM_PROGRESSION);
    report.success=true;
    report.setTotalDuration(System.currentTimeMillis() - start);
    logger.logTAP(LogLevel.INFO,report,"String_Node_Str","String_Node_Str",null);
    return report;
  }
  finally {
    if (queryResult != null) {
      try {
        queryResult.close();
      }
 catch (      DataReadException dre) {
        logger.logTAP(LogLevel.WARNING,report,"String_Node_Str","String_Node_Str",dre);
      }
    }
    try {
      dropUploadedTables();
    }
 catch (    TAPException e) {
      logger.logTAP(LogLevel.WARNING,report,"String_Node_Str","String_Node_Str",e);
    }
    if (dbConn != null) {
      dbConn.cancel(true);
      service.getFactory().freeConnection(dbConn);
      dbConn=null;
    }
  }
}

Fixed version (ground truth):
/** 
 * <p>Process the ADQL query.</p> <p>This function calls the following function (in the same order):</p> <ol> <li>  {@link TAPFactory#getConnection(String)}</li> <li>  {@link #uploadTables()}</li> <li>  {@link #parseADQL()}</li> <li>  {@link #executeADQL(ADQLQuery)}</li> <li>  {@link #writeResult(TableIterator)}</li> <li>  {@link #dropUploadedTables()}</li> <li>  {@link TAPFactory#freeConnection(DBConnection)}</li> </ol> <p> The execution report is updated gradually. Besides a job parameter - progression - is set at each step of the process in order to notify the user of the progression of the query execution. This parameter is removed at the end of the execution if it is successful. </p> <p>The "interrupted" flag of the associated thread is often tested so that stopping the execution as soon as possible.</p>
 * @return	The updated execution report.
 * @throws TAPException			If any error occurs while executing the ADQL query.
 * @throws UWSException			If any error occurs while executing the ADQL query.
 * @throws IOException			If an error happens while writing the result in the specified {@link HttpServletResponse}. <i>That kind of error can be thrown only in synchronous mode. In asynchronous, the error is stored as job error report and is never propagated.</i>
 * @throws InterruptedException	If the job has been interrupted (by the user or a time-out).
 */
protected final TAPExecutionReport start() throws TAPException, UWSException, IOException, InterruptedException {
  logger.logTAP(LogLevel.INFO,report,"String_Node_Str",(report.synchronous ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str",null);
  long start=System.currentTimeMillis();
  TableIterator queryResult=null;
  try {
    initDBConnection(report.jobID);
    if (tapParams.getUploadedTables() != null && tapParams.getUploadedTables().length > 0) {
      startStep(ExecutionProgression.UPLOADING);
      uploadTables();
      endStep();
    }
    if (thread.isInterrupted())     throw new InterruptedException();
    startStep(ExecutionProgression.PARSING);
    ADQLQuery adqlQuery=null;
    try {
      adqlQuery=parseADQL();
    }
 catch (    ParseException pe) {
      if (report.synchronous)       throw new TAPException("String_Node_Str" + pe.getMessage(),pe,UWSException.BAD_REQUEST,tapParams.getQuery(),progression);
 else       throw new UWSException(UWSException.BAD_REQUEST,pe,"String_Node_Str" + pe.getMessage());
    }
    report.resultingColumns=adqlQuery.getResultingColumns();
    endStep();
    if (thread.isInterrupted())     throw new InterruptedException();
    startStep(ExecutionProgression.EXECUTING_ADQL);
    queryResult=executeADQL(adqlQuery);
    endStep();
    if (thread.isInterrupted())     throw new InterruptedException();
    startStep(ExecutionProgression.WRITING_RESULT);
    writeResult(queryResult);
    endStep();
    tapParams.remove(TAPJob.PARAM_PROGRESSION);
    report.success=true;
    report.setTotalDuration(System.currentTimeMillis() - start);
    logger.logTAP(LogLevel.INFO,report,"String_Node_Str","String_Node_Str",null);
    return report;
  }
  finally {
    if (queryResult != null) {
      try {
        queryResult.close();
      }
 catch (      DataReadException dre) {
        logger.logTAP(LogLevel.WARNING,report,"String_Node_Str","String_Node_Str",dre);
      }
    }
    try {
      dropUploadedTables();
    }
 catch (    TAPException e) {
      logger.logTAP(LogLevel.WARNING,report,"String_Node_Str","String_Node_Str",e);
    }
    if (dbConn != null) {
      service.getFactory().freeConnection(dbConn);
      dbConn=null;
    }
  }
}