[Demonstration 1]

[Buggy Method]
public void show(final Context context, String title, Book book, final BookDialogListener bookDialogListener) {
    if (mRealmController == null) {
        mRealmController = new RealmController();
    }
    /**
     * if no book obect is passed through constructor , create a new book object with a new ID.
     * if already one book object is passed through constructor , dont create a new Book object , but just update the fileds (Keep the id of the book because it is the primary key)
     */
    if (book == null) {
        mBook = new Book();
        mBook.setId(mRealmController.getAll(Book.class).size() + 1);
    } else {
        mBook = book;
    }
    View content = LayoutInflater.from(context).inflate(R.layout.edit_item, null);
    final EditText editTitle = (EditText) content.findViewById(R.id.title);
    final EditText editAuthor = (EditText) content.findViewById(R.id.author);
    final EditText editThumbnail = (EditText) content.findViewById(R.id.thumbnail);
    if (book != null) {
        editTitle.setText(book.getTitle());
        editAuthor.setText(book.getAuthor());
        editThumbnail.setText(book.getImageUrl());
    }
    final DialogInterface.OnClickListener okClickListener = new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            mBook.setTitle(editTitle.getText().toString());
            mBook.setAuthor(editAuthor.getText().toString());
            mBook.setImageUrl(editThumbnail.getText().toString());
            if (editTitle.getText() == null || editTitle.getText().toString().equals("") || editTitle.getText().toString().equals(" ")) {
                Toast.makeText(context, "Entry not saved, missing title", Toast.LENGTH_SHORT).show();
            } else {
                if (bookDialogListener != null) {
                    bookDialogListener.onOkClicked(mBook);
                }
            }
        }
    };
    final DialogInterface.OnClickListener cancelClickListener = new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            if (bookDialogListener != null) {
                bookDialogListener.onCancelCliked();
            }
        }
    };
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setView(content).setTitle(title).setPositiveButton(android.R.string.ok, okClickListener).setNegativeButton(android.R.string.cancel, cancelClickListener);
    AlertDialog dialog = builder.create();
    dialog.show();
}

[Buggy Hunk]
mBook.setId(mRealmController.getAll(Book.class).size() + 1);

[Patch]
mBook.setId(mRealmController.getAllRealm(Book.class).size() + 1);

[Demonstration 2]

[Buggy Method]
public static void main(String[] args) throws Exception {
    setIpAddress(IP_ADDRESS);
    setPort(PORT);
    staticFileLocation("/public");
    new TodoResource(new TodoService(mongo()));
}

[Buggy Hunk]
new TodoResource(new TodoService(mongo()));

[Patch]
new HoldingResource(new HoldingService(mongo()));

[Demonstration 3]

[Buggy Method]
public static Result service(String ownerName, String projectName, String service, boolean isAdvertise) throws IOException, UnsupportedOperationException, ServletException {
    if (!isSupportedService(service)) {
        return forbidden(String.format("Unsupported service: '%s'", service));
    }
    Project project = Project.findByOwnerAndProjectName(ownerName, projectName);
    if (project == null) {
        return notFound();
    }
    models.User user = UserApp.currentUser();
    if (!isAllowed(project, service)) {
        if (user.isAnonymous()) {
            return BasicAuthAction.unauthorized(response());
        } else {
            // If you want the Git client showing your custom message to
            // the user, the Content-Type should be exact "text/plain"
            // without any parameter. For more details, see the code at
            // https://github.com/git/git/commit/426e70d4a11ce3b4f70636d57c6a0ab16ae08a00#diff-eea0ad565ec5903a11b6023755d491cfR154
            response().setHeader("Content-Type", "text/plain");
            return forbidden(String.format("'%s' has no permission to '%s/%s'.", user.name, ownerName, projectName));
        }
    }
    if (isAdvertise) {
        return ok(RepositoryService.gitAdvertise(project, service, response()));
    } else {
        if (request().body().isMaxSizeExceeded()) {
            return status(REQUEST_ENTITY_TOO_LARGE);
        } else {
            user.visits(project);
            return ok(RepositoryService.gitRpc(project, service, request(), response()));
        }
    }
}

[Buggy Hunk]
user.name, ownerName, projectName));

[Patch]
user.loginId, ownerName, projectName));