Program: 167030
Project: 167030
Buggy source:
private Iterator<Vertex> internalGetVertices(List<HasContainer> hasContainers,Direction direction,String... labels){
  if (this.sqlgGraph.features().supportsBatchMode() && this.sqlgGraph.tx().isInBatchMode() && this.sqlgGraph.tx().getBatchManager().vertexIsCached(this)) {
    List<Vertex> vertices=this.sqlgGraph.tx().getBatchManager().getVertices(this,direction,labels);
    return vertices.stream().filter(v -> HasContainer.testAll(v,hasContainers)).iterator();
  }
 else {
    List<Vertex> vertices=new ArrayList<>();
    List<HasContainer> labelHasContainers=filterHasContainerOnKey(hasContainers,T.label.getAccessor());
    Set<String> hasContainerLabels=extractLabelsFromHasContainer(labelHasContainers);
    List<Direction> directions=new ArrayList<>(2);
    Set<SchemaTable> inVertexLabels=new HashSet<>();
    Set<SchemaTable> outVertexLabels=new HashSet<>();
    if (direction == Direction.IN) {
      inVertexLabels.addAll(this.sqlgGraph.getSchemaManager().getTableLabels(this.getSchemaTablePrefixed()).getLeft());
      if (labels.length > 0) {
        retainLabels(inVertexLabels,labels);
      }
      directions.add(direction);
    }
 else     if (direction == Direction.OUT) {
      outVertexLabels.addAll(this.sqlgGraph.getSchemaManager().getTableLabels(this.getSchemaTablePrefixed()).getRight());
      if (labels.length > 0) {
        retainLabels(outVertexLabels,labels);
      }
      directions.add(direction);
    }
 else {
      inVertexLabels.addAll(this.sqlgGraph.getSchemaManager().getTableLabels(this.getSchemaTablePrefixed()).getLeft());
      outVertexLabels.addAll(this.sqlgGraph.getSchemaManager().getTableLabels(this.getSchemaTablePrefixed()).getRight());
      if (labels.length > 0) {
        retainLabels(inVertexLabels,labels);
        retainLabels(outVertexLabels,labels);
      }
      directions.add(Direction.IN);
      directions.add(Direction.OUT);
    }
    for (    Direction d : directions) {
      for (      SchemaTable schemaTable : (d == Direction.IN ? inVertexLabels : outVertexLabels)) {
        Set<String> edgeForeignKeys=this.sqlgGraph.getSchemaManager().getEdgeForeignKeys(schemaTable.getSchema() + "String_Node_Str" + schemaTable.getTable());
        Set<SchemaTable> tables;
switch (d) {
case IN:
          tables=transformToOutSchemaTables(edgeForeignKeys,hasContainerLabels);
        break;
case OUT:
      tables=transformToInSchemaTables(edgeForeignKeys,hasContainerLabels);
    break;
default :
  throw new IllegalStateException(BUG_DIRECTION_BOTH_SHOULD_NEVER_FIRE_HERE);
}
for (SchemaTable joinSchemaTable : tables) {
StringBuilder sql=new StringBuilder("String_Node_Str");
sql.append("String_Node_Str");
switch (d) {
case IN:
  sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(joinSchemaTable.getSchema() + "String_Node_Str" + joinSchemaTable.getTable()+ SchemaManager.OUT_VERTEX_COLUMN_END));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(schemaTable.getSchema()));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(schemaTable.getTable()));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(joinSchemaTable.getSchema()));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(SchemaManager.VERTEX_PREFIX + joinSchemaTable.getTable()));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(joinSchemaTable.getSchema() + "String_Node_Str" + joinSchemaTable.getTable()+ SchemaManager.OUT_VERTEX_COLUMN_END));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(this.schema + "String_Node_Str" + this.table+ SchemaManager.IN_VERTEX_COLUMN_END));
