[Demonstration 1]

[Buggy Method]
@Override
public T pop() throws InterruptedException {
    try {
        permissionToModifyStack.acquire();
        if (empty())
            throw new EmptyStackException();
        final T element = stackVector[head];
        stackVector[head++] = null;
        return element;
    } finally {
        permissionToModifyStack.release();
    }
}

[Buggy Hunk]
stackVector[head++] = null;

[Patch]
stackVector[head--] = null;

[Demonstration 2]

[Buggy Method]
private void loadSelectedStandardTemplates(ConfigurationTemplateSettings.Builder settings) {
    final String[] inlineNames = listInlineTemplates();
    final TemplateResource[] templates = listTemplateResources();
    if (templates.length + inlineNames.length == 0)
        return;
    MultiDialog md = new MultiDialog("Select templates", new MultiDialog.BaseItems() {

        public int size() {
            return templates.length + inlineNames.length;
        }

        public String getFormattedName(int i) {
            if (i < inlineNames.length)
                return inlineNames[i];
            return templates[inlineNames.length + i].name;
        }
    });
    md.addSelected(settings.getSelectedStandardTemplatesList());
    md.showDialog();
    if (md.wasCanceled())
        return;
    ArrayList<String> selected = md.getSelectedResults();
    if (selected.isEmpty())
        return;
    // Save
    settings.clearSelectedStandardTemplates();
    settings.addAllSelectedStandardTemplates(selected);
    int count = 0;
    // Keep a hash of those not loaded from inline resources
    final HashSet<String> remaining = new HashSet<String>(selected.size());
    for (int i = 0; i < selected.size(); i++) {
        String name = selected.get(i);
        // Try and get the template from inline resources
        Template t = inlineTemplates.get(name);
        if (t != null) {
            count++;
            map.put(name, t);
        } else {
            remaining.add(name);
        }
    }
    if (!remaining.isEmpty()) {
        // Build a list of resources to load
        TurboList<TemplateResource> list = new TurboList<TemplateResource>(remaining.size());
        for (TemplateResource t : templates) {
            if (remaining.contains(t.name))
                list.add(t);
        }
        count += loadTemplateResources(list.toArray(new TemplateResource[list.size()]));
    }
    if (count > 0)
        saveDefaultTemplates();
    IJ.showMessage("Loaded " + TextUtils.pleural(count, "standard template"));
}

[Buggy Hunk]
return templates[inlineNames.length + i].name;

[Patch]
return templates[i - inlineNames.length].name;

[Demonstration 3]

[Buggy Method]
@Override
public //multipling of matrix is parallel
SparseMatrix multiply(SparseMatrix first, SparseMatrix second) {
    if (first.getNumberOfColumns() != second.getNumberOfRows()) {
        throw new RuntimeException("Number of columns of the first matrix must be equal to number of rows of the second.");
    }
    LOGGER.info("Calculation of resulting multiply matrix has been started.");
    SparseMatrix resultMatrix = new SparseMatrix(first.getNumberOfRows(), second.getNumberOfColumns(), concurrentlyMultiply(first, second));
    LOGGER.info("Calculation of resulting multiply matrix has been finished.");
    return resultMatrix;
}

[Buggy Hunk]
throw new RuntimeException("Number of columns of the first matrix must be equal to number of rows of the second.");

[Patch]
throw new IllegalArgumentException("Number of columns of the first matrix must be equal to number of rows of the second.");