nus-yam/ex-repair huggingface dataset:
Program: 113214
Project: 113214
Buggy source:
@Override public void truncate(){
  try (RocksDBReference dbRef=dbhandle.getReference()){
    try (RocksIterator it=dbRef.db().newIterator()){
      it.seekToFirst();
      try (WriteOptions wo=new WriteOptions()){
        wo.setDisableWAL(true);
        wo.setSync(false);
        while (it.isValid()) {
          dbRef.db().remove(wo,it.key());
          it.next();
        }
        wo.sync();
      }
     }
 catch (    RocksDBException e) {
      throw propagate(e);
    }
  }
 }

Fixed version (ground truth):
@Override public void truncate(){
  try (RocksDBReference dbRef=dbhandle.getReference()){
    try (RocksIterator it=dbRef.db().newIterator()){
      it.seekToFirst();
      try (WriteOptions wo=new WriteOptions();WriteBatch batch=new WriteBatch()){
        wo.setSync(true);
        while (it.isValid()) {
          batch.remove(it.key());
          it.next();
        }
        dbRef.db().write(wo,batch);
      }
     }
 catch (    RocksDBException e) {
      throw propagate(e);
    }
  }
 }
Program: 113215
Project: 113215
Buggy source:
@Override public void deleteAll(Iterator<ObjectId> ids,BulkOpListener listener){
  checkNotNull(ids,"String_Node_Str");
  checkNotNull(listener,"String_Node_Str");
  checkWritable();
  final boolean checkExists=!BulkOpListener.NOOP_LISTENER.equals(listener);
  byte[] keybuff=new byte[ObjectId.NUM_BYTES];
  try (RocksDBReference dbRef=dbhandle.getReference();ReadOptions ro=new ReadOptions()){
    ro.setFillCache(false);
    ro.setVerifyChecksums(false);
    try (WriteOptions writeOps=new WriteOptions()){
      writeOps.setSync(false);
      while (ids.hasNext()) {
        ObjectId id=ids.next();
        id.getRawValue(keybuff);
        if (!checkExists || exists(dbRef,ro,keybuff)) {
          try {
            dbRef.db().remove(writeOps,keybuff);
          }
 catch (          RocksDBException e) {
            throw Throwables.propagate(e);
          }
          listener.deleted(id);
        }
 else {
          listener.notFound(id);
        }
      }
      writeOps.sync();
    }
   }
 }

Fixed version (ground truth):
@Override public void deleteAll(Iterator<ObjectId> ids,BulkOpListener listener){
  checkNotNull(ids,"String_Node_Str");
  checkNotNull(listener,"String_Node_Str");
  checkWritable();
  final boolean checkExists=!BulkOpListener.NOOP_LISTENER.equals(listener);
  byte[] keybuff=new byte[ObjectId.NUM_BYTES];
  try (RocksDBReference dbRef=dbhandle.getReference();ReadOptions ro=new ReadOptions()){
    ro.setFillCache(false);
    ro.setVerifyChecksums(false);
    try (WriteOptions writeOps=new WriteOptions();WriteBatch batch=new WriteBatch()){
      writeOps.setSync(true);
      while (ids.hasNext()) {
        ObjectId id=ids.next();
        id.getRawValue(keybuff);
        if (!checkExists || exists(dbRef,ro,keybuff)) {
          batch.remove(keybuff);
          listener.deleted(id);
        }
 else {
          listener.notFound(id);
        }
      }
      try {
        dbRef.db().write(writeOps,batch);
      }
 catch (      RocksDBException e) {
        throw Throwables.propagate(e);
      }
    }
   }
 }
Program: 113216
Project: 113216
Buggy source:
@Override public <T>T convert(Object source,Class<T> target) throws Exception {
  if (source == null) {
    return null;
  }
  Preconditions.checkArgument(source.getClass().equals(String.class));
  Preconditions.checkArgument(target.isArray());
  Preconditions.checkArgument(target.getComponentType().isPrimitive());
  final FieldType arrayType=FieldType.forBinding(target);
  Preconditions.checkState(arrayType.getBinding().isArray());
  final List<String> list=Splitter.on(';').omitEmptyStrings().trimResults().splitToList((CharSequence)source);
  final int length=list.size();
  Object array=Array.newInstance(target.getComponentType(),length);
  for (int i=0; i < length; i++) {
    String val=list.get(i);
switch (arrayType) {
case BOOLEAN_ARRAY:
      Array.setBoolean(array,i,Boolean.parseBoolean(val));
    break;
case BYTE_ARRAY:
  Array.setByte(array,i,Byte.parseByte(val));
break;
case SHORT_ARRAY:
Array.setShort(array,i,Short.parseShort(val));
break;
case INTEGER_ARRAY:
Array.setInt(array,i,Integer.parseInt(val));
break;
case LONG_ARRAY:
Array.setLong(array,i,Long.parseLong(val));
break;
case FLOAT_ARRAY:
Array.setFloat(array,i,Float.parseFloat(val));
break;
case DOUBLE_ARRAY:
Array.setDouble(array,i,Double.parseDouble(val));
break;
default :
throw new IllegalArgumentException();
}
}
return (T)array;
}

Fixed version (ground truth):
@Override public <T>T convert(Object source,Class<T> target) throws Exception {
  Preconditions.checkArgument(source == null || source.getClass().equals(String.class));
  Preconditions.checkArgument(target.isArray());
  Preconditions.checkArgument(target.getComponentType().isPrimitive());
  if (source == null || ((String)source).trim().isEmpty()) {
    return null;
  }
  final FieldType arrayType=FieldType.forBinding(target);
  Preconditions.checkState(arrayType.getBinding().isArray());
  String string=(String)source;
  if (!string.startsWith("String_Node_Str") && !string.endsWith("String_Node_Str")) {
    return null;
  }
  string=string.substring(1);
  string=string.substring(0,string.length() - 1);
  final List<String> list=Splitter.on(',').omitEmptyStrings().trimResults().splitToList(string);
  final int length=list.size();
  Object array=Array.newInstance(target.getComponentType(),length);
  for (int i=0; i < length; i++) {
    String val=list.get(i);
switch (arrayType) {
case BOOLEAN_ARRAY:
      Array.setBoolean(array,i,Boolean.parseBoolean(val));
    break;
case BYTE_ARRAY:
  Array.setByte(array,i,Byte.parseByte(val));
break;
case SHORT_ARRAY:
Array.setShort(array,i,Short.parseShort(val));
break;
case INTEGER_ARRAY:
Array.setInt(array,i,Integer.parseInt(val));
break;
case LONG_ARRAY:
Array.setLong(array,i,Long.parseLong(val));
break;
case FLOAT_ARRAY:
Array.setFloat(array,i,Float.parseFloat(val));
break;
case DOUBLE_ARRAY:
Array.setDouble(array,i,Double.parseDouble(val));
break;
default :
throw new IllegalArgumentException();
}
}
return (T)array;
}
Program: 113217
Project: 113217
Buggy source:
@Test public void roundtripTest(){
  Map<String,? extends Object> map=ImmutableMap.of("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",Integer.valueOf(12345),"String_Node_Str",ImmutableMap.of("String_Node_Str","String_Node_Str","String_Node_Str",new Long(789)));
  assertNull(Converters.convert(map,Integer.class));
  String converted=Converters.convert(map,String.class);
  assertNotNull(converted);
  @SuppressWarnings("String_Node_Str") Map<String,Object> roundTripped=Converters.convert(converted,Map.class);
  assertNotNull(roundTripped);
  assertEquals(map,roundTripped);
}

