[Demonstration 1]

[Buggy Method]
public void update() {
    panel.removeAll();
    setBorder(BorderFactory.createLineBorder(Color.BLACK));
    GridBagConstraints c = new GridBagConstraints();
    List<Macro> macroList = Frame.getCalculator().getMacroList();
    if (macroList.size() == 0) {
        panel.add(new JLabel("no macros yet!"));
    } else {
        for (int i = 0; i < macroList.size(); i++) {
            Macro macro = macroList.get(i);
            c.gridy = i;
            c.fill = GridBagConstraints.BOTH;
            c.gridx = 0;
            JLabel label = new JLabel(String.format(" %s ", macro.getName()));
            label.setBorder(BorderFactory.createLineBorder(Color.BLACK));
            panel.add(label, c);
            c.gridx = 1;
            panel.add(new MacroButton("Run", (ActionEvent e) -> {
                Frame.getCalculator().setAndRunMacro(macro);
                Frame.getFrame().showCalculator();
            }), c);
            c.gridx = 2;
            panel.add(new MacroButton("Show", (ActionEvent e) -> {
                String listing = macro.getListing();
                String title = "Listing for Macro " + macro.getName();
                JOptionPane.showMessageDialog(Frame.getFrame(), listing, title, JOptionPane.INFORMATION_MESSAGE);
            }), c);
            c.gridx = 3;
            panel.add(new MacroButton("Rename", (ActionEvent e) -> {
                String name = (String) JOptionPane.showInputDialog(Frame.getFrame(), "New name?", macro.getName());
                if (!Frame.getCalculator().commandExists(name)) {
                    macro.setName(name.trim());
                    PanelMacro.this.update();
                }
            }), c);
            c.gridx = 4;
            panel.add(new MacroButton("Delete", (ActionEvent e) -> {
                String message = "Are you sure you want to delete macro " + macro.getName() + "?";
                int response = JOptionPane.showConfirmDialog(Frame.getFrame(), message);
                if (response == JOptionPane.YES_OPTION) {
                    Frame.getCalculator().removeMacro(macro);
                }
                PanelMacro.this.update();
            }), c);
        }
    }
    panel.revalidate();
}

[Buggy Hunk]
if (!Frame.getCalculator().commandExists(name)) {

[Patch]
if (!Frame.getCalculator().commandExists(name) && name != null) {

[Demonstration 2]

[Buggy Method]
@Override
public void render(Context ctx, Template template) {
    String contentType = template.getContentType();
    contentType = contentType == null ? "text/html" : contentType;
    try {
        ctx.getResponse().send(contentType, thymeleaf.process(template.getName(), template.getModel(), template.getFragmentSpec()));
    } catch (Exception e) {
        ctx.error(e);
    }
}

[Buggy Hunk]
ctx.getResponse().send(contentType, thymeleaf.process(template.getName(), template.getModel(), template.getFragmentSpec()));

[Patch]
ctx.getResponse().send(contentType, thymeleaf.process(template.getName(), template.getModel()));

[Demonstration 3]

[Buggy Method]
@Override
protected IStatus run(final IProgressMonitor monitor) {
    monitor.beginTask("LDAP_SEARCH", 100);
    Display.getDefault().syncExec(new Runnable() {

        @Override
        public void run() {
            btnSearch.setEnabled(false);
            btnSelectAllEntries.setEnabled(false);
            btnCreateSearchGroup.setEnabled(false);
            String filter = buildFilterClause();
            String[] returningAttributes = findReturningAttributes();
            monitor.worked(20);
            monitor.worked(40);
            // First, do LDAP search
            List<SearchResult> entries = LdapUtils.getInstance().searchAndReturnList(null, filter, returningAttributes, SearchControls.SUBTREE_SCOPE, 0, LdapConnectionListener.getConnection(), LdapConnectionListener.getMonitor());
            monitor.worked(80);
            if (entries != null && !entries.isEmpty()) {
                // Then, if 'agent' scope is selected,
                // Filter the entries by agent properties as well
                if (btnSearchAgents.getSelection()) {
                    // Then, filter these results by agent
                    // properties
                    Map<String, String> propFilter = buildPropertyMap();
                    if (propFilter != null && !propFilter.isEmpty()) {
                        // Read agents
                        queryAgents();
                        List<SearchResult> temp = new ArrayList<SearchResult>();
                        for (SearchResult entry : entries) {
                            String dn = entry.getName();
                            if (LdapUtils.getInstance().isAgent(entry.getAttributes().get("objectClass"))) {
                                Agent agent = findAgent(dn);
                                if (hasProperties(agent, propFilter)) {
                                    temp.add(entry);
                                }
                            } else if (btnSearchGroups.getSelection() || btnSearchUsers.getSelection()) {
                                temp.add(entry);
                            }
                        }
                        entries = temp;
                    }
                }
                recreateTable(returningAttributes);
                viewer.setInput(entries);
                redraw();
            } else {
                emptyTable(returningAttributes);
            }
            monitor.worked(100);
            monitor.done();
            btnSearch.setEnabled(true);
            btnSelectAllEntries.setEnabled(true);
            btnCreateSearchGroup.setEnabled(true);
        }
    });
    return Status.OK_STATUS;
}

[Buggy Hunk]
Map<String, String> propFilter = buildPropertyMap();

[Patch]
Map<String, AgentPropValueOperatorPair> propFilter = buildPropertyMap();