Program: 31364
Project: 31364
Buggy source:
@SuppressWarnings("String_Node_Str") @SuppressFBWarnings({"String_Node_Str"}) private RecordSource compileSingleJournal(QueryModel model,JournalReaderFactory factory) throws JournalException, ParserException {
  RecordMetadata metadata=model.getMetadata();
  JournalMetadata journalMetadata;
  if (metadata == null) {
    journalMetadata=collectJournalMetadata(model,factory);
  }
 else   if (metadata instanceof JournalMetadata) {
    journalMetadata=(JournalMetadata)metadata;
  }
 else {
    throw QueryError.$(0,"String_Node_Str");
  }
  if (model.getAlias() != null) {
    journalMetadata.setAlias(model.getAlias().token);
  }
 else {
    journalMetadata.setAlias(model.getJournalName().token);
  }
  PartitionSource ps=new JournalPartitionSource(journalMetadata,true);
  RowSource rs=null;
  String latestByCol=null;
  RecordColumnMetadata latestByMetadata=null;
  ExprNode latestByNode=null;
  if (model.getLatestBy() != null) {
    latestByNode=model.getLatestBy();
    if (latestByNode.type != ExprNode.NodeType.LITERAL) {
      throw QueryError.$(latestByNode.position,"String_Node_Str");
    }
    int colIndex=journalMetadata.getColumnIndexQuiet(latestByNode.token);
    if (colIndex == -1) {
      throw QueryError.invalidColumn(latestByNode.position,latestByNode.token);
    }
    latestByMetadata=journalMetadata.getColumnQuick(colIndex);
    ColumnType type=latestByMetadata.getType();
    if (type != ColumnType.SYMBOL && type != ColumnType.STRING && type != ColumnType.INT) {
      throw QueryError.position(latestByNode.position).$("String_Node_Str").$(type).$();
    }
    if (!latestByMetadata.isIndexed()) {
      throw QueryError.position(latestByNode.position).$("String_Node_Str").$();
    }
    latestByCol=latestByNode.token;
  }
  ExprNode where=model.getWhereClause();
  if (where != null) {
    IntrinsicModel im=queryFilterAnalyser.extract(where,journalMetadata,latestByCol);
    VirtualColumn filter=im.filter != null ? virtualColumnBuilder.createVirtualColumn(model,im.filter,journalMetadata) : null;
    if (filter != null) {
      if (filter.getType() != ColumnType.BOOLEAN) {
        throw QueryError.$(im.filter.position,"String_Node_Str");
      }
      if (filter.isConstant()) {
        if (filter.getBool(null)) {
          filter=null;
        }
 else {
          im.intrinsicValue=IntrinsicValue.FALSE;
        }
      }
    }
    if (im.intrinsicValue == IntrinsicValue.FALSE) {
      ps=new NoOpJournalPartitionSource(journalMetadata);
    }
 else {
      if (im.intervalHi < Long.MAX_VALUE || im.intervalLo > Long.MIN_VALUE) {
        ps=new MultiIntervalPartitionSource(ps,new SingleIntervalSource(new Interval(im.intervalLo,im.intervalHi)));
      }
      if (im.intervalSource != null) {
        ps=new MultiIntervalPartitionSource(ps,im.intervalSource);
      }
      if (latestByCol == null) {
        if (im.keyColumn != null) {
switch (journalMetadata.getColumn(im.keyColumn).getType()) {
case SYMBOL:
            rs=buildRowSourceForSym(im);
          break;
case STRING:
        rs=buildRowSourceForStr(im);
      break;
case INT:
    rs=buildRowSourceForInt(im);
  break;
default :
break;
}
}
if (filter != null) {
rs=new FilteredRowSource(rs == null ? new AllRowSource() : rs,filter);
}
}
 else {
if (im.keyColumn != null && im.keyValuesIsLambda) {
int lambdaColIndex;
RecordSource lambda=compileSourceInternal(factory,im.keyValues.get(0));
RecordMetadata m=lambda.getMetadata();
switch (m.getColumnCount()) {
case 0:
throw QueryError.$(im.keyValuePositions.getQuick(0),"String_Node_Str");
case 1:
lambdaColIndex=0;
break;
default :
lambdaColIndex=m.getColumnIndexQuiet(latestByCol);
if (lambdaColIndex == -1) {
throw QueryError.$(im.keyValuePositions.getQuick(0),"String_Node_Str");
}
break;
}
ColumnType lambdaColType=m.getColumn(lambdaColIndex).getType();
mutableSig.setParamCount(2).setName("String_Node_Str").paramType(0,latestByMetadata.getType(),true).paramType(1,lambdaColType,false);
LatestByLambdaRowSourceFactory fact=LAMBDA_ROW_SOURCE_FACTORIES.get(mutableSig);
if (fact != null) {
rs=fact.newInstance(latestByCol,lambda,lambdaColIndex,filter);
}
 else {
throw QueryError.$(im.keyValuePositions.getQuick(0),"String_Node_Str");
}
}
 else {
switch (latestByMetadata.getType()) {
case SYMBOL:
if (im.keyColumn != null) {
rs=new KvIndexSymListHeadRowSource(latestByCol,new CharSequenceHashSet(im.keyValues),filter);
}
 else {
rs=new KvIndexSymAllHeadRowSource(latestByCol,filter);
}
break;
case STRING:
if (im.keyColumn != null) {
rs=new KvIndexStrListHeadRowSource(latestByCol,new CharSequenceHashSet(im.keyValues),filter);
}
 else {
throw QueryError.$(latestByNode.position,"String_Node_Str");
}
break;
case INT:
if (im.keyColumn != null) {
rs=new KvIndexIntListHeadRowSource(latestByCol,toIntHashSet(im),filter);
}
 else {
throw QueryError.$(latestByNode.position,"String_Node_Str");
}
break;
default :
break;
}
}
}
}
}
 else if (latestByCol != null) {
switch (latestByMetadata.getType()) {
case SYMBOL:
rs=new KvIndexSymAllHeadRowSource(latestByCol,null);
break;
default :
throw QueryError.$(latestByNode.position,"String_Node_Str");
}
}
return new JournalSource(ps,rs == null ? new AllRowSource() : rs);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @SuppressFBWarnings({"String_Node_Str"}) private RecordSource compileSingleJournal(QueryModel model,JournalReaderFactory factory) throws JournalException, ParserException {
  RecordMetadata metadata=model.getMetadata();
  JournalMetadata journalMetadata;
  if (metadata == null) {
    journalMetadata=collectJournalMetadata(model,factory);
  }
 else   if (metadata instanceof JournalMetadata) {
    journalMetadata=(JournalMetadata)metadata;
  }
 else {
    throw QueryError.$(0,"String_Node_Str");
  }
  if (model.getAlias() != null) {
    journalMetadata.setAlias(model.getAlias().token);
  }
 else {
    journalMetadata.setAlias(model.getJournalName().token);
  }
  PartitionSource ps=new JournalPartitionSource(journalMetadata,true);
  RowSource rs=null;
  String latestByCol=null;
  RecordColumnMetadata latestByMetadata=null;
  ExprNode latestByNode=null;
  if (model.getLatestBy() != null) {
    latestByNode=model.getLatestBy();
    if (latestByNode.type != ExprNode.NodeType.LITERAL) {
      throw QueryError.$(latestByNode.position,"String_Node_Str");
    }
    int colIndex=journalMetadata.getColumnIndexQuiet(latestByNode.token);
    if (colIndex == -1) {
      throw QueryError.invalidColumn(latestByNode.position,latestByNode.token);
    }
    latestByMetadata=journalMetadata.getColumnQuick(colIndex);
    ColumnType type=latestByMetadata.getType();
    if (type != ColumnType.SYMBOL && type != ColumnType.STRING && type != ColumnType.INT) {
      throw QueryError.position(latestByNode.position).$("String_Node_Str").$(type).$();
    }
    if (!latestByMetadata.isIndexed()) {
      throw QueryError.position(latestByNode.position).$("String_Node_Str").$();
    }
    latestByCol=latestByNode.token;
  }
  ExprNode where=model.getWhereClause();
  if (where != null) {
    IntrinsicModel im=queryFilterAnalyser.extract(where,journalMetadata,latestByCol);
    VirtualColumn filter=im.filter != null ? virtualColumnBuilder.createVirtualColumn(model,im.filter,journalMetadata) : null;
    if (filter != null) {
      if (filter.getType() != ColumnType.BOOLEAN) {
        throw QueryError.$(im.filter.position,"String_Node_Str");
      }
      if (filter.isConstant()) {
        if (filter.getBool(null)) {
          filter=null;
        }
 else {
          im.intrinsicValue=IntrinsicValue.FALSE;
        }
      }
    }
    if (im.intrinsicValue == IntrinsicValue.FALSE) {
      ps=new NoOpJournalPartitionSource(journalMetadata);
    }
 else {
      if (im.intervalHi < Long.MAX_VALUE || im.intervalLo > Long.MIN_VALUE) {
        ps=new MultiIntervalPartitionSource(ps,new SingleIntervalSource(new Interval(im.intervalLo,im.intervalHi)));
      }
      if (im.intervalSource != null) {
        ps=new MultiIntervalPartitionSource(ps,im.intervalSource);
      }
      if (latestByCol == null) {
        if (im.keyColumn != null) {
switch (journalMetadata.getColumn(im.keyColumn).getType()) {
case SYMBOL:
            rs=buildRowSourceForSym(im);
          break;
case STRING:
        rs=buildRowSourceForStr(im);
      break;
case INT:
    rs=buildRowSourceForInt(im);
  break;
default :
break;
}
}
if (filter != null) {
rs=new FilteredRowSource(rs == null ? new AllRowSource() : rs,filter);
}
}
 else {
if (im.keyColumn != null && im.keyValuesIsLambda) {
int lambdaColIndex;
RecordSource lambda=compileSourceInternal(factory,im.keyValues.get(0));
RecordMetadata m=lambda.getMetadata();
switch (m.getColumnCount()) {
case 0:
throw QueryError.$(im.keyValuePositions.getQuick(0),"String_Node_Str");
case 1:
lambdaColIndex=0;
break;
default :
lambdaColIndex=m.getColumnIndexQuiet(latestByCol);
if (lambdaColIndex == -1) {
throw QueryError.$(im.keyValuePositions.getQuick(0),"String_Node_Str");
}
break;
}
ColumnType lambdaColType=m.getColumn(lambdaColIndex).getType();
mutableSig.setParamCount(2).setName("String_Node_Str").paramType(0,latestByMetadata.getType(),true).paramType(1,lambdaColType,false);
LatestByLambdaRowSourceFactory fact=LAMBDA_ROW_SOURCE_FACTORIES.get(mutableSig);
if (fact != null) {
rs=fact.newInstance(latestByCol,lambda,lambdaColIndex,filter);
}
 else {
throw QueryError.$(im.keyValuePositions.getQuick(0),"String_Node_Str");
}
}
 else {
switch (latestByMetadata.getType()) {
case SYMBOL:
if (im.keyColumn != null) {
rs=new KvIndexSymListHeadRowSource(latestByCol,new CharSequenceHashSet(im.keyValues),filter);
}
 else {
rs=new KvIndexSymAllHeadRowSource(latestByCol,filter);
}
break;
case STRING:
if (im.keyColumn != null) {
rs=new KvIndexStrListHeadRowSource(latestByCol,new CharSequenceHashSet(im.keyValues),filter);
}
 else {
throw QueryError.$(latestByNode.position,"String_Node_Str");
}
break;
case INT:
if (im.keyColumn != null) {
rs=new KvIndexIntListHeadRowSource(latestByCol,toIntHashSet(im),filter);
}
 else {
throw QueryError.$(latestByNode.position,"String_Node_Str");
}
break;
default :
break;
}
}
}
}
}
 else if (latestByCol != null) {
switch (latestByMetadata.getType()) {
case SYMBOL:
rs=new KvIndexSymAllHeadRowSource(latestByCol,null);
break;
default :
throw QueryError.$(latestByNode.position,"String_Node_Str");
}
}
if (rs == null && model.getColumns().size() == 1) {
QueryColumn qc=model.getColumns().getQuick(0);
if ("String_Node_Str".equals(qc.getAst().token) && qc.getAst().paramCount == 0) {
model.getOrderBy().clear();
model.getColumns().clear();
return new CountRecordSource(qc.getAlias() == null ? "String_Node_Str" : qc.getAlias(),ps);
}
}
return new JournalSource(ps,rs == null ? new AllRowSource() : rs);
}