[Demonstration 1]

[Buggy Method]
private String parseGetDeviceCommand(String data) {
    // Request performed successfully: load response body
    // Expected response format: { "data": { "code": ..., "message": "..." }, "code": 200, "message":
    // "200 - OK", ... }
    try {
        Gson gson = new Gson();
        // Response -> String -> Json -> extract data field
        JsonObject responseAsJson = gson.fromJson(data, JsonObject.class);
        String dataMessage = responseAsJson.get("message").getAsString();
        return dataMessage;
    } catch (JsonParseException e) {
        mCaller.responseFormatError("Unexpected response format: " + e.getMessage(), false);
        return null;
    }
}

[Buggy Hunk]
private String parseGetDeviceCommand(String data) {

[Patch]
private synchronized String parseGetDeviceCommand(String data) {

[Demonstration 2]

[Buggy Method]
@Override
public void createLink(LinkRepresentation link, ApplicationUser user) {
    final ActiveObjects ao = ComponentGetter.getAo();
    ao.executeInTransaction(new TransactionCallback<Void>() {

        @Override
        public Void doInTransaction() {
            boolean linkAlreadyExists = false;
            for (LinkEntity linkEntity : ao.find(LinkEntity.class)) {
                if (linkEntity.getIngoingId() == link.getIngoingId() && linkEntity.getOutgoingId() == link.getOutgoingId()) {
                    linkAlreadyExists = true;
                }
            }
            if (!linkAlreadyExists) {
                link.getOutgoingId();
                DecisionComponentEntity decCompIngoing;
                DecisionComponentEntity[] decCompIngoingArray = ao.find(DecisionComponentEntity.class, Query.select().where("ID = ?", link.getIngoingId()));
                /*
                	 * ID is the primarykey for decisioncomponents, therefore find can only return 0 to 1 entities
                	 */
                if (decCompIngoingArray.length == 1) {
                    decCompIngoing = decCompIngoingArray[0];
                } else {
                    //entity with ingoingId does not exist
                    decCompIngoing = null;
                }
                DecisionComponentEntity decCompOutgoing;
                DecisionComponentEntity[] decCompOutgoingArray = ao.find(DecisionComponentEntity.class, Query.select().where("ID = ?", link.getOutgoingId()));
                if (decCompIngoingArray.length == 1) {
                    decCompOutgoing = decCompOutgoingArray[0];
                } else {
                    //entity with ingoingId does not exist
                    decCompOutgoing = null;
                }
                if (decCompIngoing != null && decCompOutgoing != null) {
                    if (decCompIngoing.getProjectKey().equals(decCompOutgoing.getProjectKey())) {
                        // entities exist and are in the same project
                        final LinkEntity linkEntity = ao.create(LinkEntity.class);
                        linkEntity.setIngoingId(link.getIngoingId());
                        linkEntity.setOutgoingId(link.getOutgoingId());
                        linkEntity.setType(link.getLinkType());
                        linkEntity.save();
                    } else {
                        // entities to be linked are not in the same project, TODO ignore request
                    }
                } else {
                    // one of the entities to be linked does not exist, TODO ignore request
                }
            }
            return null;
        }
    });
}

[Buggy Hunk]
public void createLink(LinkRepresentation link, ApplicationUser user) {

[Patch]
public void createLink(final LinkRepresentation link, ApplicationUser user) {

[Demonstration 3]

[Buggy Method]
@Override
public boolean deserialize(String data) {
    try {
        if (data.endsWith("%")) {
            durabilityPercent = Integer.parseInt(data.substring(0, data.length() - 1)) / 100.0;
            durability = (short) (item.getItem(false).getType().getMaxDurability() * durabilityPercent);
        } else {
            durability = Short.parseShort(data.substring(0));
        }
    } catch (NumberFormatException e) {
        return false;
    }
    return true;
}

[Buggy Hunk]
durability = (short) (item.getItem(false).getType().getMaxDurability() * durabilityPercent);

[Patch]
durability = (short) (item.getMaterial().getMaxDurability() * durabilityPercent);