Program: 167087
Project: 167087
Buggy source:
private Iterator<Pair<E,Multimap<String,Object>>> elements(){
  Preconditions.checkState(this.replacedSteps.size() > 0,"String_Node_Str");
  Preconditions.checkState(this.replacedSteps.get(0).isGraphStep(),"String_Node_Str");
  Preconditions.checkState(SchemaTableTree.threadLocalAliasColumnNameMap.get().isEmpty(),"String_Node_Str");
  Preconditions.checkState(SchemaTableTree.threadLocalColumnNameAliasMap.get().isEmpty(),"String_Node_Str");
  Set<SchemaTableTree> rootSchemaTableTree=this.sqlgGraph.getGremlinParser().parse(this.replacedSteps);
  SqlgCompiledResultIterator<Pair<E,Multimap<String,Object>>> resultIterator=new SqlgCompiledResultIterator<>();
  for (  SchemaTableTree schemaTableTree : rootSchemaTableTree) {
    List<Pair<LinkedList<SchemaTableTree>,String>> sqlStatements=schemaTableTree.constructSql();
    try {
      for (      Pair<LinkedList<SchemaTableTree>,String> sqlPair : sqlStatements) {
        Connection conn=this.sqlgGraph.tx().getConnection();
        if (logger.isDebugEnabled()) {
          logger.debug(sqlPair.getRight());
        }
        try (PreparedStatement preparedStatement=conn.prepareStatement(sqlPair.getRight())){
          SqlgUtil.setParametersOnStatement(this.sqlgGraph,sqlPair.getLeft(),conn,preparedStatement,1);
          ResultSet resultSet=preparedStatement.executeQuery();
          ResultSetMetaData resultSetMetaData=resultSet.getMetaData();
          while (resultSet.next()) {
            Pair<E,Multimap<String,Object>> result=SqlgUtil.loadElementsLabeledAndEndElements(this.sqlgGraph,resultSetMetaData,resultSet,sqlPair.getLeft());
            resultIterator.add(result);
          }
        }
 catch (        Exception e) {
          throw new RuntimeException(e);
        }
      }
    }
  finally {
      schemaTableTree.resetThreadVars();
    }
  }
  return resultIterator;
}

Fixed version (ground truth):
private Iterator<Pair<E,Multimap<String,Object>>> elements(){
  Preconditions.checkState(this.replacedSteps.size() > 0,"String_Node_Str");
  Preconditions.checkState(this.replacedSteps.get(0).isGraphStep(),"String_Node_Str");
  Preconditions.checkState(SchemaTableTree.threadLocalAliasColumnNameMap.get().isEmpty(),"String_Node_Str");
  Preconditions.checkState(SchemaTableTree.threadLocalColumnNameAliasMap.get().isEmpty(),"String_Node_Str");
  Set<SchemaTableTree> rootSchemaTableTree=this.sqlgGraph.getGremlinParser().parse(this.replacedSteps);
  SqlgCompiledResultIterator<Pair<E,Multimap<String,Object>>> resultIterator=new SqlgCompiledResultIterator<>();
  for (  SchemaTableTree schemaTableTree : rootSchemaTableTree) {
    try {
      List<Pair<LinkedList<SchemaTableTree>,String>> sqlStatements=schemaTableTree.constructSql();
      for (      Pair<LinkedList<SchemaTableTree>,String> sqlPair : sqlStatements) {
        Connection conn=this.sqlgGraph.tx().getConnection();
        if (logger.isDebugEnabled()) {
          logger.debug(sqlPair.getRight());
        }
        try (PreparedStatement preparedStatement=conn.prepareStatement(sqlPair.getRight())){
          SqlgUtil.setParametersOnStatement(this.sqlgGraph,sqlPair.getLeft(),conn,preparedStatement,1);
          ResultSet resultSet=preparedStatement.executeQuery();
          ResultSetMetaData resultSetMetaData=resultSet.getMetaData();
          while (resultSet.next()) {
            Pair<E,Multimap<String,Object>> result=SqlgUtil.loadElementsLabeledAndEndElements(this.sqlgGraph,resultSetMetaData,resultSet,sqlPair.getLeft());
            resultIterator.add(result);
          }
        }
 catch (        Exception e) {
          throw new RuntimeException(e);
        }
      }
    }
  finally {
      schemaTableTree.resetThreadVars();
    }
  }
  rootSchemaTableTree.forEach(SchemaTableTree::resetThreadVars);
  return resultIterator;
}