Program: 162776
Project: 162776
Buggy source:
/** 
 * Called by the framework to initiate a continuous process of reading models, and reading from the input topic and updating model state in memory, and issuing updates to the update topic. This will be executed asynchronously and may block.
 * @param updateIterator iterator to read models from
 * @throws IOException if an error occurs while reading updates
 */
@Override public void consume(Iterator<KeyMessage<String,String>> updateIterator) throws IOException {
  while (updateIterator.hasNext()) {
    KeyMessage<String,String> km=updateIterator.next();
    String key=km.getKey();
    String message=km.getMessage();
switch (key) {
case "String_Node_Str":
      if (model == null) {
        continue;
      }
    DecisionForest forest=model.getForest();
  List<?> update=MAPPER.readValue(message,List.class);
int treeID=Integer.parseInt(update.get(0).toString());
String nodeID=update.get(1).toString();
if (inputSchema.isClassification()) {
TerminalNode nodeToUpdate=(TerminalNode)forest.getTrees()[treeID].findByID(nodeID);
CategoricalPrediction predictionToUpdate=(CategoricalPrediction)nodeToUpdate.getPrediction();
int encoding=Integer.parseInt(update.get(2).toString());
int count=Integer.parseInt(update.get(3).toString());
predictionToUpdate.update(encoding,count);
}
 else {
TerminalNode nodeToUpdate=(TerminalNode)forest.getTrees()[treeID].findByID(nodeID);
NumericPrediction predictionToUpdate=(NumericPrediction)nodeToUpdate.getPrediction();
double mean=Double.parseDouble(update.get(2).toString());
int count=Integer.parseInt(update.get(3).toString());
predictionToUpdate.update(mean,count);
}
break;
case "String_Node_Str":
PMML pmml;
try {
pmml=PMMLUtils.fromString(message);
}
 catch (JAXBException e) {
throw new IOException(e);
}
RDFPMMLUtils.validatePMMLVsSchema(pmml,inputSchema);
Pair<DecisionForest,CategoricalValueEncodings> forestAndEncodings=RDFPMMLUtils.read(pmml);
model=new RDFServingModel(forestAndEncodings.getFirst(),forestAndEncodings.getSecond(),inputSchema);
break;
default :
throw new IllegalStateException("String_Node_Str" + key);
}
}
}

Fixed version (ground truth):
/** 
 * Called by the framework to initiate a continuous process of reading models, and reading from the input topic and updating model state in memory, and issuing updates to the update topic. This will be executed asynchronously and may block.
 * @param updateIterator iterator to read models from
 * @throws IOException if an error occurs while reading updates
 */
@Override public void consume(Iterator<KeyMessage<String,String>> updateIterator) throws IOException {
  while (updateIterator.hasNext()) {
    KeyMessage<String,String> km=updateIterator.next();
    String key=km.getKey();
    String message=km.getMessage();
switch (key) {
case "String_Node_Str":
      if (model == null) {
        continue;
      }
    DecisionForest forest=model.getForest();
  List<?> update=MAPPER.readValue(message,List.class);
int treeID=Integer.parseInt(update.get(0).toString());
String nodeID=update.get(1).toString();
if (inputSchema.isClassification()) {
TerminalNode nodeToUpdate=(TerminalNode)forest.getTrees()[treeID].findByID(nodeID);
CategoricalPrediction predictionToUpdate=(CategoricalPrediction)nodeToUpdate.getPrediction();
@SuppressWarnings("String_Node_Str") Map<Integer,Integer> counts=(Map<Integer,Integer>)update.get(2);
for (Map.Entry<?,?> entry : counts.entrySet()) {
int encoding=Integer.parseInt(entry.getKey().toString());
int count=Integer.parseInt(entry.getValue().toString());
predictionToUpdate.update(encoding,count);
}
}
 else {
TerminalNode nodeToUpdate=(TerminalNode)forest.getTrees()[treeID].findByID(nodeID);
NumericPrediction predictionToUpdate=(NumericPrediction)nodeToUpdate.getPrediction();
double mean=Double.parseDouble(update.get(2).toString());
int count=Integer.parseInt(update.get(3).toString());
predictionToUpdate.update(mean,count);
}
break;
case "String_Node_Str":
PMML pmml;
try {
pmml=PMMLUtils.fromString(message);
}
 catch (JAXBException e) {
throw new IOException(e);
}
RDFPMMLUtils.validatePMMLVsSchema(pmml,inputSchema);
Pair<DecisionForest,CategoricalValueEncodings> forestAndEncodings=RDFPMMLUtils.read(pmml);
model=new RDFServingModel(forestAndEncodings.getFirst(),forestAndEncodings.getSecond(),inputSchema);
break;
default :
throw new IllegalStateException("String_Node_Str" + key);
}
}
}