Program: 8017
Project: 8017
Buggy source:
@Override public void compareAndSwap(byte[] row,byte[] column,byte[] expectedValue,byte[] newValue,ReadPointer readPointer,long writeVersion) throws OperationException {
  byte[] expectedPrependedValue=null;
  KeyValue latestVisibleKV=null;
  try {
    Get get=new Get(row);
    get.addColumn(this.family,column);
    get.setTimeRange(0,getMaxStamp(readPointer));
    get.setMaxVersions();
    Result result=this.readTable.get(get);
    KeyValue[] rawResults=result.raw();
    if (rawResults != null && rawResults.length != 0) {
      expectedPrependedValue=rawResults[0].getValue();
      Set<Long> deleted=Sets.newHashSet();
      for (      KeyValue kv : result.raw()) {
        long version=kv.getTimestamp();
        if (!readPointer.isVisible(version) || deleted.contains(version)) {
          continue;
        }
        byte[] value=kv.getValue();
        byte typePrefix=value[0];
        if (typePrefix == DATA) {
          latestVisibleKV=kv;
          break;
        }
 else         if (typePrefix == DELETE_VERSION) {
          deleted.add(version);
        }
 else         if (typePrefix == DELETE_ALL) {
          latestVisibleKV=null;
          break;
        }
      }
    }
    if (equalValues(latestVisibleKV,expectedValue)) {
      byte[] newPrependedValue;
      if (newValue == null) {
        newPrependedValue=DELETE_ALL_VALUE;
      }
 else {
        newPrependedValue=prependWithTypePrefix(DATA,newValue);
      }
      if (this.readTable.checkAndPut(row,this.family,column,expectedPrependedValue,readPointer.getMaximum(),new Put(row).add(this.family,column,writeVersion,newPrependedValue))) {
        return;
      }
    }
    throw new OperationException(StatusCode.WRITE_CONFLICT,"String_Node_Str");
  }
 catch (  IOException e) {
    this.exceptionHandler.handle(e);
  }
}

Fixed version (ground truth):
@Override public void compareAndSwap(byte[] row,byte[] column,byte[] expectedValue,byte[] newValue,ReadPointer readPointer,long writeVersion) throws OperationException {
  byte[] expectedPrependedValue=null;
  KeyValue latestVisibleKV=null;
  HTable writeTable=null;
  try {
    Get get=new Get(row);
    get.addColumn(this.family,column);
    get.setTimeRange(0,getMaxStamp(readPointer));
    get.setMaxVersions();
    Result result=this.readTable.get(get);
    KeyValue[] rawResults=result.raw();
    if (rawResults != null && rawResults.length != 0) {
      expectedPrependedValue=rawResults[0].getValue();
      Set<Long> deleted=Sets.newHashSet();
      for (      KeyValue kv : result.raw()) {
        long version=kv.getTimestamp();
        if (!readPointer.isVisible(version) || deleted.contains(version)) {
          continue;
        }
        byte[] value=kv.getValue();
        byte typePrefix=value[0];
        if (typePrefix == DATA) {
          latestVisibleKV=kv;
          break;
        }
 else         if (typePrefix == DELETE_VERSION) {
          deleted.add(version);
        }
 else         if (typePrefix == DELETE_ALL) {
          latestVisibleKV=null;
          break;
        }
      }
    }
    if (equalValues(latestVisibleKV,expectedValue)) {
      byte[] newPrependedValue;
      if (newValue == null) {
        newPrependedValue=DELETE_ALL_VALUE;
      }
 else {
        newPrependedValue=prependWithTypePrefix(DATA,newValue);
      }
      writeTable=getWriteTable();
      writeTable.put(new Put(row).add(this.family,column,writeVersion,newPrependedValue));
    }
 else {
      throw new OperationException(StatusCode.WRITE_CONFLICT,"String_Node_Str");
    }
  }
 catch (  IOException e) {
    this.exceptionHandler.handle(e);
  }
 finally {
    if (writeTable != null)     returnWriteTable(writeTable);
  }
}