sql.append("String_Node_Str");
for (HasContainer hasContainer : hasContainers) {
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(this.sqlgGraph.getSqlDialect().hasContainerKeyToColumn(hasContainer.getKey())));
if (!hasContainer.getBiPredicate().equals(Compare.eq)) {
throw new IllegalStateException("String_Node_Str");
}
sql.append("String_Node_Str");
}
break;
case OUT:
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(joinSchemaTable.getSchema() + "String_Node_Str" + joinSchemaTable.getTable()+ SchemaManager.IN_VERTEX_COLUMN_END));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(schemaTable.getSchema()));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(schemaTable.getTable()));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(joinSchemaTable.getSchema()));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(SchemaManager.VERTEX_PREFIX + joinSchemaTable.getTable()));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(joinSchemaTable.getSchema() + "String_Node_Str" + joinSchemaTable.getTable()+ SchemaManager.IN_VERTEX_COLUMN_END));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(this.schema + "String_Node_Str" + this.table+ SchemaManager.OUT_VERTEX_COLUMN_END));
sql.append("String_Node_Str");
for (HasContainer hasContainer : hasContainers) {
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(this.sqlgGraph.getSqlDialect().hasContainerKeyToColumn(hasContainer.getKey())));
if (!hasContainer.getBiPredicate().equals(Compare.eq)) {
throw new IllegalStateException("String_Node_Str");
}
sql.append("String_Node_Str");
}
break;
default :
throw new IllegalStateException(BUG_DIRECTION_BOTH_SHOULD_NEVER_FIRE_HERE);
}
if (this.sqlgGraph.getSqlDialect().needsSemicolon()) {
sql.append("String_Node_Str");
}
Connection conn=this.sqlgGraph.tx().getConnection();
if (logger.isDebugEnabled()) {
logger.debug(sql.toString());
}
try (PreparedStatement preparedStatement=conn.prepareStatement(sql.toString())){
switch (d) {
case IN:
preparedStatement.setLong(1,this.recordId.getId());
break;
case OUT:
preparedStatement.setLong(1,this.recordId.getId());
break;
case BOTH:
throw new IllegalStateException(BUG_DIRECTION_BOTH_SHOULD_NEVER_FIRE_HERE);
}
int countHasContainers=2;
for (HasContainer hasContainer : hasContainers) {
if (!hasContainer.getBiPredicate().equals(Compare.eq)) {
throw new IllegalStateException("String_Node_Str");
}
Map<String,Object> keyValues=new HashMap<>();
keyValues.put(hasContainer.getKey(),hasContainer.getValue());
SqlgUtil.setKeyValuesAsParameter(this.sqlgGraph,countHasContainers++,conn,preparedStatement,keyValues);
}
ResultSet resultSet=preparedStatement.executeQuery();
while (resultSet.next()) {
Set<String> inVertexColumnNames=new HashSet<>();
Set<String> outVertexColumnNames=new HashSet<>();
String inVertexColumnName="String_Node_Str";
String outVertexColumnName="String_Node_Str";
ResultSetMetaData resultSetMetaData=resultSet.getMetaData();
for (int i=1; i <= resultSetMetaData.getColumnCount(); i++) {
String columnName=resultSetMetaData.getColumnLabel(i);
if (columnName.endsWith(SchemaManager.IN_VERTEX_COLUMN_END)) {
inVertexColumnNames.add(columnName);
}
 else if (columnName.endsWith(SchemaManager.OUT_VERTEX_COLUMN_END)) {
outVertexColumnNames.add(columnName);
}
}
if (inVertexColumnNames.isEmpty() && outVertexColumnNames.isEmpty()) {
throw new IllegalStateException("String_Node_Str");
}
Long inId=null;
Long outId=null;
for (String inColumnName : inVertexColumnNames) {
if (inId != null) {
resultSet.getLong(inColumnName);
if (!resultSet.wasNull()) {
throw new IllegalStateException("String_Node_Str");
}
}
 else {
Long tempInId=resultSet.getLong(inColumnName);
if (!resultSet.wasNull()) {
inId=tempInId;
inVertexColumnName=inColumnName;
}
}
}
for (String outColumnName : outVertexColumnNames) {
if (outId != null) {
resultSet.getLong(outColumnName);
if (!resultSet.wasNull()) {
throw new IllegalStateException("String_Node_Str");
}
}
 else {
Long tempOutId=resultSet.getLong(outColumnName);
if (!resultSet.wasNull()) {
outId=tempOutId;
outVertexColumnName=outColumnName;
}
}
}
if (inVertexColumnName.isEmpty() && outVertexColumnName.isEmpty()) {
throw new IllegalStateException("String_Node_Str");
}
List<Object> keyValues=new ArrayList<>();
for (int i=1; i <= resultSetMetaData.getColumnCount(); i++) {
String columnName=resultSetMetaData.getColumnLabel(i);
if (!(columnName.equals("String_Node_Str") || inVertexColumnNames.contains(columnName) || outVertexColumnNames.contains(columnName))) {
Object object=resultSet.getObject(columnName);
if (object != null) {
keyValues.add(columnName);
keyValues.add(object);
}
}
}
SqlgVertex sqlGVertex;
switch (d) {
case IN:
sqlGVertex=SqlgVertex.of(this.sqlgGraph,outId,joinSchemaTable.getSchema(),joinSchemaTable.getTable());
Map<String,Object> keyValueMap=SqlgUtil.transformToInsertValues(keyValues.toArray());
sqlGVertex.properties.clear();
sqlGVertex.properties.putAll(keyValueMap);
vertices.add(sqlGVertex);
break;
case OUT:
sqlGVertex=SqlgVertex.of(this.sqlgGraph,inId,joinSchemaTable.getSchema(),joinSchemaTable.getTable());
keyValueMap=SqlgUtil.transformToInsertValues(keyValues.toArray());
sqlGVertex.properties.clear();
sqlGVertex.properties.putAll(keyValueMap);
vertices.add(sqlGVertex);
break;
case BOTH:
throw new IllegalStateException("String_Node_Str");
}
}
}
 catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
}
return vertices.iterator();
}
}

