Program: 132379
Project: 132379
Buggy source:
public void testDescendingPrefixLookup() 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"};
  TreeMap<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(),false);
  for (int i=4; i > 0; 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(),false);
  for (int i=6; i > 0; 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(),false);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup("String_Node_Str".getBytes(),"String_Node_Str".getBytes(),false);
  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],false);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup(null,null,false);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup("String_Node_Str".getBytes(),null,false);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup(null,"String_Node_Str".getBytes(),false);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup("String_Node_Str".getBytes(),"String_Node_Str".getBytes(),false);
  assertFalse(it.hasNext());
}

Fixed version (ground truth):
public void testDescendingPrefixLookup() 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"};
  TreeMap<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(),false);
  for (int i=5; i >= 1; 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(),false);
  for (int i=6; i > 0; 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(),false);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup("String_Node_Str".getBytes(),"String_Node_Str".getBytes(),false);
  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],false);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup(null,null,false);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup("String_Node_Str".getBytes(),null,false);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup(null,"String_Node_Str".getBytes(),false);
  assertFalse(it.hasNext());
  it=diskIndex.rangeLookup("String_Node_Str".getBytes(),"String_Node_Str".getBytes(),false);
  assertFalse(it.hasNext());
}