[Demonstration 1]

[Buggy Method]
@RequestMapping("register")
public String register(@ModelAttribute UserVo user, HttpServletRequest request, HttpServletResponse response) {
    log.info("UserAction.register 参数:{}", user);
    List<String> erroList = UserInfoValidate.checkRegisterParam(user);
    if (erroList.isEmpty()) {
        ServiceResponse<UserVo> resp = userService.saveUser(user);
        if (ShoppingContants.RESP_CODE_SUCESS.equals(resp.getCode())) {
            //成功，返回到主頁
            request.getSession().setAttribute(ShoppingContants.USER_SESSION_KEY, user);
            return "redirect:/unlogin/home/index.do";
        }
    }
    //失败，返回到注册页
    request.setAttribute("erroList", erroList);
    request.setAttribute("user", user);
    return webPage("user/register");
}

[Buggy Hunk]
List<String> erroList=UserInfoValidate.checkRegisterParam(user);

[Patch]
Map<String,String> erroList=UserInfoValidate.checkRegisterParam(user);

[Demonstration 2]

[Buggy Method]
private void replaceFields(Order o, XWPFDocument document) {
    if (o.binary) {
        replace(document, "#coordinate_1", o.coordinates1);
        replace(document, "#coordinate_2", o.coordinates2);
    } else {
        replace(document, "#coordinate_1", "");
        //set size to larger
        replace(document, "&", o.coordinates1);
        replace(document, "#coordinate_2", "");
    }
    replace(document, "#insert_name", o.starName);
    //this chunk supports unlimited message lines
    for (int i = 0; i < o.personalMessage.length; i++) {
        replace(document, "msg_" + i, o.personalMessage[i]);
    }
    replace(document, "#registration_number", o.registrationNumber);
    replace(document, "#current_date", o.date);
}

[Buggy Hunk]
private void replaceFields(Order o, XWPFDocument document) {

[Patch]
private void replaceFields(Order o, XWPFDocument document) throws FileNotFoundException, IOException {

[Demonstration 3]

[Buggy Method]
public static String replacePart(String sourceText, int from, int to, String replaceText) {
    if (from < to || from < 0 || to > sourceText.length()) {
        throw new StringIndexOutOfBoundsException();
    }
    return String.format("%s%s%s", sourceText.substring(0, from), replaceText, sourceText.substring(to));
}

[Buggy Hunk]
if (from < to || from < 0 || to > sourceText.length()) {

[Patch]
if (from > to || from < 0 || to > sourceText.length()) {