Program: 113528
Project: 113528
Buggy source:
public void testSnapshots() throws Exception {
  final int maxFilesPerDir=4;
  final int numDirs=20;
  final String volumeName="String_Node_Str";
  final int numSnaps=100;
  invokeSync(client.mkvol(mrcAddress,uc,volumeName,getDefaultStripingPolicy(),POSIXFileAccessPolicy.POLICY_ID,0775));
  invokeSync(client.setxattr(mrcAddress,uc,volumeName,"String_Node_Str","String_Node_Str","String_Node_Str",0));
  SortedSet<TreeEntry> tree=createRandomTree(numDirs,maxFilesPerDir);
  for (  TreeEntry path : tree)   if (path.isDir())   invokeSync(client.mkdir(mrcAddress,uc,volumeName,path.getName(),0775));
 else   invokeSync(client.open(mrcAddress,uc,volumeName,path.getName(),FileAccessManager.O_CREAT,0775,0,new VivaldiCoordinates()));
  assertTree(tree,volumeName,"String_Node_Str",true);
  invokeSync(createSnapshot(volumeName,"String_Node_Str","String_Node_Str",true));
  assertTree(tree,volumeName + "String_Node_Str","String_Node_Str",true);
  invokeSync(createSnapshot(volumeName,"String_Node_Str","String_Node_Str",false));
  assertTree(tree,volumeName + "String_Node_Str","String_Node_Str",false);
  Map<Integer,Object[]> snaps=new HashMap<Integer,Object[]>();
  for (int i=0; i < numSnaps; i++) {
    String dir=getRandomDir(tree);
    boolean recursive=rnd.nextBoolean();
    snaps.put(i,new Object[]{dir,recursive});
    invokeSync(createSnapshot(volumeName,dir,i + "String_Node_Str",recursive));
    assertTree(tree,volumeName + "String_Node_Str" + i,dir,recursive);
  }
  SortedSet<TreeEntry> newTree=modifyTree(tree,0.2,0.3,0.2,5);
  for (  TreeEntry path : tree)   if (!newTree.contains(path)) {
    if (path.isDir())     try {
      invokeSync(client.rmdir(mrcAddress,uc,volumeName,path.getName()));
    }
 catch (    Exception exc) {
    }
 else     invokeSync(client.unlink(mrcAddress,uc,volumeName,path.getName()));
  }
  for (  TreeEntry path : newTree)   if (!tree.contains(path)) {
    if (path.isDir())     invokeSync(client.mkdir(mrcAddress,uc,volumeName,path.getName(),0775));
 else     invokeSync(client.open(mrcAddress,uc,volumeName,path.getName(),FileAccessManager.O_CREAT,0775,0,new VivaldiCoordinates()));
  }
  assertTree(newTree,volumeName,"String_Node_Str",true);
  for (  Entry<Integer,Object[]> snap : snaps.entrySet())   assertTree(tree,volumeName + "String_Node_Str" + snap.getKey(),(String)snap.getValue()[0],(Boolean)snap.getValue()[1]);
}

Fixed version (ground truth):
public void testSnapshots() throws Exception {
  final int maxFilesPerDir=4;
  final int numDirs=20;
  final String volumeName="String_Node_Str";
  final int numSnaps=50;
  invokeSync(client.mkvol(mrcAddress,uc,volumeName,getDefaultStripingPolicy(),POSIXFileAccessPolicy.POLICY_ID,0775));
  invokeSync(client.setxattr(mrcAddress,uc,volumeName,"String_Node_Str","String_Node_Str","String_Node_Str",0));
  SortedSet<TreeEntry> tree=createRandomTree(numDirs,maxFilesPerDir);
  for (  TreeEntry path : tree)   if (path.isDir())   invokeSync(client.mkdir(mrcAddress,uc,volumeName,path.getName(),0775));
 else   invokeSync(client.open(mrcAddress,uc,volumeName,path.getName(),FileAccessManager.O_CREAT,0775,0,new VivaldiCoordinates()));
  assertTree(tree,volumeName,"String_Node_Str",true);
  invokeSync(createSnapshot(volumeName,"String_Node_Str","String_Node_Str",true));
  assertTree(tree,volumeName + "String_Node_Str","String_Node_Str",true);
  invokeSync(createSnapshot(volumeName,"String_Node_Str","String_Node_Str",false));
  assertTree(tree,volumeName + "String_Node_Str","String_Node_Str",false);
  Map<Integer,Object[]> snaps=new HashMap<Integer,Object[]>();
  for (int i=0; i < numSnaps; i++) {
    String dir=getRandomDir(tree);
    boolean recursive=rnd.nextBoolean();
    snaps.put(i,new Object[]{dir,recursive});
    invokeSync(createSnapshot(volumeName,dir,i + "String_Node_Str",recursive));
    assertTree(tree,volumeName + "String_Node_Str" + i,dir,recursive);
  }
  ArrayList<TreeEntry> entries=new ArrayList<TreeEntry>(tree);
  Collections.sort(entries,new Comparator<TreeEntry>(){
    public int compare(    TreeEntry o1,    TreeEntry o2){
      return o2.getName().length() - o1.getName().length();
    }
  }
);
  for (  TreeEntry path : entries)   if (path.isDir())   invokeSync(client.rmdir(mrcAddress,uc,volumeName,path.getName()));
 else   invokeSync(client.unlink(mrcAddress,uc,volumeName,path.getName()));
  TreeSet<TreeEntry> emptyTree=new TreeSet<TreeEntry>();
  assertTree(emptyTree,volumeName,"String_Node_Str",true);
  for (  Entry<Integer,Object[]> snap : snaps.entrySet())   assertTree(tree,volumeName + "String_Node_Str" + snap.getKey(),(String)snap.getValue()[0],(Boolean)snap.getValue()[1]);
}