Fixed version (ground truth):
@Test public void roundtripTest(){
  Map<String,Object> map=new HashMap<>();
  map.put("String_Node_Str","String_Node_Str");
  map.put("String_Node_Str","String_Node_Str");
  map.put("String_Node_Str",Integer.valueOf(12345));
  map.put("String_Node_Str",null);
  map.put("String_Node_Str",new double[]{Math.PI,Double.MIN_VALUE,Double.MAX_VALUE});
  map.put("String_Node_Str",ImmutableMap.of("String_Node_Str","String_Node_Str","String_Node_Str",new Long(789)));
  assertNull(Converters.convert(map,Integer.class));
  String converted=Converters.convert(map,String.class);
  assertNotNull(converted);
  @SuppressWarnings("String_Node_Str") Map<String,Object> roundTripped=Converters.convert(converted,Map.class);
  assertNotNull(roundTripped);
  assertEquals(map.size(),roundTripped.size());
  assertEquals(map.keySet(),roundTripped.keySet());
  for (  Entry<String,Object> e : map.entrySet()) {
    assertTrue(Objects.deepEquals(e.getValue(),roundTripped.get(e.getKey())));
  }
}
Program: 113218
Project: 113218
Buggy source:
private void roundtripTest(Object value){
  String converted=Converters.convert(value,String.class);
  assertNotNull(converted);
  Object roundTripped=Converters.convert(converted,value.getClass());
  assertNotNull(roundTripped);
  assertTrue(roundTripped.getClass().isArray());
  assertTrue(roundTripped.getClass().getComponentType().isPrimitive());
  assertArrayEquals(value,roundTripped);
}

Fixed version (ground truth):
private void roundtripTest(Object value){
  String converted=Converters.convert(value,String.class);
  assertNotNull(converted);
  int length=Array.getLength(value);
  if (0 == length) {
    assertEquals("String_Node_Str",converted);
  }
 else {
    assertTrue(converted.startsWith("String_Node_Str"));
    assertTrue(converted.endsWith("String_Node_Str"));
    String plain=converted.substring(1);
    plain=plain.substring(0,plain.length() - 1);
    List<String> elems=Splitter.on(',').omitEmptyStrings().trimResults().splitToList(plain);
    assertEquals(length,elems.size());
  }
  Object roundTripped=Converters.convert(converted,value.getClass());
  assertNotNull(roundTripped);
  assertTrue(roundTripped.getClass().isArray());
  assertTrue(roundTripped.getClass().getComponentType().isPrimitive());
  assertArrayEquals(value,roundTripped);
}
Program: 113219
Project: 113219
Buggy source:
@Test public void testDouble(){
  roundtripTest(new double[0]);
  roundtripTest(new double[]{Double.NaN,Double.NEGATIVE_INFINITY,Double.POSITIVE_INFINITY,Double.MIN_VALUE,-1.1,0,1.1,2.2,3.3,Double.MAX_VALUE});
}

Fixed version (ground truth):
@Test public void testDouble(){
  roundtripTest(new double[0]);
  roundtripTest(new double[]{Double.NaN,Double.NEGATIVE_INFINITY,Double.POSITIVE_INFINITY,Double.MIN_VALUE,-1.1,0,1.1,2.2,3.3,Double.MAX_VALUE,Math.PI,Math.E});
}
Program: 113220
Project: 113220
Buggy source:
@Override public void found(ObjectId object,@Nullable Integer storageSizeBytes){
  found.add(object);
}

Fixed version (ground truth):
@Override public void found(ObjectId object,@Nullable Integer storageSizeBytes){
  found.add(object);
  assertNotNull(db.getIfPresent(object));
}
Program: 113221
Project: 113221
Buggy source:
@Override public void inserted(ObjectId object,@Nullable Integer storageSizeBytes){
  inserted.add(object);
}

Fixed version (ground truth):
@Override public void inserted(ObjectId object,@Nullable Integer storageSizeBytes){
  inserted.add(object);
  assertNotNull(db.getIfPresent(object));
}
Program: 113222
Project: 113222
Buggy source:
@Test public void testPutAllWithListener(){
  ImmutableList<RevObject> expected=ImmutableList.of(feature(0,null,"String_Node_Str"),feature(1,"String_Node_Str",new Integer(111)),feature(2,(Object)null),RevTree.EMPTY);
  Function<RevObject,ObjectId> toId=p -> p.getId();
  final Iterable<ObjectId> ids=Iterables.transform(expected,toId);
  final List<ObjectId> found=new CopyOnWriteArrayList<>();
  final List<ObjectId> inserted=new CopyOnWriteArrayList<>();
  BulkOpListener listener=new BulkOpListener(){
    @Override public void found(    ObjectId object,    @Nullable Integer storageSizeBytes){
      found.add(object);
    }
    @Override public void inserted(    ObjectId object,    @Nullable Integer storageSizeBytes){
      inserted.add(object);
    }
  }
;
  db.putAll(expected.iterator(),listener);
  assertTrue(found.toString(),found.isEmpty());
  assertEquals(Sets.newHashSet(ids),Sets.newHashSet(inserted));
  found.clear();
  inserted.clear();
  db.putAll(expected.iterator(),listener);
  assertTrue(inserted.toString(),inserted.isEmpty());
  assertEquals(Sets.newHashSet(ids),Sets.newHashSet(found));
}

