[Demonstration 1]

[Buggy Method]
public static CombinedEnchantments combine(Map<Integer, Integer> enchList1, Map<Integer, Integer> enchList2, ItemStack item) {
    int repairCost = 0;
    double repairAmount = 0;
    Map<Integer, Integer> compatEnchList = new HashMap<Integer, Integer>();
    Map<Integer, Integer> inCompatEnchList = new HashMap<Integer, Integer>();
    if (enchList1 != null && !enchList1.isEmpty() && enchList2 != null && !enchList2.isEmpty()) {
        compatEnchList.putAll(enchList1);
        //Combine all enchantments
        for (Map.Entry<Integer, Integer> entry : enchList2.entrySet()) {
            if (entry == null) {
                continue;
            }
            Enchantment enchantment = null;
            final int index = entry.getKey();
            if (index < Enchantment.enchantmentsList.length) {
                enchantment = Enchantment.enchantmentsList[index];
            } else {
                BetterAnvil.BETTER_ANVIL_LOGGER.warn(String.format("Enchantment id %d, is invalid!", index));
            }
            if (enchantment == null) {
                continue;
            }
            if (compatEnchList.containsKey(enchantment.effectId)) {
                int value = enchList2.get(enchantment.effectId);
                int origVal = compatEnchList.get(enchantment.effectId);
                int limit = Config.ENCHANT_LIMITS.get(enchantment.effectId);
                if (origVal == value && origVal < limit) {
                    compatEnchList.put(enchantment.effectId, value + 1);
                    repairCost += Config.enchantCombineRepairCost * value;
                    repairAmount += Config.enchantCombineRepairBonus * value;
                } else if (origVal < value) {
                    compatEnchList.put(enchantment.effectId, value);
                    repairCost += Config.enchantTransferRepairCost * value;
                    repairAmount += Config.enchantTransferRepairBonus * value;
                }
            } else if (item.getItem() == Items.enchanted_book || enchantment.canApply(item)) {
                boolean found = false;
                for (Map.Entry<Integer, Integer> entry2 : compatEnchList.entrySet()) {
                    if (entry2 == null) {
                        continue;
                    }
                    if (Utils.contains(Config.ENCHANT_BLACK_LIST.get(entry2.getKey()), Utils.getEnchName(enchantment.effectId))) {
                        inCompatEnchList.put(enchantment.effectId, entry.getValue());
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    compatEnchList.put(enchantment.effectId, entry.getValue());
                    repairCost += Config.enchantTransferRepairCost * entry.getValue();
                    repairAmount += Config.enchantTransferRepairBonus * entry.getValue();
                }
            } else {
                inCompatEnchList.put(enchantment.effectId, entry.getValue());
            }
        }
    }
    return new CombinedEnchantments(repairCost, repairAmount, compatEnchList, inCompatEnchList);
}

[Buggy Hunk]
if(enchList1 != null && !enchList1.isEmpty() && enchList2 != null && !enchList2.isEmpty()) {

[Patch]
if((enchList1 != null && enchList2 != null) && (!enchList1.isEmpty() || !enchList2.isEmpty())) {

[Demonstration 2]

[Buggy Method]
@Override
protected void runInTry() throws java.lang.Exception {
    final JSONObject response = new JSONObject(jsonOfConfirmation);
    if (!response.getString("url").equals(URL_CALLBACK)) {
        throw new java.lang.Exception();
    }
    final JSONObject orderData = response.getJSONObject("params");
    checkResponse(orderData);
    callback.onPaidSuccess(parseOrder(orderData));
}

[Buggy Hunk]
callback.onPaidSuccess(parseOrder(orderData));

[Patch]
callback.onPaidProcessed(parseOrder(orderData));

[Demonstration 3]

[Buggy Method]
private Object getForeignKeyValue(EntityInfo entityInfo, ClassMetadata meta, String foreignKeyName) {
    Object entity = entityInfo.entity;
    Object id = null;
    if (foreignKeyName == meta.getIdentifierPropertyName())
        id = meta.getIdentifier(entity, null);
    else if (Arrays.asList(meta.getPropertyNames()).contains(foreignKeyName))
        id = meta.getPropertyValue(entity, foreignKeyName);
    else if (meta.getIdentifierType().isComponentType()) {
        // compound key
        ComponentType compType = (ComponentType) meta.getIdentifierType();
        int index = Arrays.asList(compType.getPropertyNames()).indexOf(foreignKeyName);
        if (index >= 0) {
            Object idComp = meta.getIdentifier(entity, null);
            id = compType.getPropertyValue(idComp, index, EntityMode.POJO);
        }
    }
    if (id == null && entityInfo.entityState == EntityState.Deleted) {
        id = entityInfo.originalValuesMap.get(foreignKeyName);
    }
    return id;
}

[Buggy Hunk]
if (foreignKeyName == meta.getIdentifierPropertyName())

[Patch]
if (foreignKeyName.equalsIgnoreCase(meta.getIdentifierPropertyName()))