[Demonstration 1]

[Buggy Method]
public static void userProfile(HttpServletRequest request, HttpServletResponse response) {
    UserProfileBean bean = null;
    String user = null;
    Session session = null;
    Subject subject = null;
    AccountFacade facade = null;
    Account profile = null;
    bean = new UserProfileBean();
    facade = new AccountFacade();
    subject = SecurityUtils.getSubject();
    user = request.getParameter("account");
    if (!FormValidator.validateParameter(user) || facade.getProfile(user) == null) {
        ErrorHelper.error404(request, response);
    } else {
        profile = facade.getProfile(user);
        if (subject.isAuthenticated()) {
            session = SessionManager.getSession(subject);
            bean.setUserData((Account) session.getAttribute("user_data"));
            bean.setProfile(profile);
            bean.setLayout("system.user_profile_auth");
        } else {
            bean.setProfile(profile);
            bean.setLayout("system.user_profile");
        }
        bean.setBlogEntries(facade.getBlogEntries(bean.getProfile().getId()));
        request.setAttribute("Bean", bean);
    }
}

[Buggy Hunk]
bean.setBlogEntries( facade.getBlogEntries( bean.getProfile( ).getId( ) ) );

[Patch]
bean.setBlogEntries( facade.getBlogEntries( bean.getProfile( ) ) );

[Demonstration 2]

[Buggy Method]
@RequestMapping(value = _CREATE_URI + "{executionCourseId}", method = RequestMethod.POST)
public String create(@PathVariable("executionCourseId") final ExecutionCourse executionCourse, @RequestParam(value = "bean", required = false) final CompetenceCourseMarkSheetBean bean, final Model model, final RedirectAttributes redirectAttributes) {
    try {
        if (bean.getLimitCreation()) {
            throw new ULisboaSpecificationsDomainException("label.MarkSheetSettings.limitCreationToResponsibleTeacher.true");
        }
        assertRequiredNumberOfShifts(bean);
        final CompetenceCourseMarkSheet markSheet = CompetenceCourseMarkSheet.create(bean.getExecutionSemester(), bean.getCompetenceCourse(), bean.getExecutionCourse(), bean.getEvaluationSeason(), bean.getEvaluationDate(), bean.getCertifier(), bean.getShifts(), true);
        model.addAttribute("competenceCourseMarkSheet", markSheet);
        return redirect(UPDATEEVALUATIONS_URL + executionCourse.getExternalId() + "/" + getCompetenceCourseMarkSheet(model).getExternalId(), model, redirectAttributes);
    } catch (Exception de) {
        addErrorMessage(de.getLocalizedMessage(), model);
        this.setCompetenceCourseMarkSheetBean(bean, model);
        return jspPage("create");
    }
}

[Buggy Hunk]
assertRequiredNumberOfShifts(bean);

[Patch]
MarkSheetSettings.isRequiredNumberOfShifts(bean.getShifts().size());

[Demonstration 3]

[Buggy Method]
public static StringBuilder replaceIcons(StringBuilder text) {
    int startIndex = text.indexOf("{lia");
    if (startIndex == -1) {
        return text;
    }
    int endIndex = text.substring(startIndex).indexOf("}") + startIndex + 1;
    String iconString = text.substring(startIndex + 1, endIndex - 1);
    iconString = iconString.replaceAll("-", "_");
    try {
        Iconify.IconValue value = Iconify.IconValue.valueOf(iconString);
        String iconValue = String.valueOf(value.character);
        text = text.replace(startIndex, endIndex, iconValue);
        return replaceIcons(text);
    } catch (IllegalArgumentException e) {
        Log.w(Iconify.TAG, "Wrong icon name: " + iconString);
        return text;
    }
}

[Buggy Hunk]
int startIndex = text.indexOf("{lia");

[Patch]
int startIndex = text.indexOf("{" + ICON_PREFIX);