[Demonstration 1]

[Buggy Method]
@Override
public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
    // Save parameters from storm
    this.conf = conf;
    this.context = context;
    this.collector = collector;
    Mongo mongo = null;
    DB db = null;
    // Open the db connection
    try {
        MongoURI uri = new MongoURI(this.url);
        // Create mongo instance
        mongo = new Mongo();
        // Get the db the user wants
        db = mongo.getDB(this.dbName);
        // If we need to authenticate do it
        if (uri.getUsername() != null) {
            db.authenticate(uri.getUsername(), uri.getPassword());
        }
    } catch (UnknownHostException e) {
        // Log the error
        LOG.error("Unknown host for Mongo DB", e);
        // Die fast
        throw new RuntimeException(e);
    }
    // Set up an executor
    this.task = new MongoTask(this.queue, mongo, db, this.collectionNames, this.query);
    // Start thread
    Thread thread = new Thread(this.task);
    thread.start();
}

[Buggy Hunk]
db = mongo.getDB(this.dbName);

[Patch]
db = mongo.getDB(this.dbName == null ? uri.getDatabase() : this.dbName);

[Demonstration 2]

[Buggy Method]
@Override
public DistributedScheduledFuture scheduleAtFixedRate(String taskName, Runnable runner, long delay, long period, TimeUnit timeUnit) throws DistributedScheduleException {
    if (!this.hzTrackingMap.containsKey(taskName)) {
        if (this.hzTrackingMap.tryLock(taskName)) {
            try {
                IScheduledFuture<?> future = this.hzScheduler.scheduleAtFixedRate(new HzDistributedRunnable(this.hzScheduler.getName(), taskName, this.hzTrackingMap.getName(), runner), delay, period, timeUnit);
                return prepareFuture(taskName, future);
            } finally {
                this.hzTrackingMap.unlock(taskName);
            }
        }
    }
    throw new DistributedScheduleException();
}

[Buggy Hunk]
.scheduleAtFixedRate(new HzDistributedRunnable(this.hzScheduler.getName(), taskName,

[Patch]
.scheduleAtFixedRate(new HzDistributedRunnable(this.hzScheduler.getName(), false, taskName,

[Demonstration 3]

[Buggy Method]
private static void putInScheduler(SensorAcq s) {
    //		if (s.getDir() == OUTPUT_CHAR)
    //			return;
    ScheduledFuture<SensorAcq> future = (ScheduledFuture<SensorAcq>) scheduler.scheduleAtFixedRate(s, 0, s.getDelay(), TimeUnit.MILLISECONDS);
    s.setFuture(future);
}

[Buggy Hunk]
ScheduledFuture<SensorAcq> future = (ScheduledFuture<SensorAcq>)scheduler.scheduleAtFixedRate(s, 0, s.getDelay(), TimeUnit.MILLISECONDS);

[Patch]
ScheduledFuture<SensorAcq> future = (ScheduledFuture<SensorAcq>)scheduler.scheduleWithFixedDelay(s, 0, s.getDelay(), TimeUnit.MILLISECONDS);