Program: 132482
Project: 132482
Buggy source:
public void testPrefixLookup() throws Exception {
  final String[] keys={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  final String[] vals={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  SortedMap<byte[],byte[]> testMap=new TreeMap<byte[],byte[]>(COMP);
  for (int i=0; i < keys.length; i++)   testMap.put(keys[i].getBytes(),vals[i].getBytes());
  new File(PATH2).delete();
  DiskIndexWriter index=new DiskIndexWriter(PATH2,4);
  index.writeIndex(testMap.entrySet().iterator());
  DiskIndex diskIndex=new DiskIndex(PATH2,new DefaultByteRangeComparator());
  Iterator<Entry<byte[],byte[]>> it=diskIndex.rangeLookup(keys[1].getBytes(),keys[5].getBytes());
  for (int i=1; i < 5; i++) {
    Entry<byte[],byte[]> entry=it.next();
    assertEquals(keys[i],new String(entry.getKey()));
    assertEquals(vals[i],new String(entry.getValue()));
  }
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup("String_Node_Str".getBytes(),"String_Node_Str".getBytes());
  for (int i=1; i < 7; i++) {
    Entry<byte[],byte[]> entry=it.next();
    assertEquals(keys[i],new String(entry.getKey()));
    assertEquals(vals[i],new String(entry.getValue()));
  }
  assertFalse(it.hasNext());
}

Fixed version (ground truth):
public void testPrefixLookup() throws Exception {
  final String[] keys={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  final String[] vals={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  SortedMap<byte[],byte[]> testMap=new TreeMap<byte[],byte[]>(COMP);
  for (int i=0; i < keys.length; i++)   testMap.put(keys[i].getBytes(),vals[i].getBytes());
  new File(PATH2).delete();
  DiskIndexWriter index=new DiskIndexWriter(PATH2,4);
  index.writeIndex(testMap.entrySet().iterator());
  DiskIndex diskIndex=new DiskIndex(PATH2,new DefaultByteRangeComparator());
  Iterator<Entry<byte[],byte[]>> it=diskIndex.rangeLookup(keys[1].getBytes(),keys[5].getBytes());
  for (int i=1; i < 5; i++) {
    Entry<byte[],byte[]> entry=it.next();
    assertEquals(keys[i],new String(entry.getKey()));
    assertEquals(vals[i],new String(entry.getValue()));
  }
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup("String_Node_Str".getBytes(),"String_Node_Str".getBytes());
  for (int i=1; i < 7; i++) {
    Entry<byte[],byte[]> entry=it.next();
    assertEquals(keys[i],new String(entry.getKey()));
    assertEquals(vals[i],new String(entry.getValue()));
  }
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup("String_Node_Str".getBytes(),"String_Node_Str".getBytes());
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup("String_Node_Str".getBytes(),"String_Node_Str".getBytes());
  assertFalse(it.hasNext());
  index=new DiskIndexWriter(PATH1,4);
  index.writeIndex(new HashMap().entrySet().iterator());
  diskIndex=new DiskIndex(PATH1,new DefaultByteRangeComparator());
  it=diskIndex.rangeLookup(new byte[0],new byte[0]);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup(null,null);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup("String_Node_Str".getBytes(),null);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup(null,"String_Node_Str".getBytes());
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup("String_Node_Str".getBytes(),"String_Node_Str".getBytes());
  assertFalse(it.hasNext());
}