[Demonstration 1]

[Buggy Method]
public void acceptBidForChicken(Bid bid) throws ChickenException {
    SearchController searchController = ChickBidsApplication.getSearchController();
    UserController userController = ChickBidsApplication.getUserController();
    User current_user = userController.getCurrentUser();
    Chicken chicken = getChickenForBidForCurrentUser(bid);
    current_user.deleteChickenForId(chicken.getId());
    if (!userController.getCurrentUser().getUsername().equals(chicken.getOwnerUsername())) {
        throw new ChickenException("Cannot accept bid if not the owner");
    }
    bid.setBidStatus(Bid.BidStatus.ACCEPTED);
    for (Bid b : chicken.getBids()) {
        if (b != bid) {
            User user = searchController.getUserFromDatabase(b.getBidderUsername());
            removeChickenForBidFromUser(user, b);
            searchController.removeBidFromDatabase(b.getId());
            searchController.updateUserInDatabase(user);
        }
    }
    bid = searchController.updateBidInDatabase(bid);
    chicken.getBids().clear();
    chicken.addBid(bid);
    chicken.setChickenStatus(Chicken.ChickenStatus.BORROWED);
    chicken.setBorrowerUsername(bid.getBidderUsername());
    chicken = searchController.updateChickenInDatabase(chicken);
    current_user.addChicken(chicken);
    userController.updateUser(userController.getCurrentUser());
}

[Buggy Hunk]
if (b != bid) {

[Patch]
if ((b.getBidStatus() == Bid.BidStatus.UNDECIDED) && (b != bid)) {

[Demonstration 2]

[Buggy Method]
@ResponseBody
@ExceptionHandler(PersistenceLayerException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ApiError serverError(PersistenceLayerException e) {
    return new ApiError(INTERNAL_SERVER_ERROR_CODE, e.getClass().getSimpleName().concat(e.getMessage()));
}

[Buggy Hunk]
return new ApiError(INTERNAL_SERVER_ERROR_CODE, e.getClass().getSimpleName().concat(e.getMessage()));

[Patch]
return new ApiError(INTERNAL_SERVER_ERROR_CODE, e.getClass().getSimpleName().concat(getExceptionMessage(e)));