[Demonstration 1]

[Buggy Method]
public ListBoxModel doFillDefaultProjectItems(@QueryParameter String username, @QueryParameter String password, @QueryParameter String hostUrl) {
    ListBoxModel items = new ListBoxModel();
    try {
        SwampPostBuild.setApi(login(username, password, hostUrl));
        //SwampApiWrapper api = new SwampApiWrapper(HostType.DEVELOPMENT);
        //api.login(username, password);
        Iterator<Project> myProjects = SwampPostBuild.getSwampApi().getProjectsList().iterator();
        while (myProjects.hasNext()) {
            Project nextProject = myProjects.next();
            items.add(nextProject.getFullName(), nextProject.getUUIDString());
        }
    } catch (Exception e) {
        ListBoxModel error = new ListBoxModel();
        error.add("", "null");
        return error;
    }
    return items;
}

[Buggy Hunk]
SwampPostBuild.setApi(login(username, password, hostUrl));

[Patch]
SwampPostBuild.setSwampApi(login(username, password, hostUrl));

[Demonstration 2]

[Buggy Method]
public User CheckFirstLogin() {
    User user = new User();
    String usernameFromCookie = "";
    //get session
    HttpSession session = request.getSession(false);
    String userpasswordFromsession = "";
    if (session == null) {
        isFirstLogin = true;
        user.setUserName("");
        return user;
    }
    //get cookies, if cookie is not null, get userPassword from session.
    Cookie[] cookies = request.getCookies();
    if (cookies != null) {
        for (Cookie cookie : cookies) {
            if (cookie.getName().equals("userName")) {
                usernameFromCookie = cookie.getValue();
            }
        }
        userpasswordFromsession = (String) session.getAttribute("password");
    }
    //check usernameFromCookie or userpasswordFromsession which is null or not, if it is empty, return true.
    if (usernameFromCookie == "" || userpasswordFromsession == "") {
        isFirstLogin = true;
        user.setUserName("");
        return user;
    }
    user.setUserName(usernameFromCookie);
    user.setPassword(userpasswordFromsession);
    isFirstLogin = false;
    return user;
}

[Buggy Hunk]
if(usernameFromCookie=="" || userpasswordFromsession==""){

[Patch]
if(usernameFromCookie.equals("") || userpasswordFromsession.equals("")){

[Demonstration 3]

[Buggy Method]
@PreAuthorize("hasAuthority('ADMIN')")
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public ResponseEntity<AuthorResource> updateAuthor(@PathVariable("id") long id, @RequestBody Author author) {
    Author urlAuthor = authorService.findById(id);
    if (urlAuthor == null) {
        return new ResponseEntity<AuthorResource>(HttpStatus.NOT_FOUND);
    }
    Author requestAuthor = authorService.findById(author.getId());
    if (requestAuthor == null) {
        return new ResponseEntity<AuthorResource>(HttpStatus.NOT_FOUND);
    }
    if (urlAuthor.getId() != requestAuthor.getId()) {
        return new ResponseEntity<AuthorResource>(HttpStatus.BAD_REQUEST);
    }
    authorService.updateAuthor(author);
    AuthorResourceAssembler assembler = new AuthorResourceAssembler();
    AuthorResource authorResource = assembler.toResource(author);
    authorResource.add(linkTo(AuthorsRestController.class).slash(author).withSelfRel());
    authorResource.add(linkTo(methodOn(AuthorsRestController.class).listAllAuthors()).withRel("authors"));
    authorResource.add(linkTo(AuthorsRestController.class).slash(author).slash("/books").withRel("books"));
    return new ResponseEntity<AuthorResource>(authorResource, HttpStatus.OK);
}

[Buggy Hunk]
if (urlAuthor.getId() != requestAuthor.getId()) {

[Patch]
if (!urlAuthor.getId().equals(requestAuthor.getId())) {