[Demonstration 1]

[Buggy Method]
static void showHistory(String[] parameterArray) {
    TextWindow gridHistoryWindow = (TextWindow) WindowManager.getWindow(historyWindowTitle);
    if (gridHistoryWindow == null) {
        //make a new empty TextWindow with String historyWindowTitle with headings
        gridHistoryWindow = new TextWindow(historyWindowTitle, gridHistoryHeadings, "", 1028, 250);
        //If a file whose name is String textfileName exists in the plugin folder,
        //read it into the list.
        try {
            BufferedReader br = new BufferedReader(new FileReader(IJ.getDirectory("plugins") + textfileName));
            boolean isHeadings = true;
            while (true) {
                String s = br.readLine();
                if (s == null)
                    break;
                if (isHeadings) {
                    isHeadings = false;
                    continue;
                }
                gridHistoryWindow.append(s);
            }
            br.close();
        } catch (IOException e) {
        }
    }
    if (parameterArray != null) {
        for (String str : parameterArray) if (str != null)
            gridHistoryWindow.append(df.format(date) + "\t" + str);
        //auto save the parameters into a file whose name is String textfileName
        TextPanel tp = gridHistoryWindow.getTextPanel();
        tp.saveAs(IJ.getDirectory("plugins") + textfileName);
    }
}

[Buggy Hunk]
gridHistoryWindow.append(df.format(date) + "\t" + str);

[Patch]
gridHistoryWindow.append(str);

[Demonstration 2]

[Buggy Method]
@Override
public void commit(IProgressMonitor monitor) throws CoreException {
    _switchYardProject.readLock();
    try {
        if (!isModified()) {
            monitor.done();
            return;
        }
        monitor.beginTask(Messages.SwitchYardProjectWorkingCopy_taskMessage_updatingProjectPOM, 300);
        IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 100, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
        final List<Operation> updateOperations = processUpdates(subMonitor);
        if (updateOperations.size() > 0) {
            subMonitor.done();
            subMonitor = new SubProgressMonitor(monitor, 100, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
            try {
                updatePom(updateOperations);
            } catch (IOException e) {
                throw new CoreException(new Status(Status.ERROR, Activator.PLUGIN_ID, "Could not update pom.xml", e));
            }
            subMonitor.done();
        }
        subMonitor.done();
        final List<Operation> updateFeatureOperations = processFeatureUpdates(subMonitor);
        if (updateFeatureOperations.size() > 0) {
            subMonitor.done();
            subMonitor = new SubProgressMonitor(monitor, 100, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
            try {
                updateFeatures(updateFeatureOperations);
            } catch (IOException e) {
                throw new CoreException(new Status(Status.ERROR, Activator.PLUGIN_ID, "Could not update features.xml", e));
            }
            subMonitor.done();
        }
        subMonitor.done();
        monitor.done();
    } finally {
        _switchYardProject.readUnlock();
        _switchYardProject.getSwitchYardFeaturesFile().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
        refreshProject(new NullProgressMonitor());
    }
}

[Buggy Hunk]
refreshProject(new NullProgressMonitor());

[Patch]
M2EUtils.refreshProject(_switchYardProject.getProject(), new NullProgressMonitor());

[Demonstration 3]

[Buggy Method]
@Override
public String execute(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
    final UserSignUpForm userForm = new UserSignUpForm();
    fillForm(request, userForm);
    final List<String> errors = validationService.validate(userForm);
    if (isNotEmpty(errors)) {
        request.setAttribute(ERROR_MSGS, messages.getMessages(errors, request.getLocale()));
    } else {
        User user = null;
        try {
            user = userSignUpConverter.convert(userForm);
            userService.signUp(user);
            if (user.getId() != null && user.getRole() == Role.STUDENT) {
                request.getSession().setAttribute(SESSION_ATTRIBUTES.STUDENT, user);
                response.sendRedirect(LINKS.STUDENT_HOME_PAGE);
                return REDIRECT;
            }
            if (user.getId() != null && user.getRole() == Role.TUTOR) {
                request.getSession().setAttribute(SESSION_ATTRIBUTES.TUTOR, user);
                response.sendRedirect(LINKS.TUTOR_QUIZZES);
                return REDIRECT;
            }
        } catch (final EntityExistsException e) {
            LOG.warn(e.getMessage(), e);
            request.setAttribute(ERROR_MSG, messages.getMessage(ERRORS.USER_EXISTS, request.getLocale()));
        }
        request.setAttribute(REQUEST_ATTRIBUTES.USER, user);
    }
    fillPage(request);
    return PAGES.SIGN_UP;
}

[Buggy Hunk]
final List<String> errors = validationService.validate(userForm);

[Patch]
final Map<String, String> errors = validationService.validate(userForm);