[Demonstration 1]

[Buggy Method]
List<Edge> getPointingEdges(Synset pointedSynset) {
    ValueFactory factory = repository.getValueFactory();
    String queryString = String.format("SELECT ?edgeType ?edge" + " WHERE { ?pointedSynset <%s> %s . ?originSynset ?edge ?pointedSynset . ?edge <%s> ?edgeType . ?edgeType <%s> <%s> }", SR.ID, factory.createLiteral(pointedSynset.getId()), RDF.TYPE, RDFS.SUBCLASSOF, SR.EDGE, RDF.TYPE);
    return getEdges(queryString);
}

[Buggy Hunk]
SR.ID, factory.createLiteral(pointedSynset.getId()), RDF.TYPE, RDFS.SUBCLASSOF, SR.EDGE, RDF.TYPE);

[Patch]
SR.ID, factory.createLiteral(pointedSynset.getId()), RDF.TYPE, RDFS.SUBCLASSOF, SR.EDGE);

[Demonstration 2]

[Buggy Method]
@Override
public void execute(Tuple tuple) {
    String url = tuple.getStringByField("url");
    Status status = (Status) tuple.getValueByField("status");
    boolean potentiallyNew = status.equals(Status.DISCOVERED);
    // if the URL is a freshly discovered one
    // check whether it is already known in the cache
    // if so we've already seen it and don't need to
    // store it again
    if (potentiallyNew && useCache) {
        if (cache.getIfPresent(url) != null) {
            // no need to add it to the queue
            LOG.debug("URL {} already in cache", url);
            cacheHits++;
            _collector.ack(tuple);
            return;
        } else {
            LOG.debug("URL {} not in cache", url);
            cacheMisses++;
        }
    }
    Metadata metadata = (Metadata) tuple.getValueByField("metadata");
    // store last processed or discovery date
    final String nowAsString = dateFormat.format(new Date());
    if (status.equals(Status.DISCOVERED)) {
        metadata.setValue("discoveryDate", nowAsString);
    } else {
        metadata.setValue("lastProcessedDate", nowAsString);
    }
    // too many fetch errors?
    if (status.equals(Status.FETCH_ERROR)) {
        String errorCount = metadata.getFirstValue(Constants.fetchErrorCountParamName);
        int count = 0;
        try {
            count = Integer.parseInt(errorCount);
        } catch (NumberFormatException e) {
        }
        count++;
        if (count == maxFetchErrors) {
            status = Status.ERROR;
            metadata.setValue(Constants.STATUS_ERROR_CAUSE, "maxFetchErrors");
        } else {
            metadata.setValue(Constants.fetchErrorCountParamName, Integer.toString(count));
        }
    }
    // delete any existing error count metadata
    // e.g. status changed
    if (!status.equals(Status.FETCH_ERROR)) {
        metadata.remove(Constants.fetchErrorCountParamName);
    }
    // https://github.com/DigitalPebble/storm-crawler/issues/415
    // remove error related key values in case of success
    if (status.equals(Status.FETCHED) || status.equals(Status.REDIRECTION)) {
        metadata.remove(Constants.STATUS_ERROR_CAUSE);
        metadata.remove(Constants.STATUS_ERROR_MESSAGE);
        metadata.remove(Constants.STATUS_ERROR_SOURCE);
    }
    // determine the value of the next fetch based on the status
    Date nextFetch = scheduler.schedule(status, metadata);
    // filter metadata just before storing it, so that non-persisted
    // metadata is available to fetch schedulers
    metadata = mdTransfer.filter(metadata);
    // extensions of this class will handle the storage
    // on a per document basis
    try {
        store(url, status, metadata, nextFetch);
    } catch (Exception e) {
        LOG.error("Exception caught when storing", e);
        _collector.fail(tuple);
        return;
    }
    // gone? notify any deleters. Doesn't need to be anchored
    if (status == Status.ERROR) {
        _collector.emit(Constants.DELETION_STREAM_NAME, new Values(url));
    }
    ack(tuple, url);
}

[Buggy Hunk]
if (count == maxFetchErrors) {

[Patch]
if (count >= maxFetchErrors) {

[Demonstration 3]

[Buggy Method]
private void calculateHoursWork(final WorkDay workDay) throws ErrorEvent {
    long workLong = 0;
    if (workDay.getEnd() != null) {
        workLong = workDay.getEnd().getTime() - workDay.getStart().getTime();
        Pauses pauses = workDay.getPauses();
        for (Pause pause : pauses) {
            long pauseLong = pause.getEnd().getTime() - pause.getStart().getTime();
            workLong -= pauseLong;
        }
    } else if (workDay == timeSheet.getLastWorkDay()) {
        workLong = new Date().getTime() - workDay.getStart().getTime();
        Pauses pauses = workDay.getPauses();
        for (Pause pause : pauses) {
            long pauseLong = new Date().getTime() - pause.getStart().getTime();
            workLong -= pauseLong;
        }
    }
    workDay.setHoursWork(workLong / CONVERT_MILLISECONDS_TO_HOURS);
}

[Buggy Hunk]
long pauseLong = new Date().getTime() - pause.getStart().getTime();

[Patch]
long pauseLong = pause.getEnd().getTime() - pause.getStart().getTime();