[Demonstration 1]

[Buggy Method]
@Override
public int compareTo(Object o) {
    Dica other = (Dica) o;
    return Integer.compare(other.getAprovacao(), this.getAprovacao());
}

[Buggy Hunk]
return Integer.compare(other.getAprovacao(), this.getAprovacao());

[Patch]
return Integer.compare(other.getAprovacao(), this.getAprovacao()) == 0? -1:Integer.compare(other.getAprovacao(), this.getAprovacao());

[Demonstration 2]

[Buggy Method]
@Test
public void testScrubOutOfOrder() throws Exception {
    // This test assumes ByteOrderPartitioner to create out-of-order SSTable
    IPartitioner oldPartitioner = DatabaseDescriptor.getPartitioner();
    DatabaseDescriptor.setPartitionerUnsafe(new ByteOrderedPartitioner());
    // Create out-of-order SSTable
    File tempDir = File.createTempFile("ScrubTest.testScrubOutOfOrder", "").getParentFile();
    // create ks/cf directory
    File tempDataDir = new File(tempDir, String.join(File.separator, KEYSPACE, CF3));
    tempDataDir.mkdirs();
    try {
        CompactionManager.instance.disableAutoCompaction();
        Keyspace keyspace = Keyspace.open(KEYSPACE);
        String columnFamily = CF3;
        ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(columnFamily);
        cfs.clearUnsafe();
        List<String> keys = Arrays.asList("t", "a", "b", "z", "c", "y", "d");
        String filename = cfs.getSSTablePath(tempDataDir);
        Descriptor desc = Descriptor.fromFilename(filename);
        LifecycleTransaction txn = LifecycleTransaction.offline(OperationType.WRITE, desc.directory);
        try (SSTableTxnWriter writer = new SSTableTxnWriter(txn, createTestWriter(desc, (long) keys.size(), cfs.metadata, txn))) {
            for (String k : keys) {
                PartitionUpdate update = UpdateBuilder.create(cfs.metadata, Util.dk(k)).newRow("someName").add("val", "someValue").build();
                writer.append(update.unfilteredIterator());
            }
            writer.finish(false);
        }
        try {
            SSTableReader.open(desc, cfs.metadata);
            fail("SSTR validation should have caught the out-of-order rows");
        } catch (IllegalStateException ise) {
            /* this is expected */
        }
        // open without validation for scrubbing
        Set<Component> components = new HashSet<>();
        if (new File(desc.filenameFor(Component.COMPRESSION_INFO)).exists())
            components.add(Component.COMPRESSION_INFO);
        components.add(Component.DATA);
        components.add(Component.PRIMARY_INDEX);
        components.add(Component.FILTER);
        components.add(Component.STATS);
        components.add(Component.SUMMARY);
        components.add(Component.TOC);
        SSTableReader sstable = SSTableReader.openNoValidation(desc, components, cfs);
        if (sstable.last.compareTo(sstable.first) < 0)
            sstable.last = sstable.first;
        try (LifecycleTransaction scrubTxn = LifecycleTransaction.offline(OperationType.SCRUB, sstable);
            Scrubber scrubber = new Scrubber(cfs, scrubTxn, false, true, true)) {
            scrubber.scrub();
        }
        LifecycleTransaction.waitForDeletions();
        cfs.loadNewSSTables();
        assertOrderedAll(cfs, 7);
    } finally {
        FileUtils.deleteRecursive(tempDataDir);
        // reset partitioner
        DatabaseDescriptor.setPartitionerUnsafe(oldPartitioner);
    }
}

[Buggy Hunk]
LifecycleTransaction txn = LifecycleTransaction.offline(OperationType.WRITE, desc.directory);

[Patch]
LifecycleTransaction txn = LifecycleTransaction.offline(OperationType.WRITE);

[Demonstration 3]

[Buggy Method]
private int getBucketIndex(double value) {
    // Is value out of bucket range?
    if (Double.compare(value, minV) < 0 || Double.compare(value, maxV) > 0) {
        return -1;
    }
    return (int) Math.floor((value - minV) / step);
}

[Buggy Hunk]
if (Double.compare(value, minV) < 0 || Double.compare(value, maxV) > 0){

[Patch]
if (Double.compare(value, minV) < 0 || Double.compare(value, maxV) >= 0){