[Demonstration 1]

[Buggy Method]
public void AddSemanticallyRelatedRecipes(ArrayList<Recipe> recipeList) throws ExException {
    ArrayList<Recipe> result = new ArrayList<Recipe>();
    result = mergeRecipes(result, recipeList);
    Iterator<Recipe> recipeIterator = recipeList.iterator();
    while (recipeIterator.hasNext()) {
        Recipe r = recipeIterator.next();
        ArrayList<Tag> tags = getTags(r.id);
        Iterator<Tag> tagIterator = tags.iterator();
        while (tagIterator.hasNext()) {
            Tag t = tagIterator.next();
            ArrayList<Recipe> temp = searchByTagClass(t);
            result = mergeRecipes(result, temp);
            if (recipeList.size() >= 50)
                break;
        }
        if (recipeList.size() >= 50)
            break;
    }
    recipeList = mergeRecipes(recipeList, result);
}

[Buggy Hunk]
ArrayList<Recipe> temp = searchByTagClass(t);

[Patch]
ArrayList<Recipe> temp = searchByTag(t);

[Demonstration 2]

[Buggy Method]
private String printCollection(Collection<?> collection, int maxDepth, int curDepth) {
    StringBuilder sb = new StringBuilder();
    sb.append(collection.getClass().getSimpleName()).append(" size=").append(collection.size());
    if (collection.size() > 0) {
        sb.append(" [\n");
        for (Object item : collection) {
            sb.append(" ").append(toStr(item, maxDepth, curDepth + 1)).append(",\n");
        }
        if (sb.length() > 2) {
            sb.delete(sb.length() - 2, sb.length());
        }
        sb.append("\n]");
    } else {
        sb.append("\n");
    }
    return sb.toString();
}

[Buggy Hunk]
sb.append(" ").append(toStr(item,maxDepth,curDepth+1)).append(",\n");

[Patch]
sb.append(" ").append(toStr(item,maxDepth,curDepth+1, false)).append(",\n");

[Demonstration 3]

[Buggy Method]
public String scrambleTextWords(String aString) {
    StringBuilder result = new StringBuilder("");
    // current word to be scrambled when complete
    StringBuilder aWord = new StringBuilder("");
    for (int i = 0; i < aString.length(); i++) {
        // if there is a space it means a new word may have ended (or heading space case)
        if (aString.charAt(i) == ' ') {
            // if a word had started it is now ended
            if (!(aWord.toString().equals(""))) {
                // append the scrambled word to the result
                result.append(scrambleString(aWord.toString())).append(" ");
                // the current word is emptied
                aWord.delete(0, aWord.length() - 1);
            } else {
                // the space is added to the result (no current word)
                result.append(' ');
            }
        } else {
            // the current word is appended with the current character
            aWord.append(aString.charAt(i));
        }
    }
    // if there is still a current word (string not finishing by space)
    if (!(aWord.toString().equals(""))) {
        // append the scrambled word to the result
        result.append(scrambleString(aWord.toString()));
    }
    return result.toString();
}

[Buggy Hunk]
aWord.delete(0, aWord.length() - 1);

[Patch]
aWord.delete(0, aWord.length());