[Demonstration 1]

[Buggy Method]
public boolean start(Writer writer) {
    //Create an iterator status if the status attribute was set.
    if (statusAttr != null) {
        statusState = new IteratorStatus.StatusState();
        status = new IteratorStatus(statusState);
    }
    if (beginStr != null)
        begin = (Integer) findValue(beginStr, Integer.class);
    if (endStr != null)
        end = (Integer) findValue(endStr, Integer.class);
    if (stepStr != null)
        step = (Integer) findValue(stepStr, Integer.class);
    ValueStack stack = getStack();
    if (value == null && begin == null && end == null) {
        value = "top";
    }
    Object iteratorTarget = findValue(value);
    iterator = MakeIterator.convert(iteratorTarget);
    if (begin != null) {
        //default step to 1
        if (step == null)
            step = 1;
        if (iterator == null) {
            //classic for loop from 'begin' to 'end'
            iterator = new CounterIterator(begin, end, step, null);
        } else {
            //only arrays and lists are supported
            if (iteratorTarget.getClass().isArray()) {
                Object[] values = (Object[]) iteratorTarget;
                if (end == null)
                    end = step > 0 ? values.length - 1 : 0;
                iterator = new CounterIterator(begin, end, step, Arrays.asList(values));
            } else if (iteratorTarget instanceof List) {
                List values = (List) iteratorTarget;
                if (end == null)
                    end = step > 0 ? values.size() - 1 : 0;
                iterator = new CounterIterator(begin, end, step, values);
            } else {
                //so the iterator is not based on an array or a list
                LOG.error("Incorrect use of the iterator tag. When 'begin' is set, 'value' must be" + " an Array or a List, or not set at all. 'begin', 'end' and 'step' will be ignored");
            }
        }
    }
    // get the first
    if ((iterator != null) && iterator.hasNext()) {
        Object currentValue = iterator.next();
        stack.push(currentValue);
        String var = getVar();
        if ((var != null) && (currentValue != null)) {
            putInContext(currentValue);
        }
        // Status object
        if (statusAttr != null) {
            statusState.setLast(!iterator.hasNext());
            oldStatus = stack.getContext().get(statusAttr);
            stack.getContext().put(statusAttr, status);
        }
        return true;
    } else {
        super.end(writer, "");
        return false;
    }
}

[Buggy Hunk]
if ((var != null) && (currentValue != null)) {

[Patch]
if ((var != null)) {

[Demonstration 2]

[Buggy Method]
public static void main(String[] argv) throws IOException {
    Annotator annotator = new NERAnnotator();
    Server server = new Server(5757, null, annotator);
    fi.iki.elonen.util.ServerRunner.executeInstance(server);
}

[Buggy Hunk]
Server server = new Server(5757, null, annotator);

[Patch]
Server server = new Server(5757, new ServerPreferences(0, 50), annotator);

[Demonstration 3]

[Buggy Method]
protected static Trie nodeProbabilitiesRec(Trie tr) {
    double chSum = 0;
    if (tr == null || tr.getChildren() == null || tr.getChildren().isEmpty()) {
        return tr;
    }
    if (tr.getValue() == 0) {
        chSum = 0;
        for (Trie ch : tr.getChildren().values()) {
            chSum += ch.getValue();
        }
    } else {
        chSum = tr.getValue();
    }
    Map<String, Trie> resChildren = new HashMap<>();
    for (Map.Entry<String, Trie> elem : tr.getChildren().entrySet()) {
        Trie chNode = nodeProbabilitiesRec(elem.getValue());
        chNode.setValue(chNode.getValue() / chSum);
        resChildren.put(elem.getKey(), chNode);
    }
    return new Trie(tr.getKey(), tr.getValue(), resChildren);
}

[Buggy Hunk]
return tr;

[Patch]
return new Trie( tr.getKey(), tr.getValue() );