Program: 9833
Project: 9833
Buggy source:
@Override public ResultSet execSelect(){
  Var idVar=Var.alloc("String_Node_Str");
  Var executionTimeVar=Var.alloc("String_Node_Str");
  Var timeOutVar=Var.alloc("String_Node_Str");
  Var resultSetSizeVar=Var.alloc("String_Node_Str");
  Var isErrorVar=Var.alloc("String_Node_Str");
  Var errorMsgVar=Var.alloc("String_Node_Str");
  Var queryStringVar=Var.alloc("String_Node_Str");
  List<String> resultVars=Arrays.asList(idVar.getVarName(),executionTimeVar.getVarName(),timeOutVar.getVarName(),resultSetSizeVar.getVarName(),isErrorVar.getVarName(),errorMsgVar.getVarName(),queryStringVar.getVarName());
  List<Binding> resultBindings=new ArrayList<Binding>();
  SparqlSqlOpRewrite ssoRewrite=sparqlSqlOpRewriter.rewrite(query);
  SqlOp sqlOp=ssoRewrite.getSqlOp();
  int id=0;
  if (sqlOp instanceof SqlOpSelectBlock) {
    SqlOpSelectBlock b=(SqlOpSelectBlock)sqlOp;
    SqlOp subOp=b.getSubOp();
    if (subOp instanceof SqlOpUnionN) {
      SqlOpUnionN u=(SqlOpUnionN)subOp;
      for (      SqlOp member : u.getSubOps()) {
        SqlOpSelectBlock m=(SqlOpSelectBlock)member;
        SqlOpSelectBlock block=SqlOpSelectBlock.create(m.getSubOp());
        block.getProjection().put("String_Node_Str",new S_Constant(SqlValue.TRUE));
        block.getConditions().addAll(m.getConditions());
        block.setLimit(100l);
        block.setAliasName("String_Node_Str");
        SqlOpSelectBlock wrapper=SqlOpSelectBlock.create(block);
        wrapper.getProjection().put("String_Node_Str",new S_Agg(new S_AggCount()));
        ++id;
        String sqlQueryString=sqlOpSerializer.serialize(wrapper);
        logger.info("String_Node_Str" + sqlQueryString);
        long start=System.currentTimeMillis();
        long elapsedTime=timeOutInMillis;
        boolean timeOut=true;
        Node resultSetSizeNode=null;
        Node errorMsgNode=null;
        boolean isError=false;
        Connection conn=null;
        java.sql.ResultSet sqlRs=null;
        try {
          conn=dataSource.getConnection();
          conn.setAutoCommit(false);
          Statement stmt=QueryExecutionSelect.createStatement(conn);
          Thread thread=null;
          WatchDog watchDog=null;
          try {
            stmt.setQueryTimeout(timeOutInMillis);
          }
 catch (          Exception e) {
            logger.warn("String_Node_Str");
            watchDog=new WatchDog(stmt,timeOutInMillis);
            thread=new Thread(watchDog);
            thread.start();
          }
          sqlRs=stmt.executeQuery(sqlQueryString);
          if (thread != null) {
            timeOut=false;
            watchDog.cancel();
          }
          sqlRs.next();
          long resultSetSize=sqlRs.getLong("String_Node_Str");
          resultSetSizeNode=NodeValue.makeInteger(resultSetSize).asNode();
          long end=System.currentTimeMillis();
          elapsedTime=end - start;
        }
 catch (        SQLTimeoutException e) {
          timeOut=true;
        }
catch (        Exception e) {
          String errorMsg=e.getMessage();
          errorMsgNode=NodeValue.makeString(errorMsg).asNode();
          isError=true;
          if (elapsedTime >= timeOutInMillis) {
            timeOut=true;
          }
        }
 finally {
          if (sqlRs != null) {
            try {
              sqlRs.close();
            }
 catch (            SQLException e) {
              throw new RuntimeException(e);
            }
          }
          if (conn != null) {
            try {
              conn.close();
            }
 catch (            SQLException e) {
              throw new RuntimeException(e);
            }
          }
        }
        BindingHashMap binding=new BindingHashMap();
        binding.add(idVar,NodeValue.makeInteger(id).asNode());
        binding.add(executionTimeVar,NodeValue.makeInteger(elapsedTime).asNode());
        binding.add(timeOutVar,NodeValue.makeBoolean(timeOut).asNode());
        binding.add(resultSetSizeVar,resultSetSizeNode);
        binding.add(isErrorVar,NodeValue.makeBoolean(isError).asNode());
        binding.add(errorMsgVar,errorMsgNode);
        binding.add(queryStringVar,NodeValue.makeString(sqlQueryString).asNode());
        resultBindings.add(binding);
      }
    }
  }
  QueryIterator queryIterator=new QueryIterPlainWrapper(resultBindings.iterator());
  ResultSet result=ResultSetFactory.create(queryIterator,resultVars);
  return result;
}