Fixed version (ground truth):
@Test public void testPutAllWithListener(){
  ImmutableList<RevObject> expected=ImmutableList.of(feature(0,null,"String_Node_Str"),feature(1,"String_Node_Str",new Integer(111)),feature(2,(Object)null),RevTree.EMPTY);
  Function<RevObject,ObjectId> toId=p -> p.getId();
  final Iterable<ObjectId> ids=Iterables.transform(expected,toId);
  final List<ObjectId> found=new CopyOnWriteArrayList<>();
  final List<ObjectId> inserted=new CopyOnWriteArrayList<>();
  BulkOpListener listener=new BulkOpListener(){
    @Override public void found(    ObjectId object,    @Nullable Integer storageSizeBytes){
      found.add(object);
      assertNotNull(db.getIfPresent(object));
    }
    @Override public void inserted(    ObjectId object,    @Nullable Integer storageSizeBytes){
      inserted.add(object);
      assertNotNull(db.getIfPresent(object));
    }
  }
;
  db.putAll(expected.iterator(),listener);
  assertTrue(found.toString(),found.isEmpty());
  assertEquals(Sets.newHashSet(ids),Sets.newHashSet(inserted));
  found.clear();
  inserted.clear();
  db.putAll(expected.iterator(),listener);
  assertTrue(inserted.toString(),inserted.isEmpty());
  assertEquals(Sets.newHashSet(ids),Sets.newHashSet(found));
}
Program: 113223
Project: 113223
Buggy source:
static int notifyInserted(int[] inserted,List<ObjectId> objects,BulkOpListener listener){
  int newObjects=0;
  for (int i=0; i < inserted.length; i++) {
    ObjectId id=objects.get(i);
    if (inserted[i] > 0) {
      listener.inserted(id,null);
      newObjects++;
    }
 else {
      listener.found(id,null);
    }
  }
  return newObjects;
}

Fixed version (ground truth):
static int notifyInserted(Map<ObjectId,Integer> insertResults,BulkOpListener listener){
  int newObjects=0;
  for (  Entry<ObjectId,Integer> entry : insertResults.entrySet()) {
    if (entry.getValue() > 0) {
      listener.inserted(entry.getKey(),null);
      newObjects++;
    }
 else {
      listener.found(entry.getKey(),null);
    }
  }
  return newObjects;
}
Program: 113224
Project: 113224
Buggy source:
private void doInsert(Connection cx,List<EncodedObject> partition) throws Exception {
  Map<String,PreparedStatement> perTableStatements=new HashMap<>();
  ArrayListMultimap<String,ObjectId> perTableIds=ArrayListMultimap.create();
  for (Iterator<EncodedObject> it=partition.iterator(); it.hasNext() && !abortFlag.get(); ) {
    EncodedObject obj=it.next();
    final TYPE type=obj.type;
    final ObjectId id=obj.id;
    final PGId pgid=PGId.valueOf(id);
    final byte[] bytes=obj.serialized;
{
      final String tableName=objectStore.tableNameForType(type,pgid);
      perTableIds.put(tableName,id);
      PreparedStatement stmt=prepare(cx,tableName,perTableStatements);
      pgid.setArgs(stmt,1);
      stmt.setBytes(4,bytes);
      stmt.addBatch();
    }
  }
  for (  String tableName : new HashSet<String>(perTableIds.keySet())) {
    if (abortFlag.get()) {
      return;
    }
    PreparedStatement tableStatement;
    tableStatement=perTableStatements.get(tableName);
    List<ObjectId> ids=perTableIds.removeAll(tableName);
    int[] batchResults=tableStatement.executeBatch();
    tableStatement.clearParameters();
    tableStatement.clearBatch();
    notifyInserted(batchResults,ids,listener);
  }
  for (  PreparedStatement tableStatement : perTableStatements.values()) {
    tableStatement.close();
  }
}

Fixed version (ground truth):
private Map<ObjectId,Integer> doInsert(Connection cx,List<EncodedObject> partition) throws Exception {
  Map<String,PreparedStatement> perTableStatements=new HashMap<>();
  ArrayListMultimap<String,ObjectId> perTableIds=ArrayListMultimap.create();
  for (Iterator<EncodedObject> it=partition.iterator(); it.hasNext() && !abortFlag.get(); ) {
    EncodedObject obj=it.next();
    final TYPE type=obj.type;
    final ObjectId id=obj.id;
    final PGId pgid=PGId.valueOf(id);
    final byte[] bytes=obj.serialized;
{
      final String tableName=objectStore.tableNameForType(type,pgid);
      perTableIds.put(tableName,id);
      PreparedStatement stmt=prepare(cx,tableName,perTableStatements);
      pgid.setArgs(stmt,1);
      stmt.setBytes(4,bytes);
      stmt.addBatch();
    }
  }
  Map<ObjectId,Integer> insertResults=new HashMap<ObjectId,Integer>();
  for (  String tableName : new HashSet<String>(perTableIds.keySet())) {
    if (abortFlag.get()) {
      return null;
    }
    PreparedStatement tableStatement;
    tableStatement=perTableStatements.get(tableName);
    List<ObjectId> ids=perTableIds.removeAll(tableName);
    int[] batchResults=tableStatement.executeBatch();
    tableStatement.clearParameters();
    tableStatement.clearBatch();
    for (int i=0; i < batchResults.length; i++) {
      insertResults.put(ids.get(i),batchResults[i]);
    }
  }
  for (  PreparedStatement tableStatement : perTableStatements.values()) {
    tableStatement.close();
  }
  return insertResults;
}
Program: 113225
Project: 113225
Buggy source:
@Override public Void call(){
  if (abortFlag.get()) {
    return null;
  }
  try (Connection cx=PGStorage.newConnection(ds)){
    cx.setAutoCommit(false);
    try {
      doInsert(cx,batch);
      if (abortFlag.get()) {
        cx.rollback();
      }
 else {
        cx.commit();
      }
    }
 catch (    Exception executionEx) {
      rollbackAndRethrow(cx,executionEx);
    }
 finally {
      cx.setAutoCommit(true);
    }
  }
 catch (  Exception connectEx) {
    abortFlag.set(true);
  }
  return null;
}

Fixed version (ground truth):
@Override public Void call(){
  if (abortFlag.get()) {
    return null;
  }
  try (Connection cx=PGStorage.newConnection(ds)){
    cx.setAutoCommit(false);
    try {
      Map<ObjectId,Integer> insertResults=doInsert(cx,batch);
      if (abortFlag.get()) {
        cx.rollback();
      }
 else {
        cx.commit();
      }
      notifyInserted(insertResults,listener);
    }
 catch (    Exception executionEx) {
      rollbackAndRethrow(cx,executionEx);
    }
 finally {
      cx.setAutoCommit(true);
    }
  }
 catch (  Exception connectEx) {
    abortFlag.set(true);
  }
  return null;
}
Program: 113226
Project: 113226
Buggy source:
/** 
 * Makes sure the DAG has the same structure than the original tree following the path to the node (i.e.) loading only the   {@link RevTree trees} necessary to reach the node being added.
 * @param root
 * @param nodeId
 * @param nodeDepth depth, not depth index
 * @return
 * @return
 */
