Program: 154896
Project: 154896
Buggy source:
private List<LogEntry> extractTransactionFromLog(long txId,long expectedVersion,ReadableByteChannel log) throws IOException {
  buffer.clear();
  buffer.limit(8);
  log.read(buffer);
  long versionInLog=buffer.getLong();
  assertExpectedVersion(expectedVersion,versionInLog);
  long prevTxId=buffer.getLong();
  assertLogCanContainTx(txId,prevTxId);
  List<LogEntry> logEntryList=null;
  Map<Integer,List<LogEntry>> transactions=new HashMap<Integer,List<LogEntry>>();
  while (logEntryList == null && fileChannel.read(buffer) != buffer.limit()) {
    buffer.flip();
    byte entry=buffer.get();
    LogEntry logEntry;
switch (entry) {
case LogEntry.TX_START:
      logEntry=LogIoUtils.readTxStartEntry(buffer,log,-1);
    List<LogEntry> list=new LinkedList<LogEntry>();
  list.add(logEntry);
transactions.put(logEntry.getIdentifier(),list);
break;
case LogEntry.TX_PREPARE:
logEntry=LogIoUtils.readTxPrepareEntry(buffer,log);
transactions.get(logEntry.getIdentifier()).add(logEntry);
break;
case LogEntry.TX_1P_COMMIT:
logEntry=LogIoUtils.readTxOnePhaseCommit(buffer,log);
if (((LogEntry.OnePhaseCommit)logEntry).getTxId() == txId) {
logEntryList=transactions.get(logEntry.getIdentifier());
logEntryList.add(logEntry);
}
 else {
transactions.remove(logEntry.getIdentifier());
}
break;
case LogEntry.TX_2P_COMMIT:
logEntry=LogIoUtils.readTxTwoPhaseCommit(buffer,log);
if (((LogEntry.TwoPhaseCommit)logEntry).getTxId() == txId) {
logEntryList=transactions.get(logEntry.getIdentifier());
logEntryList.add(logEntry);
}
 else {
transactions.remove(logEntry.getIdentifier());
}
break;
case LogEntry.COMMAND:
logEntry=LogIoUtils.readTxCommand(buffer,log,cf);
transactions.get(logEntry.getIdentifier()).add(logEntry);
break;
case LogEntry.DONE:
logEntry=LogIoUtils.readTxDoneEntry(buffer,log);
transactions.remove(logEntry.getIdentifier());
break;
default :
throw new IOException("String_Node_Str" + txId + "String_Node_Str");
}
buffer.clear();
buffer.limit(1);
}
if (logEntryList == null) {
throw new IOException("String_Node_Str" + txId + "String_Node_Str"+ expectedVersion+ "String_Node_Str"+ prevTxId+ "String_Node_Str");
}
return logEntryList;
}

Fixed version (ground truth):
private List<LogEntry> extractTransactionFromLog(long txId,long expectedVersion,ReadableByteChannel log) throws IOException {
  buffer.clear();
  buffer.limit(16);
  log.read(buffer);
  buffer.flip();
  long versionInLog=buffer.getLong();
  assertExpectedVersion(expectedVersion,versionInLog);
  long prevTxId=buffer.getLong();
  assertLogCanContainTx(txId,prevTxId);
  List<LogEntry> logEntryList=null;
  Map<Integer,List<LogEntry>> transactions=new HashMap<Integer,List<LogEntry>>();
  buffer.clear();
  while (logEntryList == null && fileChannel.read(buffer) != buffer.limit()) {
    buffer.flip();
    byte entry=buffer.get();
    LogEntry logEntry;
switch (entry) {
case LogEntry.TX_START:
      logEntry=LogIoUtils.readTxStartEntry(buffer,log,-1);
    List<LogEntry> list=new LinkedList<LogEntry>();
  list.add(logEntry);
transactions.put(logEntry.getIdentifier(),list);
break;
case LogEntry.TX_PREPARE:
logEntry=LogIoUtils.readTxPrepareEntry(buffer,log);
transactions.get(logEntry.getIdentifier()).add(logEntry);
break;
case LogEntry.TX_1P_COMMIT:
logEntry=LogIoUtils.readTxOnePhaseCommit(buffer,log);
if (((LogEntry.OnePhaseCommit)logEntry).getTxId() == txId) {
logEntryList=transactions.get(logEntry.getIdentifier());
logEntryList.add(logEntry);
}
 else {
transactions.remove(logEntry.getIdentifier());
}
break;
case LogEntry.TX_2P_COMMIT:
logEntry=LogIoUtils.readTxTwoPhaseCommit(buffer,log);
if (((LogEntry.TwoPhaseCommit)logEntry).getTxId() == txId) {
logEntryList=transactions.get(logEntry.getIdentifier());
logEntryList.add(logEntry);
}
 else {
transactions.remove(logEntry.getIdentifier());
}
break;
case LogEntry.COMMAND:
logEntry=LogIoUtils.readTxCommand(buffer,log,cf);
transactions.get(logEntry.getIdentifier()).add(logEntry);
break;
case LogEntry.DONE:
logEntry=LogIoUtils.readTxDoneEntry(buffer,log);
transactions.remove(logEntry.getIdentifier());
break;
default :
throw new IOException("String_Node_Str" + txId + "String_Node_Str");
}
buffer.clear();
buffer.limit(1);
}
if (logEntryList == null) {
throw new IOException("String_Node_Str" + txId + "String_Node_Str"+ expectedVersion+ "String_Node_Str"+ prevTxId+ "String_Node_Str");
}
return logEntryList;
}