[Demonstration 1]

[Buggy Method]
@Override
public double scoreTerm(String term) {
    FeatureVector docVector = doc.getFeatureVector();
    double wordCount = docVector.getFeatureWeight(term);
    double docLength = docVector.getLength();
    double colProb = epsilon + collectionStats.termCount(term) / collectionStats.getTokCount();
    double score = (wordCount + mu * colProb) / (docLength + mu);
    return score;
}

[Buggy Hunk]
double colProb = epsilon + collectionStats.termCount(term) / collectionStats.getTokCount();

[Patch]
double colProb = (epsilon + collectionStats.termCount(term)) / collectionStats.getTokCount();

[Demonstration 2]

[Buggy Method]
private void startFsyncThread() {
    final Thread fsyncThread = new Thread() {

        @Override
        public void run() {
            while (true) {
                ObjectOutputStream stream = null;
                try {
                    stream = new ObjectOutputStream(new FileOutputStream(FSYNC_FILENAME));
                    stream.writeObject(mMessages.getNodes());
                    Thread.sleep(30000);
                } catch (Exception e) {
                    System.out.println(e);
                } finally {
                    try {
                        stream.close();
                    } catch (Exception e) {
                        // No big deal!
                    }
                }
            }
        }
    };
    fsyncThread.start();
}

[Buggy Hunk]
stream.writeObject(mMessages.getNodes());

[Patch]
stream.writeObject(mMessages.getValues());

[Demonstration 3]

[Buggy Method]
@OnMessage(NetMessages.CSVCMsg_PacketEntities.class)
public void onPacketEntities(Context ctx, NetMessages.CSVCMsg_PacketEntities message) {
    BitStream stream = new BitStream(message.getEntityData());
    DTClasses dtClasses = ctx.getProcessor(DTClasses.class);
    int updateCount = message.getUpdatedEntries();
    int entityIndex = -1;
    int cmd;
    int clsId;
    DTClass cls;
    int serial;
    Object[] state;
    Entity entity;
    boolean debug = false;
    if (debug) {
        System.out.println(ctx.getBuildNumber());
    }
    while (updateCount-- != 0) {
        entityIndex += stream.readUBitVar() + 1;
        cmd = stream.readUBitInt(2);
        if ((cmd & 1) == 0) {
            if ((cmd & 2) != 0) {
                clsId = stream.readUBitInt(dtClasses.getClassBits());
                cls = dtClasses.forClassId(clsId);
                if (cls == null) {
                    throw new RuntimeException(String.format("class for new entity %d is %d, but no dtClass found!.", entityIndex, clsId));
                }
                serial = stream.readUBitInt(engineType.getSerialBits());
                if (engineType == EngineType.SOURCE2) {
                    // TODO: there is an extra VarInt encoded here for S2, figure out what it is
                    stream.readVarUInt();
                }
                state = Util.clone(getBaseline(dtClasses, cls.getClassId()));
                fieldReader.readFields(stream, cls, state, debug);
                entity = new Entity(ctx.getEngineType(), entityIndex, serial, cls, true, state);
                entities[entityIndex] = entity;
                if (evCreated != null) {
                    evCreated.raise(entity);
                }
                if (evEntered != null) {
                    evEntered.raise(entity);
                }
            } else {
                entity = entities[entityIndex];
                if (entity == null) {
                    throw new RuntimeException(String.format("entity at index %d was not found for update.", entityIndex));
                }
                cls = entity.getDtClass();
                state = entity.getState();
                int nChanged = fieldReader.readFields(stream, cls, state, debug);
                if (evUpdated != null) {
                    evUpdated.raise(entity, fieldPaths, nChanged);
                }
                if (!entity.isActive()) {
                    entity.setActive(true);
                    if (evEntered != null) {
                        evEntered.raise(entity);
                    }
                }
            }
        } else {
            entity = entities[entityIndex];
            if (entity == null) {
                log.warn("entity at index {} was not found when ordered to leave.", entityIndex);
            } else {
                if (entity.isActive()) {
                    entity.setActive(false);
                    if (evLeft != null) {
                        evLeft.raise(entity);
                    }
                }
                if ((cmd & 2) != 0) {
                    entities[entityIndex] = null;
                    if (evDeleted != null) {
                        evDeleted.raise(entity);
                    }
                }
            }
        }
    }
    if (message.getIsDelta()) {
        int n = fieldReader.readDeletions(stream, engineType.getIndexBits(), deletions);
        for (int i = 0; i < n; i++) {
            entityIndex = deletions[i];
            entity = entities[entityIndex];
            if (entity != null) {
                log.warn("entity at index {} was ACTUALLY found when ordered to delete, tell the press!", entityIndex);
                if (entity.isActive()) {
                    entity.setActive(false);
                    if (evLeft != null) {
                        evLeft.raise(entity);
                    }
                }
                if (evDeleted != null) {
                    evDeleted.raise(entity);
                }
            } else {
                //log.warn("entity at index {} was not found when ordered to delete.", entityIndex);
            }
            entities[entityIndex] = null;
        }
    }
}

[Buggy Hunk]
evUpdated.raise(entity, fieldPaths, nChanged);

[Patch]
evUpdated.raise(entity, fieldReader.getFieldPaths(), nChanged);