protected void mergeRoot(DAG root,final NodeId nodeId){
  checkNotNull(root);
  checkNotNull(nodeId);
  if (root.getState() == STATE.INITIALIZED) {
    final RevTree original=getOriginalTree(root.originalTreeId());
    root.setTotalChildCount(original.size());
    final boolean originalIsLeaf=original.buckets().isEmpty();
    if (originalIsLeaf) {
      final Map<NodeId,DAGNode> origNodes=lazyNodes(original);
      if (!origNodes.isEmpty()) {
        storageProvider.saveNodes(origNodes);
        origNodes.keySet().forEach((id) -> root.addChild(id));
      }
    }
 else {
      final int dagDepth=root.getId().depthLength();
      final TreeId nodeBucketId=computeBucketId(nodeId,dagDepth + 1);
      final ImmutableSortedMap<Integer,Bucket> buckets=original.buckets();
      if (root.getState() == STATE.INITIALIZED) {
        checkState(root.numChildren() == 0);
        preload(buckets.values());
        for (        Entry<Integer,Bucket> e : buckets.entrySet()) {
          Integer bucketIndex=e.getKey();
          TreeId dagBucketId=computeBucketId(nodeBucketId,bucketIndex);
          ObjectId bucketId=e.getValue().getObjectId();
          DAG dag=getOrCreateDAG(dagBucketId,bucketId);
          root.addBucket(dagBucketId);
        }
      }
    }
    root.setMirrored();
  }
}

Fixed version (ground truth):
/** 
 * Makes sure the DAG has the same structure than the original tree following the path to the node (i.e.) loading only the   {@link RevTree trees} necessary to reach the node being added.
 * @param root
 * @param nodeDepth depth, not depth index
 * @return
 * @return
 */
protected void mergeRoot(DAG root){
  checkNotNull(root);
  if (root.getState() == STATE.INITIALIZED) {
    final RevTree original=getOriginalTree(root.originalTreeId());
    root.setTotalChildCount(original.size() + original.numTrees());
    final boolean originalIsLeaf=original.buckets().isEmpty();
    if (originalIsLeaf) {
      final Map<NodeId,DAGNode> origNodes=lazyNodes(original);
      if (!origNodes.isEmpty()) {
        storageProvider.saveNodes(origNodes);
        origNodes.keySet().forEach((id) -> root.addChild(id));
      }
    }
 else {
      final ImmutableSortedMap<Integer,Bucket> buckets=original.buckets();
      if (root.getState() == STATE.INITIALIZED) {
        checkState(root.numChildren() == 0);
        preload(buckets.values());
        for (        Entry<Integer,Bucket> e : buckets.entrySet()) {
          Integer bucketIndex=e.getKey();
          TreeId dagBucketId=root.getId().newChild(bucketIndex.intValue());
          ObjectId bucketId=e.getValue().getObjectId();
          DAG dag=getOrCreateDAG(dagBucketId,bucketId);
          root.addBucket(dagBucketId);
        }
      }
    }
    root.setMirrored();
  }
}
Program: 113228
Project: 113228
Buggy source:
private void shrinkIfUnderflow(final DAG bucketsDAG,NodeId nodeId,int depth){
  final long childCount=bucketsDAG.getTotalChildCount();
  final int normalizedSizeLimit=normalizedSizeLimit(depth);
  if (childCount <= normalizedSizeLimit && bucketsDAG.numBuckets() > 0) {
    Set<NodeId> childrenRecursive=getChildrenRecursive(bucketsDAG,nodeId,depth);
    checkState(childrenRecursive.size() == childCount,"String_Node_Str",childCount,childrenRecursive.size(),bucketsDAG);
    bucketsDAG.clearBuckets();
    childrenRecursive.forEach((id) -> bucketsDAG.addChild(id));
  }
}

Fixed version (ground truth):
private void shrinkIfUnderflow(final DAG dag){
  if (dag.numBuckets() == 0) {
    return;
  }
  final long childCount=dag.getTotalChildCount();
  final int depth=dag.getId().depthLength();
  final int normalizedSizeLimit=normalizedSizeLimit(depth);
  if (childCount > normalizedSizeLimit) {
    return;
  }
  Set<NodeId> childrenRecursive=getChildrenRecursiveAndClearBuckets(dag);
  checkState(childrenRecursive.size() == childCount,"String_Node_Str",childCount,childrenRecursive.size(),dag);
  dag.clearBuckets();
  childrenRecursive.forEach((id) -> dag.addChild(id));
}
Program: 113229
Project: 113229
Buggy source:
private TreeId computeBucketId(final TreeId treeId,final Integer leafOverride){
  byte[] bucketIndicesByDepth=treeId.bucketIndicesByDepth.clone();
  bucketIndicesByDepth[bucketIndicesByDepth.length - 1]=leafOverride.byteValue();
  return new TreeId(bucketIndicesByDepth);
}

Fixed version (ground truth):
TreeId computeBucketId(final NodeId nodeId,final int childDepth){
  byte[] treeId=new byte[childDepth];
  int unpromotableDepthIndex=-1;
  for (int depthIndex=0; depthIndex < childDepth; depthIndex++) {
    int bucketIndex=bucket(nodeId,depthIndex);
    if (bucketIndex == -1) {
      unpromotableDepthIndex=depthIndex;
      break;
    }
    treeId[depthIndex]=(byte)bucketIndex;
  }
  if (unpromotableDepthIndex > -1) {
    final int extraBucketIndex=unpromotableBucketIndex(unpromotableDepthIndex);
    treeId[unpromotableDepthIndex]=(byte)extraBucketIndex;
    unpromotableDepthIndex++;
    final int missingDepthCount=childDepth - unpromotableDepthIndex;
    for (int i=0; i < missingDepthCount; i++, unpromotableDepthIndex++) {
      int bucketIndex=canonicalBucket(nodeId,i);
      treeId[unpromotableDepthIndex]=(byte)bucketIndex;
    }
  }
  return new TreeId(treeId);
}
Program: 113230
Project: 113230
Buggy source:
protected ClusteringStrategy(RevTree original,DAGStorageProvider storageProvider){
  checkNotNull(original);
  checkNotNull(storageProvider);
  this.original=original;
  this.storageProvider=storageProvider;
  this.dagCache=new DAGCache(storageProvider);
  this.root=new DAG(ROOT_ID,original.getId());
  this.root.setTotalChildCount(original.size());
}

Fixed version (ground truth):
protected ClusteringStrategy(RevTree original,DAGStorageProvider storageProvider){
  checkNotNull(original);
  checkNotNull(storageProvider);
  this.original=original;
  this.storageProvider=storageProvider;
  this.dagCache=new DAGCache(storageProvider);
  this.root=new DAG(ROOT_ID,original.getId());
  mergeRoot(root);
}
Program: 113231
Project: 113231
Buggy source:
@Override public String toString(){
  String revTreeId=originalTreeId.equals(RevTree.EMPTY_TREE_ID) ? "String_Node_Str" : originalTreeId.toString().substring(0,6);
  return String.format("String_Node_Str",id,revTreeId,state,childCount,children.size(),buckets.size(),children,buckets);
}

