[Demonstration 1]

[Buggy Method]
private void request(String input) {
    JSONObject jsonObject = new JSONObject();
    try {
        jsonObject.put("type", "REQUEST");
        jsonObject.put("content", input);
        this.sender.println(jsonObject);
        this.sender.flush();
        //wait the data form server.
        JSONObject receive = this.receive_data();
        assert receive != null;
        if (Boolean.parseBoolean((String) receive.get("content")))
            print("Request successfully");
    } catch (JSONException e) {
        error_handle(e);
    }
}

[Buggy Hunk]
if (Boolean.parseBoolean((String) receive.get("content")))

[Patch]
if ((Boolean)receive.get("content"))

[Demonstration 2]

[Buggy Method]
@POST
@Path("/{distId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + "; charset=UTF-8")
public Response updateResponsibleOrganization(@PathParam("distId") Long distId, DistributionRulePO distribution) {
    if (distId == null || distribution == null) {
        log.info("updateResponsibleOrganization - bad request[{},{}]", distId, distribution);
        return badRequest("need distId and distribution object");
    }
    if (!authService.isAuthenticated()) {
        return Response.status(Response.Status.UNAUTHORIZED).entity(NOT_LOGGED_IN).build();
    }
    Optional<User> user = userService.findByEmail(authService.getAuthentication().getEmail());
    if (user.isPresent()) {
        long userId = user.get().getId();
        if (userService.isAdmin(userId) || userService.isManager(userId)) {
            // only managers and admins can update responsibility
            //TODO: multi-tenancy considerations. Do we pass municipality to service methods, or do we inject that in the
            //services? At any rate, make sure we can't get mess with other municipalities' data.
            return distributionService.getDistribution(distId).map(existing -> {
                log.info("updateResponsibleOrganization - updating resource");
                return doUpdateResponsibleOrganization(existing, distribution);
            }).orElseGet(() -> {
                log.info("updateResponsibleOrganization - nonexisting distributionRule[{}]", distId);
                return Response.status(Response.Status.NOT_FOUND).build();
            });
        } else {
            return Response.status(Response.Status.UNAUTHORIZED).entity(NOT_AUTHORIZED).build();
        }
    } else {
        return Response.status(Response.Status.NOT_FOUND).entity(USER_NOT_FOUND).build();
    }
}

[Buggy Hunk]
if (userService.isAdmin(userId) || userService.isManager(userId)) { // only managers and admins can update responsibility

[Patch]
if (userService.isAdmin(userId) || userService.isMunicipalityAdmin(userId) || userService.isManager(userId)) { // only managers and admins can update responsibility

[Demonstration 3]

[Buggy Method]
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //Using
    mRecyclerView = (RecyclerView) findViewById(R.id.active_drug_recycler);
    // use this setting to improve performance if you know that changes
    // in content do not change the layout size of the RecyclerView
    mRecyclerView.setHasFixedSize(true);
    mLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mAdapter = new ActiveDrugAdapter(new String[] { "Testing" });
    mRecyclerView.setAdapter(mAdapter);
}

[Buggy Hunk]
mAdapter = new ActiveDrugAdapter(new String[] {"Testing"});

[Patch]
mAdapter = new ActiveDrugAdapter(new String[] {"Aspirin", "Ethanol", "Acetaminophen"});