Fixed version (ground truth):
@Override public ResultSet execSelect(){
  Var idVar=Var.alloc("String_Node_Str");
  Var executionTimeVar=Var.alloc("String_Node_Str");
  Var timeOutVar=Var.alloc("String_Node_Str");
  Var resultSetSizeVar=Var.alloc("String_Node_Str");
  Var isErrorVar=Var.alloc("String_Node_Str");
  Var errorMsgVar=Var.alloc("String_Node_Str");
  Var queryStringVar=Var.alloc("String_Node_Str");
  List<String> resultVars=Arrays.asList(idVar.getVarName(),executionTimeVar.getVarName(),timeOutVar.getVarName(),resultSetSizeVar.getVarName(),isErrorVar.getVarName(),errorMsgVar.getVarName(),queryStringVar.getVarName());
  List<Binding> resultBindings=new ArrayList<Binding>();
  SparqlSqlOpRewrite ssoRewrite=sparqlSqlOpRewriter.rewrite(query);
  SqlOp sqlOp=ssoRewrite.getSqlOp();
  int id=0;
  if (sqlOp instanceof SqlOpSelectBlock) {
    SqlOpSelectBlock b=(SqlOpSelectBlock)sqlOp;
    SqlOp subOp=b.getSubOp();
    if (subOp instanceof SqlOpUnionN) {
      SqlOpUnionN u=(SqlOpUnionN)subOp;
      for (      SqlOp member : u.getSubOps()) {
        SqlOpSelectBlock m=(SqlOpSelectBlock)member;
        SqlOpSelectBlock block=SqlOpSelectBlock.create(m.getSubOp());
        block.getProjection().put("String_Node_Str",new S_Constant(SqlValue.TRUE));
        block.getConditions().addAll(m.getConditions());
        block.setLimit(100l);
        block.setAliasName("String_Node_Str");
        SqlOpSelectBlock wrapper=SqlOpSelectBlock.create(block);
        wrapper.getProjection().put("String_Node_Str",new S_Agg(new S_AggCount()));
        ++id;
        String sqlQueryString=sqlOpSerializer.serialize(wrapper);
        logger.info("String_Node_Str" + sqlQueryString);
        long start=System.currentTimeMillis();
        long queryTimeOutInMillis=queryTimeOutInSeconds * 1000;
        boolean timeOut=true;
        Node resultSetSizeNode=null;
        Node errorMsgNode=null;
        boolean isError=false;
        Connection conn=null;
        java.sql.ResultSet sqlRs=null;
        long elapsedTimeInMillis=0;
        try {
          try {
            conn=dataSource.getConnection();
            conn.setAutoCommit(false);
            Statement stmt=QueryExecutionSelect.createStatement(conn);
            Thread thread=null;
            WatchDog watchDog=null;
            try {
              stmt.setQueryTimeout(queryTimeOutInSeconds);
            }
 catch (            Exception e) {
              logger.warn("String_Node_Str");
              watchDog=new WatchDog(stmt,queryTimeOutInMillis);
              thread=new Thread(watchDog);
              thread.start();
            }
            sqlRs=stmt.executeQuery(sqlQueryString);
            if (thread != null) {
              timeOut=false;
              watchDog.cancel();
            }
          }
  finally {
            long end=System.currentTimeMillis();
            elapsedTimeInMillis=end - start;
          }
          sqlRs.next();
          long resultSetSize=sqlRs.getLong("String_Node_Str");
          resultSetSizeNode=NodeValue.makeInteger(resultSetSize).asNode();
        }
 catch (        SQLTimeoutException e) {
          timeOut=true;
        }
catch (        Exception e) {
          String errorMsg=e.getMessage();
          errorMsgNode=NodeValue.makeString(errorMsg).asNode();
          isError=true;
          if (elapsedTimeInMillis >= queryTimeOutInSeconds) {
            timeOut=true;
          }
        }
 finally {
          if (sqlRs != null) {
            try {
              sqlRs.close();
            }
 catch (            SQLException e) {
              throw new RuntimeException(e);
            }
          }
          if (conn != null) {
            try {
              conn.close();
            }
 catch (            SQLException e) {
              throw new RuntimeException(e);
            }
          }
        }
        BindingHashMap binding=new BindingHashMap();
        binding.add(idVar,NodeValue.makeInteger(id).asNode());
        binding.add(executionTimeVar,NodeValue.makeInteger(elapsedTimeInMillis).asNode());
        binding.add(timeOutVar,NodeValue.makeBoolean(timeOut).asNode());
        binding.add(resultSetSizeVar,resultSetSizeNode);
        binding.add(isErrorVar,NodeValue.makeBoolean(isError).asNode());
        binding.add(errorMsgVar,errorMsgNode);
        binding.add(queryStringVar,NodeValue.makeString(sqlQueryString).asNode());
        resultBindings.add(binding);
      }
    }
  }
  QueryIterator queryIterator=new QueryIterPlainWrapper(resultBindings.iterator());
  ResultSet result=ResultSetFactory.create(queryIterator,resultVars);
  return result;
}