Program: 7967
Project: 7967
Buggy source:
@Override public boolean compareAndSwapDirty(byte[] row,byte[] column,byte[] expectedValue,byte[] newValue) throws OperationException {
  PreparedStatement ps=null;
  Boolean oldAutoCommitValue=null;
  Integer oldTransactionIsolation=null;
  try {
    oldAutoCommitValue=this.connection.getAutoCommit();
    oldTransactionIsolation=this.connection.getTransactionIsolation();
    this.connection.setAutoCommit(false);
    this.connection.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
    ps=this.connection.prepareStatement("String_Node_Str" + "String_Node_Str" + this.quotedTableName + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
    ps.setBytes(1,row);
    ps.setBytes(2,column);
    ResultSet result=ps.executeQuery();
    ImmutablePair<Long,byte[]> latest=latest(result);
    byte[] existingValue=latest == null ? null : latest.getSecond();
    ps.close();
    ps=null;
    if ((existingValue == null && expectedValue == null) || Bytes.equals(existingValue,expectedValue)) {
      if (newValue == null || newValue.length == 0) {
        deleteAll(row,column,latest.getFirst());
        ps=this.connection.prepareStatement("String_Node_Str" + this.quotedTableName + "String_Node_Str"+ "String_Node_Str");
        ps.setBytes(1,row);
        ps.setBytes(2,column);
        ps.setLong(3,TransactionOracle.DIRTY_WRITE_VERSION);
        ps.executeUpdate();
      }
 else {
        if (existingValue == null) {
          ps=this.connection.prepareStatement("String_Node_Str" + this.quotedTableName + "String_Node_Str");
          ps.setBytes(1,row);
          ps.setBytes(2,column);
          ps.setLong(3,TransactionOracle.DIRTY_WRITE_VERSION);
          ps.setInt(4,Type.VALUE.i);
          ps.setBytes(5,newValue);
          ps.executeUpdate();
        }
 else {
          ps=this.connection.prepareStatement("String_Node_Str" + this.quotedTableName + "String_Node_Str"+ "String_Node_Str");
          ps.setBytes(1,newValue);
          ps.setBytes(2,row);
          ps.setBytes(3,column);
          ps.setLong(4,TransactionOracle.DIRTY_WRITE_VERSION);
          ps.executeUpdate();
        }
      }
      this.connection.commit();
      return true;
    }
    return false;
  }
 catch (  SQLException e) {
    throw createOperationException(e,"String_Node_Str");
  }
 finally {
    try {
      if (oldAutoCommitValue != null) {
        this.connection.setAutoCommit(oldAutoCommitValue);
      }
      if (oldTransactionIsolation != null) {
        this.connection.setTransactionIsolation(oldTransactionIsolation);
      }
      if (ps != null) {
        ps.close();
      }
    }
 catch (    SQLException e) {
      throw createOperationException(e,"String_Node_Str");
    }
  }
}

Fixed version (ground truth):
@Override public boolean compareAndSwapDirty(byte[] row,byte[] column,byte[] expectedValue,byte[] newValue) throws OperationException {
  PreparedStatement ps=null;
  Boolean oldAutoCommitValue=null;
  Integer oldTransactionIsolation=null;
  try {
    oldAutoCommitValue=this.connection.getAutoCommit();
    oldTransactionIsolation=this.connection.getTransactionIsolation();
    this.connection.setAutoCommit(false);
    this.connection.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
    ps=this.connection.prepareStatement("String_Node_Str" + "String_Node_Str" + this.quotedTableName + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
    ps.setBytes(1,row);
    ps.setBytes(2,column);
    ResultSet result=ps.executeQuery();
    ImmutablePair<Long,byte[]> latest=latest(result);
    byte[] existingValue=latest == null ? null : latest.getSecond();
    ps.close();
    ps=null;
    if ((existingValue == null && expectedValue == null) || Bytes.equals(existingValue,expectedValue)) {
      if (newValue == null || newValue.length == 0) {
        deleteAll(row,column,latest.getFirst());
        ps=this.connection.prepareStatement("String_Node_Str" + this.quotedTableName + "String_Node_Str"+ "String_Node_Str");
        ps.setBytes(1,row);
        ps.setBytes(2,column);
        ps.setLong(3,TransactionOracle.DIRTY_WRITE_VERSION);
        ps.executeUpdate();
      }
 else {
        if (existingValue == null) {
          ps=this.connection.prepareStatement("String_Node_Str" + this.quotedTableName + "String_Node_Str"+ "String_Node_Str");
          ps.setBytes(1,row);
          ps.setBytes(2,column);
          ps.setLong(3,TransactionOracle.DIRTY_WRITE_VERSION);
          ps.setInt(4,Type.VALUE.i);
          ps.setBytes(5,newValue);
          ps.executeUpdate();
        }
 else {
          ps=this.connection.prepareStatement("String_Node_Str" + this.quotedTableName + "String_Node_Str"+ "String_Node_Str");
          ps.setBytes(1,newValue);
          ps.setBytes(2,row);
          ps.setBytes(3,column);
          ps.setLong(4,TransactionOracle.DIRTY_WRITE_VERSION);
          ps.executeUpdate();
        }
      }
      this.connection.commit();
      return true;
    }
    return false;
  }
 catch (  SQLException e) {
    throw createOperationException(e,"String_Node_Str");
  }
 finally {
    try {
      if (oldAutoCommitValue != null) {
        this.connection.setAutoCommit(oldAutoCommitValue);
      }
      if (oldTransactionIsolation != null) {
        this.connection.setTransactionIsolation(oldTransactionIsolation);
      }
      if (ps != null) {
        ps.close();
      }
    }
 catch (    SQLException e) {
      throw createOperationException(e,"String_Node_Str");
    }
  }
}