Fixed version (ground truth):
@Override public String toString(){
  String revTreeId=originalTreeId.equals(RevTree.EMPTY_TREE_ID) ? "String_Node_Str" : originalTreeId.toString().substring(0,8);
  return String.format("String_Node_Str",id,revTreeId,state,childCount,children.size(),buckets.size(),children,buckets);
}
Program: 113232
Project: 113232
Buggy source:
@Override protected void mergeRoot(final DAG root,final NodeId nodeId){
  if (!ENABLE_EXPAND_COLLAPSE) {
    super.mergeRoot(root,nodeId);
    return;
  }
  checkNotNull(root);
  checkNotNull(nodeId);
  if (root.getState() == STATE.INITIALIZED) {
    final ObjectId originalTreeId=root.originalTreeId();
    final RevTree originalTree=getOriginalTree(originalTreeId);
    final TreeId rootId=root.getId();
    final TreeId expandedTreeId=computeExpandedChildId(originalTree,rootId);
    if (rootId.equals(expandedTreeId)) {
      super.mergeRoot(root,nodeId);
    }
 else {
      expand(root,expandedTreeId,originalTree,nodeId);
    }
  }
}

Fixed version (ground truth):
@Override protected void mergeRoot(final DAG root){
  if (!ENABLE_EXPAND_COLLAPSE) {
    super.mergeRoot(root);
    return;
  }
  checkNotNull(root);
  if (root.getState() == STATE.INITIALIZED) {
    final ObjectId originalTreeId=root.originalTreeId();
    final RevTree originalTree=getOriginalTree(originalTreeId);
    final TreeId rootId=root.getId();
    final TreeId expandedTreeId=computeExpandedChildId(originalTree,rootId);
    if (rootId.equals(expandedTreeId)) {
      super.mergeRoot(root);
    }
 else {
    }
  }
}
Program: 113233
Project: 113233
Buggy source:
public Node putNode(QuadTreeClusteringStrategy quad,Quadrant... location){
  Preconditions.checkNotNull(location);
  long fnumb=quad.root == null ? 0 : quad.root.getTotalChildCount();
  String quadInfo="String_Node_Str";
  for (  Quadrant q : location) {
    quadInfo+=q.name() + "String_Node_Str";
  }
  quadInfo+="String_Node_Str";
  for (  Quadrant q : location) {
    quadInfo+=q.getBucketNumber() + "String_Node_Str";
  }
  quadInfo+="String_Node_Str";
  Node n=createNode("String_Node_Str" + fnumb + "String_Node_Str"+ quadInfo,location);
  quad.put(n);
  return n;
}

Fixed version (ground truth):
public Node putNode(QuadTreeClusteringStrategy quad,Quadrant... location){
  Preconditions.checkNotNull(location);
  long fnumb=quad.root == null ? 0 : quad.root.getTotalChildCount();
  String quadInfo=Arrays.toString(location);
  Node n=createNode("String_Node_Str" + fnumb + "String_Node_Str"+ quadInfo,location);
  quad.put(n);
  return n;
}
Program: 113234
Project: 113234
Buggy source:
public DAG buildRoot(){
  while (1 == root.numBuckets()) {
    root.forEachBucket((treeId) -> {
      DAG actual=getOrCreateDAG(treeId);
      root=actual;
      rootId=treeId;
    }
);
  }
  return root;
}

Fixed version (ground truth):
public DAG buildRoot(){
  return root;
}
Program: 113235
Project: 113235
Buggy source:
protected ClusteringStrategy(RevTree original,DAGStorageProvider storageProvider){
  checkNotNull(original);
  checkNotNull(storageProvider);
  this.storageProvider=storageProvider;
  this.root=new DAG(ROOT_ID,original.getId());
  this.root.setChildCount(original.size());
  this.dagCache=new DAGCache(storageProvider);
}

Fixed version (ground truth):
protected ClusteringStrategy(RevTree original,DAGStorageProvider storageProvider){
  checkNotNull(original);
  checkNotNull(storageProvider);
  this.storageProvider=storageProvider;
  this.dagCache=new DAGCache(storageProvider);
  init(original,ROOT_ID);
}
Program: 113236
Project: 113236
Buggy source:
public static RevTree build(final ClusteringStrategy clusteringStrategy,final ObjectStore targetStore){
  ProgressListener listener=new DefaultProgressListener();
  SharedState state=new SharedState(targetStore,clusteringStrategy,listener);
  DAG root=clusteringStrategy.buildRoot();
  TreeId rootId=clusteringStrategy.getRootId();
  final int baseDepth=rootId.depthLength();
  TreeBuildTask task=new TreeBuildTask(state,root,baseDepth);
  RevTree tree;
  try {
    ForkJoinPool forkJoinPool=FORK_JOIN_POOL;
    tree=forkJoinPool.invoke(task);
  }
 catch (  Exception e) {
    throw Throwables.propagate(e);
  }
 finally {
    state.saveTrees();
  }
  return tree;
}

Fixed version (ground truth):
public static RevTree build(final ClusteringStrategy clusteringStrategy,final ObjectStore targetStore){
  ProgressListener listener=new DefaultProgressListener();
  SharedState state=new SharedState(targetStore,clusteringStrategy,listener);
  final DAG root=clusteringStrategy.buildRoot();
  final TreeId rootId=root.getId();
  final int baseDepth=rootId.depthLength();
  TreeBuildTask task=new TreeBuildTask(state,root,baseDepth);
  RevTree tree;
  try {
    ForkJoinPool forkJoinPool=FORK_JOIN_POOL;
    tree=forkJoinPool.invoke(task);
  }
 catch (  Exception e) {
    throw Throwables.propagate(e);
  }
 finally {
    state.saveTrees();
  }
  return tree;
}
Program: 113237
Project: 113237
Buggy source:
/** 
 * Overrides to implement a simple optimization for the case where the node bounds haven't changed and hence avoid calling remove and then put, but call put only, since the  {@code NodeId} is guaranteed to lay on the same bucket at any depth.
 */
@Override public void update(Node oldNode,Node newNode){
  if (oldNode.bounds().equals(newNode.bounds())) {
    Preconditions.checkArgument(oldNode.getName().equals(newNode.getName()));
    put(newNode);
  }
 else {
    super.update(oldNode,newNode);
  }
}

