[Demonstration 1]

[Buggy Method]
public static DescriptorExtensionList<ContainerAdapter, ContainerAdapterDescriptor> all() {
    return Jenkins.getInstance().<ContainerAdapter, ContainerAdapterDescriptor>getDescriptorList(ContainerAdapter.class);
}

[Buggy Hunk]
return Jenkins.getInstance().<ContainerAdapter,ContainerAdapterDescriptor>getDescriptorList(ContainerAdapter.class);

[Patch]
return Jenkins.getActiveInstance().<ContainerAdapter,ContainerAdapterDescriptor>getDescriptorList(ContainerAdapter.class);

[Demonstration 2]

[Buggy Method]
@Override
public void actionPerformed(ActionEvent e) {
    int action = fc.showOpenDialog(mainFrame);
    final File[] files = fc.getSelectedFiles();
    if (action != JFileChooser.APPROVE_OPTION || files.length == 0)
        return;
    processor.reset();
    invalidFiles = new StringBuffer();
    resetGui();
    //create a new dialog containing 2 progress bars
    fileProcessingDialog = new ProgressBarDialog();
    new Thread(new Runnable() {

        public void run() {
            processor.processInputFiles(files);
            setTitleRootCaseFrame(processor.getRootCases().size() + " Transactions");
            // remove the old model
            List<RmRootCase> rootCases = processor.getRootCases();
            if (rootCases != null && !rootCases.isEmpty()) {
                final RootCaseTableModel rootCaseModel = new RootCaseTableModel(rootCases);
                rootCaseTable.setModel(rootCaseModel);
                // the width is currently hard coded and could be gathered from data in future
                rootCaseTable.getColumnModel().getColumn(RootCaseTableModel.FILE_COLUMN_INDEX).setMinWidth(215);
                rootCaseTable.getColumnModel().getColumn(RootCaseTableModel.FILE_COLUMN_INDEX).setMaxWidth(515);
                rootCaseTable.getColumnModel().getColumn(RootCaseTableModel.TIMESTAMP_COLUMN_INDEX).setMinWidth(170);
                rootCaseTable.getColumnModel().getColumn(RootCaseTableModel.TIMESTAMP_COLUMN_INDEX).setMaxWidth(200);
                rootCaseTable.getColumnModel().getColumn(RootCaseTableModel.ELAPSEDTIME_COLUMN_INDEX).setMinWidth(100);
                rootCaseTable.getColumnModel().getColumn(RootCaseTableModel.ELAPSEDTIME_COLUMN_INDEX).setMaxWidth(100);
                rootCaseTable.getColumnModel().getColumn(RootCaseTableModel.TYPE_COLUMN_INDEX).setMinWidth(140);
                rootCaseTable.getColumnModel().getColumn(RootCaseTableModel.TYPE_COLUMN_INDEX).setMaxWidth(140);
                rootCaseTable.getColumnModel().getColumn(RootCaseTableModel.REQUESTID_COLUMN_INDEX).setMinWidth(85);
                rootCaseTable.getColumnModel().getColumn(RootCaseTableModel.REQUESTID_COLUMN_INDEX).setMaxWidth(85);
                // we write our own cell renderer for rendering the date values
                TableCellRenderer tableCellRenderer = new DefaultTableCellRenderer() {

                    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                        if (value instanceof Date) {
                            value = sdf.format(value);
                        }
                        return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                    }
                };
                rootCaseTable.getColumnModel().getColumn(1).setCellRenderer(tableCellRenderer);
                rootCaseToolBar.enableFilters(rootCaseTable, processor.getRootCaseTypes());
                // initially sort root cases by elapsed time descending
                Collections.sort(rootCases, new ElapsedTimeComparator());
                Collections.reverse(rootCases);
                if (Configuration.ROOT_DETAILS_FIND_UNIQUE_URIS) {
                    for (RmRootCase rootCase : rootCases) {
                        RMNode rootNode = rootCase.getRmNode();
                        processRootRecord(rootNode);
                    }
                }
            }
        }

        private void processRootRecord(RMNode rootNode) {
            LinkedHashMap<String, RMNode> uniqueUris = new LinkedHashMap<String, RMNode>();
            processChildren(rootNode.children, uniqueUris);
            for (Entry<String, RMNode> uri : uniqueUris.entrySet()) {
                rootNode.rmData.setDetailCmp(rootNode.rmData.getDetailCmp() + " > " + uri.getKey());
            }
        }

        private void processChildren(List<RMNode> children, LinkedHashMap<String, RMNode> uniqueUris) {
            if (children != null) {
                for (RMNode child : children) {
                    if ("URI".equals(child.rmData.getTypeCmp())) {
                        String key = child.rmData.getDetailCmp();
                        if (!uniqueUris.containsKey(key)) {
                            uniqueUris.putIfAbsent(key, child);
                        }
                    }
                    processChildren(child.children, uniqueUris);
                }
            }
        }
    }).start();
}

[Buggy Hunk]
uniqueUris.putIfAbsent(key, child);

[Patch]
uniqueUris.put(key, child);

[Demonstration 3]

[Buggy Method]
protected ObjectStreamField[] getFields(Class<?> clazz) {
    ObjectStreamField[] fields = null;
    ClassInfo classInfo = null;
    Integer classId = class2classId.get(clazz);
    if (classId != null) {
        classInfo = registered.get(classId);
        fields = classInfo.getObjectStreamFields();
    }
    if (fields == null) {
        ObjectStreamClass streamClass = ObjectStreamClass.lookup(clazz);
        FastArrayList<ObjectStreamField> fieldsList = new FastArrayList<ObjectStreamField>();
        while (streamClass != null) {
            for (ObjectStreamField f : streamClass.getFields()) {
                fieldsList.add(f);
            }
            clazz = clazz.getSuperclass();
            streamClass = ObjectStreamClass.lookup(clazz);
        }
        fields = new ObjectStreamField[fieldsList.size];
        System.arraycopy(fieldsList.data, 0, fields, 0, fields.length);
        if (classInfo != null)
            classInfo.setObjectStreamFields(fields);
    }
    return fields;
}

[Buggy Hunk]
streamClass = ObjectStreamClass.lookup(clazz);

[Patch]
streamClass = clazz != null ? ObjectStreamClass.lookup(clazz) : null;