[Demonstration 1]

[Buggy Method]
@RequestMapping(method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
public String getWorkTypes() {
    StringBuilder result = new StringBuilder();
    result.append("<table>").append(NL).append("<tr><td>").append(labelFor("type", "Type")).append("</td><td><select id='type' onchange='typeChanged()'>");
    for (String type : service.getTypes()) {
        result.append("<option value='").append(type).append("'>").append(type).append("</option>");
    }
    result.append("</select></td></tr>").append(NL).append("<tr><td>").append(labelFor("category", "Category")).append("</td><td><select id='category' onchange='categoryChanged()'></select></td></tr>").append(NL).append("<tr><td>").append(labelFor("subcategory", "Sub-category")).append("</td><td><select id='subcategory'></select></td></tr>").append(NL).append("</table>").append(NL);
    return result.toString();
}

[Buggy Hunk]
StringBuilder result = new StringBuilder();

[Patch]
StringBuilder result = new StringBuilder(512);

[Demonstration 2]

[Buggy Method]
private static List<Pack> processInputs(Configuration configuration, List<Item> items) {
    System.out.println("Processing outputs\n");
    List<Pack> packs = new ArrayList<Pack>();
    List<Item> sortedItems = sortItems(configuration.sortOrder, items);
    int packId = 1;
    Pack currentPack = new Pack(packId++);
    packs.add(currentPack);
    for (Item sortedItem : sortedItems) {
        Item currentItem = new Item(sortedItem.id, sortedItem.length, 0, sortedItem.weight);
        currentPack.items.add(currentItem);
        for (int i = 0; i < sortedItem.quantity; i++) {
            if (currentPack.quantity + 1 <= configuration.maxPiecesPerPack && currentPack.weight + currentItem.weight <= configuration.maxWeightPerPack) {
                currentItem.quantity++;
                currentPack.quantity++;
                currentPack.weight += currentItem.weight;
                if (sortedItem.length > currentPack.length) {
                    currentPack.length = sortedItem.length;
                }
            } else {
                currentPack = new Pack(packId++);
                packs.add(currentPack);
                currentItem = new Item(sortedItem.id, sortedItem.length, 1, sortedItem.weight);
                currentPack.items.add(currentItem);
                currentPack.length = sortedItem.length;
            }
        }
    }
    return packs;
}

[Buggy Hunk]
private static List<Pack> processInputs(Configuration configuration, List<Item> items) {

[Patch]
public static List<Pack> processInputs(Configuration configuration, List<Item> items) {

[Demonstration 3]

[Buggy Method]
private static Column resolveColumnWithQualifier(LogicalPlan plan, LogicalPlan.QueryBlock block, ColumnReferenceExpr columnRef) throws PlanningException {
    final String qualifier;
    String canonicalName;
    final String qualifiedName;
    Pair<String, String> normalized = lookupQualifierAndCanonicalName(block, columnRef);
    qualifier = normalized.getFirst();
    canonicalName = normalized.getSecond();
    qualifiedName = CatalogUtil.buildFQName(qualifier, columnRef.getName());
    Column found = resolveFromRelsWithinBlock(plan, block, columnRef);
    if (found == null) {
        throw new NoSuchColumnException(columnRef.getCanonicalName());
    }
    // If code reach here, a column is found.
    // But, it may be aliased from bottom logical node.
    // If the column is aliased, the found name may not be used in upper node.
    // Here, we try to check if column reference is already aliased.
    // If so, it replaces the name with aliased name.
    LogicalNode currentNode = block.getCurrentNode();
    // The condition (currentNode.getInSchema().contains(column)) means
    // the column can be used at the current node. So, we don't need to find aliase name.
    Schema currentNodeSchema = null;
    if (currentNode != null) {
        if (currentNode instanceof RelationNode) {
            currentNodeSchema = ((RelationNode) currentNode).getLogicalSchema();
        } else {
            currentNodeSchema = currentNode.getInSchema();
        }
    }
    if (currentNode != null && !currentNodeSchema.contains(found) && currentNode.getType() != NodeType.TABLE_SUBQUERY) {
        List<Column> candidates = TUtil.newList();
        if (block.getNamedExprsManager().isAliased(qualifiedName)) {
            String alias = block.getNamedExprsManager().getAlias(canonicalName);
            found = resolve(plan, block, new ColumnReferenceExpr(alias), NameResolvingMode.LEGACY);
            if (found != null) {
                candidates.add(found);
            }
        }
        if (!candidates.isEmpty()) {
            return ensureUniqueColumn(candidates);
        }
    }
    return found;
}

[Buggy Hunk]
String alias = block.getNamedExprsManager().getAlias(canonicalName);

[Patch]
String alias = block.getNamedExprsManager().getAlias(qualifiedName);