Fixed version (ground truth):
/** 
 * Overrides to implement a simple optimization for the case where the node bounds haven't changed and hence avoid calling remove and then put, but call put only, since the  {@code NodeId} is guaranteed to lay on the same bucket at any depth.
 */
@Override public void update(Node oldNode,Node newNode){
  Optional<Envelope> oldBounds=oldNode.bounds();
  Optional<Envelope> newBounds=newNode.bounds();
  if (oldBounds.equals(newBounds)) {
    Preconditions.checkArgument(oldNode.getName().equals(newNode.getName()));
    put(newNode);
  }
 else {
    super.update(oldNode,newNode);
  }
}
Program: 113238
Project: 113238
Buggy source:
public QuadTreeClusteringStrategy(RevTree original,DAGStorageProvider storageProvider,Envelope maxBounds){
  super(original,storageProvider);
  this.maxBounds=maxBounds;
}

Fixed version (ground truth):
public QuadTreeClusteringStrategy(RevTree original,DAGStorageProvider storageProvider,Envelope maxBounds){
  super(original,storageProvider);
  this.maxBounds=maxBounds;
  init(original);
}
Program: 113239
Project: 113239
Buggy source:
/** 
 * @return a feature node named {@code i}, with  {@code id = ObjectId.forString(String.valueOf(i))}, null metadata id, and  {@code bounds = [i, i+1, i, i+1]}
 */
protected static Node node(int i){
  String key="String_Node_Str" + String.valueOf(i);
  ObjectId oid=RevObjectTestSupport.hashString(key);
  Envelope bounds=new Envelope(i,i + 1,i,i + 1);
  Node node=Node.create(key,oid,ObjectId.NULL,TYPE.FEATURE,bounds);
  return node;
}

Fixed version (ground truth):
protected static Node node(int i,Envelope bounds){
  String key="String_Node_Str" + String.valueOf(i);
  ObjectId oid=RevObjectTestSupport.hashString(key);
  Node node=Node.create(key,oid,ObjectId.NULL,TYPE.FEATURE,bounds);
  return node;
}
Program: 113240
Project: 113240
Buggy source:
public Optional<ObjectId> getMetadataId(final int objectIdIndex){
  Optional<ObjectId> mdId=Optional.absent();
  if (objectIdIndex > 0) {
    mdId=Optional.of(getObjectId(objectIdIndex));
  }
  return mdId;
}

Fixed version (ground truth):
public Optional<ObjectId> getMetadataId(final int objectIdIndex){
  Optional<ObjectId> mdId=Optional.absent();
  if (objectIdIndex > -1) {
    mdId=Optional.of(getObjectId(objectIdIndex));
  }
  return mdId;
}
Program: 113241
Project: 113241
Buggy source:
public static RevTree decode(ObjectId id,ByteBuffer data){
  final DataBuffer dataBuffer=DataBuffer.of(data);
  final long totalSize=dataBuffer.header().size();
  final int numTrees=dataBuffer.header().numTrees();
  if (totalSize == 0L && numTrees == 0) {
    return RevTree.EMPTY;
  }
  return new RevTreeImpl(id,dataBuffer);
}

Fixed version (ground truth):
public static RevTree decode(@Nullable ObjectId id,ByteBuffer data){
  final DataBuffer dataBuffer=DataBuffer.of(data);
  final long totalSize=dataBuffer.header().size();
  final int numTrees=dataBuffer.header().numTrees();
  if (totalSize == 0L && numTrees == 0) {
    return RevTree.EMPTY;
  }
  if (null == id) {
    List<Node> trees=RevTreeFormat.trees(dataBuffer);
    List<Node> features=RevTreeFormat.features(dataBuffer);
    SortedMap<Integer,Bucket> buckets=RevTreeFormat.buckets(dataBuffer);
    id=HashObject.hashTree(trees,features,buckets);
  }
  return new RevTreeImpl(id,dataBuffer);
}
Program: 113242
Project: 113242
Buggy source:
@Test public void severalFeatures() throws IOException {
  encodedDecode(nodes(TYPE.FEATURE,1,false,false,false),TYPE.FEATURE);
  encodedDecode(nodes(TYPE.FEATURE,1024,false,false,true),TYPE.FEATURE);
  encodedDecode(nodes(TYPE.FEATURE,1024,false,true,true),TYPE.FEATURE);
  encodedDecode(nodes(TYPE.FEATURE,1024,true,true,true),TYPE.FEATURE);
  encodedDecode(nodes(TYPE.FEATURE,1024,true,false,false),TYPE.FEATURE);
  encodedDecode(nodes(TYPE.FEATURE,1024,true,true,false),TYPE.FEATURE);
}

Fixed version (ground truth):
@Test public void severalFeatures() throws IOException {
  encodedDecode(nodes(TYPE.FEATURE,1024,false,false,false),TYPE.FEATURE);
  encodedDecode(nodes(TYPE.FEATURE,1024,false,false,true),TYPE.FEATURE);
  encodedDecode(nodes(TYPE.FEATURE,1024,false,true,true),TYPE.FEATURE);
  encodedDecode(nodes(TYPE.FEATURE,1024,true,true,true),TYPE.FEATURE);
  encodedDecode(nodes(TYPE.FEATURE,1024,true,false,false),TYPE.FEATURE);
  encodedDecode(nodes(TYPE.FEATURE,1024,true,true,false),TYPE.FEATURE);
}
Program: 113243
Project: 113243
Buggy source:
@Test public void testConsistentHashing() throws IOException {
  List<Node> tNodes=nodes(TYPE.TREE,512,true,true,true);
  List<Node> fNodes=nodes(TYPE.FEATURE,512,false,true,true);
  final RevTree orig=tree(2048,tNodes,fNodes,null);
  final byte[] encoded=RevTreeFormat.encode(orig);
  assertNotNull(encoded);
  RevTree decoded=RevTreeFormat.decode(orig.getId(),encoded);
  ObjectId expected=new HashObject().setObject(orig).call();
  ObjectId actual=new HashObject().setObject(decoded).call();
  assertEquals(expected,actual);
}

Fixed version (ground truth):
public void testConsistentHashing(boolean withMetadataId,boolean withBounds,boolean withExtraData) throws IOException {
  List<Node> tNodes=nodes(TYPE.TREE,512,withMetadataId,withBounds,withExtraData);
  List<Node> fNodes=nodes(TYPE.FEATURE,512,withMetadataId,withBounds,withExtraData);
  final RevTree orig=tree(2048,tNodes,fNodes,null);
  assertHashing(orig);
}
Program: 113245
Project: 113245
Buggy source:
static NodeFlags parse(DataInput in,int numNodes) throws IOException {
  if (numNodes == 0) {
    return EMPTY;
  }
  final int length=(int)Math.ceil(numNodes / 2D);
  byte[] bitsetData=new byte[length];
  in.readFully(bitsetData);
  BitSet bitset=BitSet.valueOf(bitsetData);
  return new NodeFlags(bitset);
}

