Program: 31102
Project: 31102
Buggy source:
@SuppressWarnings("String_Node_Str") private RecordSource compileJournal0(QueryModel model,JournalReaderFactory factory) throws ParserException {
  applyLimit(model);
  RecordMetadata metadata=model.getMetadata();
  JournalMetadata journalMetadata;
  if (metadata == null) {
    metadata=model.collectJournalMetadata(factory);
  }
  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(QueryModel.stripMarker(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.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);
    int type=latestByMetadata.getType();
    if (type != ColumnType.SYMBOL && type != ColumnType.STRING && type != ColumnType.INT && type != ColumnType.LONG) {
      throw QueryError.position(latestByNode.position).$("String_Node_Str").$(ColumnType.nameOf(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,getTimestampIndexQuiet(model.getTimestamp(),journalMetadata));
    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 ColumnType.SYMBOL:
            rs=buildRowSourceForSym(im);
          break;
case ColumnType.STRING:
        rs=buildRowSourceForStr(im);
      break;
case ColumnType.INT:
    rs=buildRowSourceForInt(im);
  break;
case ColumnType.LONG:
rs=buildRowSourceForLong(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:
Misc.free(lambda);
throw QueryError.$(im.keyValuePositions.getQuick(0),"String_Node_Str");
case 1:
lambdaColIndex=0;
break;
default :
lambdaColIndex=m.getColumnIndexQuiet(latestByCol);
if (lambdaColIndex == -1) {
Misc.free(lambda);
throw QueryError.$(im.keyValuePositions.getQuick(0),"String_Node_Str");
}
break;
}
int 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 {
Misc.free(lambda);
throw QueryError.$(im.keyValuePositions.getQuick(0),"String_Node_Str");
}
}
 else {
switch (latestByMetadata.getType()) {
case ColumnType.SYMBOL:
if (im.keyColumn != null) {
rs=new KvIndexSymListHeadRowSource(latestByCol,new CharSequenceHashSet(im.keyValues),filter);
}
 else {
rs=new KvIndexSymAllHeadRowSource(latestByCol,filter);
}
break;
case ColumnType.STRING:
if (im.keyColumn != null) {
rs=new KvIndexStrListHeadRowSource(latestByCol,new CharSequenceHashSet(im.keyValues),filter);
}
 else {
Misc.free(rs);
throw QueryError.$(latestByNode.position,"String_Node_Str");
}
break;
case ColumnType.LONG:
if (im.keyColumn != null) {
rs=new KvIndexLongListHeadRowSource(latestByCol,toLongHashSet(im),filter);
}
 else {
Misc.free(rs);
throw QueryError.$(latestByNode.position,"String_Node_Str");
}
break;
case ColumnType.INT:
if (im.keyColumn != null) {
rs=new KvIndexIntListHeadRowSource(latestByCol,toIntHashSet(im),filter);
}
 else {
Misc.free(rs);
throw QueryError.$(latestByNode.position,"String_Node_Str");
}
break;
default :
break;
}
}
}
}
}
 else if (latestByCol != null) {
switch (latestByMetadata.getType()) {
case ColumnType.SYMBOL:
rs=new KvIndexSymAllHeadRowSource(latestByCol,null);
break;
default :
Misc.free(rs);
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);
}
}
RecordSource recordSource=new JournalRecordSource(ps,rs == null ? new AllRowSource() : rs);
if (QueryModel.hasMarker(model.getJournalName().token)) {
return new NoRowIdRecordSource().of(recordSource);
}
return recordSource;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private RecordSource compileJournal0(QueryModel model,JournalReaderFactory factory) throws ParserException {
  applyLimit(model);
  RecordMetadata metadata=model.getMetadata();
  JournalMetadata journalMetadata;
  if (metadata == null) {
    metadata=model.collectJournalMetadata(factory);
  }
  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(QueryModel.stripMarker(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.LITERAL) {
      throw QueryError.$(latestByNode.position,"String_Node_Str");
    }
    latestByCol=model.translateAlias(latestByNode.token).toString();
    int colIndex=journalMetadata.getColumnIndexQuiet(latestByCol);
    if (colIndex == -1) {
      throw QueryError.invalidColumn(latestByNode.position,latestByNode.token);
    }
    latestByMetadata=journalMetadata.getColumnQuick(colIndex);
    int type=latestByMetadata.getType();
    if (type != ColumnType.SYMBOL && type != ColumnType.STRING && type != ColumnType.INT && type != ColumnType.LONG) {
      throw QueryError.position(latestByNode.position).$("String_Node_Str").$(ColumnType.nameOf(type)).$();
    }
    if (!latestByMetadata.isIndexed()) {
      throw QueryError.position(latestByNode.position).$("String_Node_Str").$();
    }
  }
  ExprNode where=model.getWhereClause();
  if (where != null) {
    IntrinsicModel im=queryFilterAnalyser.extract(model,where,journalMetadata,latestByCol,getTimestampIndexQuiet(model.getTimestamp(),journalMetadata));
    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 ColumnType.SYMBOL:
            rs=buildRowSourceForSym(im);
          break;
case ColumnType.STRING:
        rs=buildRowSourceForStr(im);
      break;
case ColumnType.INT:
    rs=buildRowSourceForInt(im);
  break;
case ColumnType.LONG:
rs=buildRowSourceForLong(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:
Misc.free(lambda);
throw QueryError.$(im.keyValuePositions.getQuick(0),"String_Node_Str");
case 1:
lambdaColIndex=0;
break;
default :
lambdaColIndex=m.getColumnIndexQuiet(latestByCol);
if (lambdaColIndex == -1) {
Misc.free(lambda);
throw QueryError.$(im.keyValuePositions.getQuick(0),"String_Node_Str");
}
break;
}
int 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 {
Misc.free(lambda);
throw QueryError.$(im.keyValuePositions.getQuick(0),"String_Node_Str");
}
}
 else {
switch (latestByMetadata.getType()) {
case ColumnType.SYMBOL:
if (im.keyColumn != null) {
rs=new KvIndexSymListHeadRowSource(latestByCol,new CharSequenceHashSet(im.keyValues),filter);
}
 else {
rs=new KvIndexSymAllHeadRowSource(latestByCol,filter);
}
break;
case ColumnType.STRING:
if (im.keyColumn != null) {
rs=new KvIndexStrListHeadRowSource(latestByCol,new CharSequenceHashSet(im.keyValues),filter);
}
 else {
Misc.free(rs);
throw QueryError.$(latestByNode.position,"String_Node_Str");
}
break;
case ColumnType.LONG:
if (im.keyColumn != null) {
rs=new KvIndexLongListHeadRowSource(latestByCol,toLongHashSet(im),filter);
}
 else {
Misc.free(rs);
throw QueryError.$(latestByNode.position,"String_Node_Str");
}
break;
case ColumnType.INT:
if (im.keyColumn != null) {
rs=new KvIndexIntListHeadRowSource(latestByCol,toIntHashSet(im),filter);
}
 else {
Misc.free(rs);
throw QueryError.$(latestByNode.position,"String_Node_Str");
}
break;
default :
break;
}
}
}
}
}
 else if (latestByCol != null) {
switch (latestByMetadata.getType()) {
case ColumnType.SYMBOL:
rs=new KvIndexSymAllHeadRowSource(latestByCol,null);
break;
default :
Misc.free(rs);
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);
}
}
RecordSource recordSource=new JournalRecordSource(ps,rs == null ? new AllRowSource() : rs);
if (QueryModel.hasMarker(model.getJournalName().token)) {
return new NoRowIdRecordSource().of(recordSource);
}
return recordSource;
}