[Demonstration 1]

[Buggy Method]
@PUT
@Path("/{id:[0-9]+}")
@ApiOperation(value = "Update a Contact in the database")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Contact updated successfully"), @ApiResponse(code = 400, message = "Invalid Contact supplied in request body"), @ApiResponse(code = 404, message = "Contact with id not found"), @ApiResponse(code = 409, message = "Contact details supplied in request body conflict with another existing Contact"), @ApiResponse(code = 500, message = "An unexpected error occurred whilst processing the request") })
public Response updateContact(@ApiParam(value = "Id of Contact to be updated", allowableValues = "range[0, infinity]", required = true) @PathParam("id") long id, @ApiParam(value = "JSON representation of Contact object to be updated in the database", required = true) Contact contact) {
    if (contact == null) {
        throw new RestServiceException("Invalid Contact supplied in request body", Response.Status.BAD_REQUEST);
    }
    if (contact.getId() != null && contact.getId() != id) {
        // The client attempted to update the read-only Id. This is not permitted.
        Map<String, String> responseObj = new HashMap<>();
        responseObj.put("id", "The Contact ID in the request body must match that of the Contact being updated");
        throw new RestServiceException("Contact details supplied in request body conflict with another Contact", responseObj, Response.Status.CONFLICT);
    }
    if (service.findById(contact.getId()) == null) {
        // Verify that the contact exists. Return 404, if not present.
        throw new RestServiceException("No Contact with the id " + id + " was found!", Response.Status.NOT_FOUND);
    }
    Response.ResponseBuilder builder;
    try {
        // Apply the changes the Contact.
        service.update(contact);
        // Create an OK Response and pass the contact back in case it is needed.
        builder = Response.ok(contact);
    } catch (ConstraintViolationException ce) {
        //Handle bean validation issues
        Map<String, String> responseObj = new HashMap<>();
        for (ConstraintViolation<?> violation : ce.getConstraintViolations()) {
            responseObj.put(violation.getPropertyPath().toString(), violation.getMessage());
        }
        throw new RestServiceException("Bad Request", responseObj, Response.Status.BAD_REQUEST, ce);
    } catch (UniqueEmailException e) {
        // Handle the unique constraint violation
        Map<String, String> responseObj = new HashMap<>();
        responseObj.put("email", "That email is already used, please use a unique email");
        throw new RestServiceException("Contact details supplied in request body conflict with another Contact", responseObj, Response.Status.CONFLICT, e);
    } catch (InvalidAreaCodeException e) {
        Map<String, String> responseObj = new HashMap<>();
        responseObj.put("area_code", "The telephone area code provided is not recognised, please provide another");
        throw new RestServiceException("Bad Request", responseObj, Response.Status.BAD_REQUEST, e);
    } catch (Exception e) {
        // Handle generic exceptions
        throw new RestServiceException(e);
    }
    log.info("updateContact completed. Contact = " + contact.toString());
    return builder.build();
}

[Buggy Hunk]
if (contact == null) {

[Patch]
if (contact == null || contact.getId() == null) {

[Demonstration 2]

[Buggy Method]
@POST
@Path("/update/{userId}")
@Produces(MediaType.APPLICATION_JSON)
public Response updateUserById(@PathParam("userId") Long id) {
    String result = "Record updated: " + id;
    return Response.status(201).entity(id).build();
}

[Buggy Hunk]
return Response.status(201).entity(id).build();

[Patch]
return Response.status(201).entity(result).build();

[Demonstration 3]

[Buggy Method]
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
    conactsListAdapter.clear();
    conactsListAdapter.addAll(new ContactsFilter(getContentResolver()).filter(s.toString()));
    contactsListView.setVisibility(View.VISIBLE);
}

[Buggy Hunk]
conactsListAdapter.addAll(new ContactsFilter(getContentResolver()).filter(s.toString()));

[Patch]
conactsListAdapter.addAll(contactsFilter.filter(s.toString()));