Fixed version (ground truth):
static NodeFlags parse(DataInput in,int numNodes) throws IOException {
  if (numNodes == 0) {
    return EMPTY;
  }
  int logicalSize=in.readInt();
  final int length=(int)Math.ceil(numNodes / 2D);
  byte[] bitsetData=new byte[length];
  in.readFully(bitsetData,0,logicalSize);
  BitSet bitset=BitSet.valueOf(bitsetData);
  return new NodeFlags(bitset);
}
Program: 113246
Project: 113246
Buggy source:
@Test public void severalFeatures() throws IOException {
  encodedDecode(featureNodes(1024),TYPE.FEATURE);
}

Fixed version (ground truth):
@Test public void severalFeatures() throws IOException {
  encodedDecode(nodes(TYPE.FEATURE,1,false,false,false),TYPE.FEATURE);
  encodedDecode(nodes(TYPE.FEATURE,1024,false,false,true),TYPE.FEATURE);
  encodedDecode(nodes(TYPE.FEATURE,1024,false,true,true),TYPE.FEATURE);
  encodedDecode(nodes(TYPE.FEATURE,1024,true,true,true),TYPE.FEATURE);
  encodedDecode(nodes(TYPE.FEATURE,1024,true,false,false),TYPE.FEATURE);
  encodedDecode(nodes(TYPE.FEATURE,1024,true,true,false),TYPE.FEATURE);
}
Program: 113247
Project: 113247
Buggy source:
@Override public void addIndexedTree(IndexInfo index,ObjectId originalTree,ObjectId indexedTree){
  ObjectId indexTreeLookupId=computeIndexTreeLookupId(index.getId(),originalTree);
  try (RocksDBReference dbRef=dbhandle.getReference()){
    dbRef.db().put(indexMetadataColumn,indexTreeLookupId.getRawValue(),indexedTree.getRawValue());
  }
 catch (  RocksDBException e) {
    throw Throwables.propagate(e);
  }
}

Fixed version (ground truth):
@Override public void addIndexedTree(IndexInfo index,ObjectId originalTree,ObjectId indexedTree){
  ObjectId indexTreeLookupId=computeIndexTreeLookupId(index.getId(),originalTree);
  try (RocksDBReference dbRef=dbhandle.getReference()){
    dbRef.db().put(indexMappingsColumn,indexTreeLookupId.getRawValue(),indexedTree.getRawValue());
  }
 catch (  RocksDBException e) {
    throw Throwables.propagate(e);
  }
}
Program: 113248
Project: 113248
Buggy source:
@Override public Optional<ObjectId> resolveIndexedTree(IndexInfo index,ObjectId treeId){
  ObjectId indexTreeLookupId=computeIndexTreeLookupId(index.getId(),treeId);
  byte[] indexTreeBytes;
  try (RocksDBReference dbRef=dbhandle.getReference()){
    indexTreeBytes=dbRef.db().get(indexMetadataColumn,indexTreeLookupId.getRawValue());
  }
 catch (  RocksDBException e) {
    throw Throwables.propagate(e);
  }
  if (indexTreeBytes != null) {
    return Optional.of(ObjectId.createNoClone(indexTreeBytes));
  }
  return Optional.absent();
}

Fixed version (ground truth):
@Override public Optional<ObjectId> resolveIndexedTree(IndexInfo index,ObjectId treeId){
  ObjectId indexTreeLookupId=computeIndexTreeLookupId(index.getId(),treeId);
  byte[] indexTreeBytes;
  try (RocksDBReference dbRef=dbhandle.getReference()){
    indexTreeBytes=dbRef.db().get(indexMappingsColumn,indexTreeLookupId.getRawValue());
  }
 catch (  RocksDBException e) {
    throw Throwables.propagate(e);
  }
  if (indexTreeBytes != null) {
    return Optional.of(ObjectId.createNoClone(indexTreeBytes));
  }
  return Optional.absent();
}
Program: 113249
Project: 113249
Buggy source:
private IndexInfo readIndex(byte[] indexBytes){
  IndexInfo index=IndexInfoSerializer.deserialize(ByteStreams.newDataInput(indexBytes));
  return index;
}

Fixed version (ground truth):
private IndexInfo readIndex(byte[] indexBytes){
  DataInput input=ByteStreams.newDataInput(indexBytes);
  IndexInfo index=IndexInfoSerializer.deserialize(input);
  return index;
}
Program: 113250
Project: 113250
Buggy source:
@Override public synchronized void open(){
  if (isOpen()) {
    return;
  }
  super.open(Collections.singleton("String_Node_Str"));
  this.indexMetadataColumn=super.dbhandle.getColumnFamily("String_Node_Str");
  Preconditions.checkState(this.indexMetadataColumn != null);
}

Fixed version (ground truth):
@Override public synchronized void open(){
  if (isOpen()) {
    return;
  }
  super.open(Sets.newHashSet("String_Node_Str","String_Node_Str"));
  this.indexMetadataColumn=super.dbhandle.getColumnFamily("String_Node_Str");
  this.indexMappingsColumn=super.dbhandle.getColumnFamily("String_Node_Str");
  Preconditions.checkState(this.indexMetadataColumn != null);
  Preconditions.checkState(this.indexMappingsColumn != null);
}
Program: 113251
Project: 113251
Buggy source:
@Override public ConfigDatabase getConfigDatabase(URI repoURI,Context repoContext,boolean rootUri){
  final Environment config;
  if (rootUri) {
    Properties properties=EnvironmentBuilder.getRootURIProperties(repoURI);
    EnvironmentBuilder builder=new EnvironmentBuilder(properties);
    config=builder.build();
  }
 else {
    config=parseConfig(repoURI);
  }
  PGConfigDatabase configDb=new PGConfigDatabase(config);
  if (config.getRepositoryName() != null) {
    Optional<String> refsFormat=configDb.get("String_Node_Str");
    if (!refsFormat.isPresent()) {
      configDb.put(PGStorageProvider.FORMAT_NAME + "String_Node_Str",PGStorageProvider.VERSION);
      configDb.put("String_Node_Str",PGStorageProvider.FORMAT_NAME);
      configDb.put("String_Node_Str",PGStorageProvider.FORMAT_NAME);
      configDb.put("String_Node_Str",PGStorageProvider.FORMAT_NAME);
      configDb.put("String_Node_Str",PGStorageProvider.FORMAT_NAME);
    }
  }
  return configDb;
}

