Program: 132380
Project: 132380
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,COMPRESSED);
  index.writeIndex(testMap.entrySet().iterator());
  DiskIndex diskIndex=new DiskIndex(PATH2,new DefaultByteRangeComparator(),COMPRESSED);
  Iterator<Entry<byte[],byte[]>> it=diskIndex.rangeLookup(keys[1].getBytes(),keys[5].getBytes(),true);
  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(),true);
  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(),true);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup("String_Node_Str".getBytes(),"String_Node_Str".getBytes(),true);
  assertFalse(it.hasNext());
  index=new DiskIndexWriter(PATH1,4,COMPRESSED);
  index.writeIndex(new HashMap().entrySet().iterator());
  diskIndex=new DiskIndex(PATH1,new DefaultByteRangeComparator(),COMPRESSED);
  it=diskIndex.rangeLookup(new byte[0],new byte[0],true);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup(null,null,true);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup("String_Node_Str".getBytes(),null,true);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup(null,"String_Node_Str".getBytes(),true);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup("String_Node_Str".getBytes(),"String_Node_Str".getBytes(),true);
  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,COMPRESSED);
  index.writeIndex(testMap.entrySet().iterator());
  DiskIndex diskIndex=new DiskIndex(PATH2,new DefaultByteRangeComparator(),COMPRESSED);
  Iterator<Entry<byte[],byte[]>> it=diskIndex.rangeLookup("String_Node_Str".getBytes(),"String_Node_Str".getBytes(),true);
  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(),true);
  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(),true);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup("String_Node_Str".getBytes(),"String_Node_Str".getBytes(),true);
  assertFalse(it.hasNext());
  index=new DiskIndexWriter(PATH1,4,COMPRESSED);
  index.writeIndex(new HashMap().entrySet().iterator());
  diskIndex=new DiskIndex(PATH1,new DefaultByteRangeComparator(),COMPRESSED);
  it=diskIndex.rangeLookup(new byte[0],new byte[0],true);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup(null,null,true);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup("String_Node_Str".getBytes(),null,true);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup(null,"String_Node_Str".getBytes(),true);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup("String_Node_Str".getBytes(),"String_Node_Str".getBytes(),true);
  assertFalse(it.hasNext());
}