Fixed version (ground truth):
private Iterator<Vertex> internalGetVertices(List<HasContainer> hasContainers,Direction direction,String... labels){
  if (this.sqlgGraph.features().supportsBatchMode() && this.sqlgGraph.tx().isInBatchMode() && this.sqlgGraph.tx().getBatchManager().vertexIsCached(this)) {
    this.sqlgGraph.tx().flush();
  }
  List<Vertex> vertices=new ArrayList<>();
  List<HasContainer> labelHasContainers=filterHasContainerOnKey(hasContainers,T.label.getAccessor());
  Set<String> hasContainerLabels=extractLabelsFromHasContainer(labelHasContainers);
  List<Direction> directions=new ArrayList<>(2);
  Set<SchemaTable> inVertexLabels=new HashSet<>();
  Set<SchemaTable> outVertexLabels=new HashSet<>();
  if (direction == Direction.IN) {
    inVertexLabels.addAll(this.sqlgGraph.getSchemaManager().getTableLabels(this.getSchemaTablePrefixed()).getLeft());
    if (labels.length > 0) {
      retainLabels(inVertexLabels,labels);
    }
    directions.add(direction);
  }
 else   if (direction == Direction.OUT) {
    outVertexLabels.addAll(this.sqlgGraph.getSchemaManager().getTableLabels(this.getSchemaTablePrefixed()).getRight());
    if (labels.length > 0) {
      retainLabels(outVertexLabels,labels);
    }
    directions.add(direction);
  }
 else {
    inVertexLabels.addAll(this.sqlgGraph.getSchemaManager().getTableLabels(this.getSchemaTablePrefixed()).getLeft());
    outVertexLabels.addAll(this.sqlgGraph.getSchemaManager().getTableLabels(this.getSchemaTablePrefixed()).getRight());
    if (labels.length > 0) {
      retainLabels(inVertexLabels,labels);
      retainLabels(outVertexLabels,labels);
    }
    directions.add(Direction.IN);
    directions.add(Direction.OUT);
  }
  for (  Direction d : directions) {
    for (    SchemaTable schemaTable : (d == Direction.IN ? inVertexLabels : outVertexLabels)) {
      Set<String> edgeForeignKeys=this.sqlgGraph.getSchemaManager().getEdgeForeignKeys(schemaTable.getSchema() + "String_Node_Str" + schemaTable.getTable());
      Set<SchemaTable> tables;
switch (d) {
case IN:
        tables=transformToOutSchemaTables(edgeForeignKeys,hasContainerLabels);
      break;
case OUT:
    tables=transformToInSchemaTables(edgeForeignKeys,hasContainerLabels);
  break;
default :
throw new IllegalStateException(BUG_DIRECTION_BOTH_SHOULD_NEVER_FIRE_HERE);
}
for (SchemaTable joinSchemaTable : tables) {
StringBuilder sql=new StringBuilder("String_Node_Str");
sql.append("String_Node_Str");
switch (d) {
case IN:
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(joinSchemaTable.getSchema() + "String_Node_Str" + joinSchemaTable.getTable()+ SchemaManager.OUT_VERTEX_COLUMN_END));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(schemaTable.getSchema()));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(schemaTable.getTable()));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(joinSchemaTable.getSchema()));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(SchemaManager.VERTEX_PREFIX + joinSchemaTable.getTable()));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(joinSchemaTable.getSchema() + "String_Node_Str" + joinSchemaTable.getTable()+ SchemaManager.OUT_VERTEX_COLUMN_END));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(this.schema + "String_Node_Str" + this.table+ SchemaManager.IN_VERTEX_COLUMN_END));
sql.append("String_Node_Str");
for (HasContainer hasContainer : hasContainers) {
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(this.sqlgGraph.getSqlDialect().hasContainerKeyToColumn(hasContainer.getKey())));
if (!hasContainer.getBiPredicate().equals(Compare.eq)) {
throw new IllegalStateException("String_Node_Str");
}
sql.append("String_Node_Str");
}
break;
case OUT:
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(joinSchemaTable.getSchema() + "String_Node_Str" + joinSchemaTable.getTable()+ SchemaManager.IN_VERTEX_COLUMN_END));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(schemaTable.getSchema()));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(schemaTable.getTable()));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(joinSchemaTable.getSchema()));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(SchemaManager.VERTEX_PREFIX + joinSchemaTable.getTable()));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(joinSchemaTable.getSchema() + "String_Node_Str" + joinSchemaTable.getTable()+ SchemaManager.IN_VERTEX_COLUMN_END));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes("String_Node_Str"));
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(this.schema + "String_Node_Str" + this.table+ SchemaManager.OUT_VERTEX_COLUMN_END));
sql.append("String_Node_Str");
for (HasContainer hasContainer : hasContainers) {
sql.append("String_Node_Str");
sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(this.sqlgGraph.getSqlDialect().hasContainerKeyToColumn(hasContainer.getKey())));
if (!hasContainer.getBiPredicate().equals(Compare.eq)) {
throw new IllegalStateException("String_Node_Str");
}
sql.append("String_Node_Str");
}
break;
default :
throw new IllegalStateException(BUG_DIRECTION_BOTH_SHOULD_NEVER_FIRE_HERE);
}
if (this.sqlgGraph.getSqlDialect().needsSemicolon()) {
sql.append("String_Node_Str");
}
Connection conn=this.sqlgGraph.tx().getConnection();
if (logger.isDebugEnabled()) {
logger.debug(sql.toString());
}
try (PreparedStatement preparedStatement=conn.prepareStatement(sql.toString())){
switch (d) {
case IN:
preparedStatement.setLong(1,this.recordId.getId());
break;
case OUT:
preparedStatement.setLong(1,this.recordId.getId());
break;
case BOTH:
throw new IllegalStateException(BUG_DIRECTION_BOTH_SHOULD_NEVER_FIRE_HERE);
}
int countHasContainers=2;
for (HasContainer hasContainer : hasContainers) {
if (!hasContainer.getBiPredicate().equals(Compare.eq)) {
throw new IllegalStateException("String_Node_Str");
}
Map<String,Object> keyValues=new HashMap<>();
keyValues.put(hasContainer.getKey(),hasContainer.getValue());
SqlgUtil.setKeyValuesAsParameter(this.sqlgGraph,countHasContainers++,conn,preparedStatement,keyValues);
}
ResultSet resultSet=preparedStatement.executeQuery();
while (resultSet.next()) {
Set<String> inVertexColumnNames=new HashSet<>();
Set<String> outVertexColumnNames=new HashSet<>();
String inVertexColumnName="String_Node_Str";
String outVertexColumnName="String_Node_Str";
ResultSetMetaData resultSetMetaData=resultSet.getMetaData();
for (int i=1; i <= resultSetMetaData.getColumnCount(); i++) {
String columnName=resultSetMetaData.getColumnLabel(i);
if (columnName.endsWith(SchemaManager.IN_VERTEX_COLUMN_END)) {
inVertexColumnNames.add(columnName);
}
 else if (columnName.endsWith(SchemaManager.OUT_VERTEX_COLUMN_END)) {
outVertexColumnNames.add(columnName);
}
}
if (inVertexColumnNames.isEmpty() && outVertexColumnNames.isEmpty()) {
throw new IllegalStateException("String_Node_Str");
}
Long inId=null;
Long outId=null;
for (String inColumnName : inVertexColumnNames) {
if (inId != null) {
resultSet.getLong(inColumnName);
if (!resultSet.wasNull()) {
throw new IllegalStateException("String_Node_Str");
}
}
 else {
Long tempInId=resultSet.getLong(inColumnName);
if (!resultSet.wasNull()) {
inId=tempInId;
inVertexColumnName=inColumnName;
}
}
}
for (String outColumnName : outVertexColumnNames) {
if (outId != null) {
resultSet.getLong(outColumnName);
if (!resultSet.wasNull()) {
throw new IllegalStateException("String_Node_Str");
}
}
 else {
Long tempOutId=resultSet.getLong(outColumnName);
if (!resultSet.wasNull()) {
outId=tempOutId;
outVertexColumnName=outColumnName;
}
}
}
if (inVertexColumnName.isEmpty() && outVertexColumnName.isEmpty()) {
throw new IllegalStateException("String_Node_Str");
}
List<Object> keyValues=new ArrayList<>();
for (int i=1; i <= resultSetMetaData.getColumnCount(); i++) {
String columnName=resultSetMetaData.getColumnLabel(i);
if (!(columnName.equals("String_Node_Str") || inVertexColumnNames.contains(columnName) || outVertexColumnNames.contains(columnName))) {
Object object=resultSet.getObject(columnName);
if (object != null) {
keyValues.add(columnName);
keyValues.add(object);
}
}
}
SqlgVertex sqlGVertex;
switch (d) {
case IN:
sqlGVertex=SqlgVertex.of(this.sqlgGraph,outId,joinSchemaTable.getSchema(),joinSchemaTable.getTable());
Map<String,Object> keyValueMap=SqlgUtil.transformToInsertValues(keyValues.toArray());
sqlGVertex.properties.clear();
sqlGVertex.properties.putAll(keyValueMap);
vertices.add(sqlGVertex);
break;
case OUT:
sqlGVertex=SqlgVertex.of(this.sqlgGraph,inId,joinSchemaTable.getSchema(),joinSchemaTable.getTable());
keyValueMap=SqlgUtil.transformToInsertValues(keyValues.toArray());
sqlGVertex.properties.clear();
sqlGVertex.properties.putAll(keyValueMap);
vertices.add(sqlGVertex);
break;
case BOTH:
throw new IllegalStateException("String_Node_Str");
}
}
}
 catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
}
return vertices.iterator();
}