Fixed version (ground truth):
@Override public ConfigDatabase getConfigDatabase(URI repoURI,Context repoContext,boolean rootUri){
  final Environment config;
  if (rootUri) {
    Properties properties=EnvironmentBuilder.getRootURIProperties(repoURI);
    EnvironmentBuilder builder=new EnvironmentBuilder(properties);
    config=builder.build();
  }
 else {
    config=parseConfig(repoURI);
  }
  PGConfigDatabase configDb=new PGConfigDatabase(config);
  if (config.getRepositoryName() != null) {
    Optional<String> configEntry=configDb.get(PGStorageProvider.FORMAT_NAME + "String_Node_Str");
    if (!configEntry.isPresent()) {
      configDb.put(PGStorageProvider.FORMAT_NAME + "String_Node_Str",PGStorageProvider.VERSION);
    }
    configEntry=configDb.get("String_Node_Str");
    if (!configEntry.isPresent()) {
      configDb.put("String_Node_Str",PGStorageProvider.FORMAT_NAME);
    }
    configEntry=configDb.get("String_Node_Str");
    if (!configEntry.isPresent()) {
      configDb.put("String_Node_Str",PGStorageProvider.FORMAT_NAME);
    }
    configEntry=configDb.get("String_Node_Str");
    if (!configEntry.isPresent()) {
      configDb.put("String_Node_Str",PGStorageProvider.FORMAT_NAME);
    }
    configEntry=configDb.get("String_Node_Str");
    if (!configEntry.isPresent()) {
      configDb.put("String_Node_Str",PGStorageProvider.FORMAT_NAME);
    }
  }
  return configDb;
}
Program: 113253
Project: 113253
Buggy source:
private void createQuadTree(GeogigCLI cli,String commitish,Index index) throws IOException {
  GeoGIG geogig=cli.getGeogig();
  IndexDatabase indexDatabase=geogig.getRepository().indexDatabase();
  String treeSpec=commitish + "String_Node_Str" + tree;
  Optional<ObjectId> treeId=geogig.command(ResolveTreeish.class).setTreeish(treeSpec).call();
  if (!treeId.isPresent()) {
    cli.getConsole().println(String.format("String_Node_Str",treeSpec));
    return;
  }
  if (indexDatabase.resolveIndexedTree(index,treeId.get()).isPresent()) {
    cli.getConsole().println(String.format("String_Node_Str",treeSpec));
    return;
  }
  CreateQuadTree command=geogig.command(CreateQuadTree.class);
  command.setFeatureTree(treeId.get());
  ProgressListener listener=cli.getProgressListener();
  RevTree quadTree=command.setProgressListener(listener).call();
  geogig.getRepository().indexDatabase().addIndexedTree(index,treeId.get(),quadTree.getId());
  cli.getConsole().println(String.format("String_Node_Str",quadTree.getId(),quadTree.size()));
}

Fixed version (ground truth):
private void createQuadTree(GeogigCLI cli,String commitish,Index index) throws IOException {
  GeoGIG geogig=cli.getGeogig();
  IndexDatabase indexDatabase=geogig.getRepository().indexDatabase();
  String treeSpec=commitish + "String_Node_Str" + tree;
  Optional<ObjectId> treeId=geogig.command(ResolveTreeish.class).setTreeish(treeSpec).call();
  if (!treeId.isPresent()) {
    cli.getConsole().println(String.format("String_Node_Str",treeSpec));
    return;
  }
  if (indexDatabase.resolveIndexedTree(index,treeId.get()).isPresent()) {
    cli.getConsole().println(String.format("String_Node_Str",treeSpec));
    return;
  }
  CreateQuadTree command=geogig.command(CreateQuadTree.class);
  command.setFeatureTree(treeId.get());
  ProgressListener listener=cli.getProgressListener();
  RevTree quadTree=command.setProgressListener(listener).call();
  indexDatabase.addIndexedTree(index,treeId.get(),quadTree.getId());
  cli.getConsole().println(String.format("String_Node_Str",quadTree.getId(),quadTree.size()));
}
Program: 113254
Project: 113254
Buggy source:
private RevTree resolveTree(@Nullable final String treeIsh,@Nullable final ObjectId treeOid,final ObjectStore source){
  RevTree tree=null;
  ResolveTreeish command=null;
  if (treeOid != null) {
    if (ObjectId.NULL.equals(treeOid) || RevTree.EMPTY_TREE_ID.equals(treeOid)) {
      tree=RevTree.EMPTY;
    }
 else {
      command=command(ResolveTreeish.class).setTreeish(treeOid);
    }
  }
 else   if (treeIsh.equals(ObjectId.NULL.toString()) || RevTree.EMPTY_TREE_ID.toString().equals(treeIsh)) {
    tree=RevTree.EMPTY;
  }
 else {
    command=command(ResolveTreeish.class).setTreeish(treeIsh);
  }
  if (tree == null) {
    final Optional<ObjectId> treeId=command.call();
    checkArgument(treeId.isPresent(),treeIsh + "String_Node_Str");
    tree=source.getTree(treeId.get());
  }
  return tree;
}

Fixed version (ground truth):
private RevTree resolveTree(@Nullable final String treeIsh,@Nullable final ObjectId treeOid,final ObjectStore source){
  RevTree tree=null;
  ResolveTreeish command=null;
  if (treeOid != null) {
    if (ObjectId.NULL.equals(treeOid) || RevTree.EMPTY_TREE_ID.equals(treeOid)) {
      tree=RevTree.EMPTY;
    }
 else {
      command=command(ResolveTreeish.class).setSource(source).setTreeish(treeOid);
    }
  }
 else   if (treeIsh.equals(ObjectId.NULL.toString()) || RevTree.EMPTY_TREE_ID.toString().equals(treeIsh)) {
    tree=RevTree.EMPTY;
  }
 else {
    command=command(ResolveTreeish.class).setSource(source).setTreeish(treeIsh);
  }
  if (tree == null) {
    final Optional<ObjectId> treeId=command.call();
    checkArgument(treeId.isPresent(),treeIsh + "String_Node_Str");
    tree=source.getTree(treeId.get());
  }
  return tree;
}
Program: 113255
Project: 113255
Buggy source:
/** 
 * Executes the command.
 * @return the type of the object specified by the object id.
 * @throws IllegalArgumentException if the object doesn't exist
 */
@Override protected TYPE _call() throws IllegalArgumentException {
  RevObject o=objectDatabase().get(oid);
  return o.getType();
}

Fixed version (ground truth):
/** 
 * Executes the command.
 * @return the type of the object specified by the object id.
 * @throws IllegalArgumentException if the object doesn't exist
 */
@Override protected TYPE _call() throws IllegalArgumentException {
  ObjectStore source=this.source == null ? objectDatabase() : this.source;
  RevObject o=source.get(oid);
  return o.getType();
}