[Demonstration 1]

[Buggy Method]
public void addResult(Integer id, Integer unitId, Type type, RoundingMethod roundingMethod, Integer significantDigits, String value, String dictEntry) throws Exception {
    Item item;
    ArrayList<Item> list;
    if (unitId == null)
        unitId = 0;
    //
    // default is special, there is just one per unit id
    //
    if (type == Type.DEFAULT) {
        defaults.put(unitId, value);
        return;
    }
    item = new Item();
    item.id = id;
    item.type = type;
    item.roundingMethod = roundingMethod;
    item.significantDigits = significantDigits;
    switch(type) {
        case DICTIONARY:
            ResultRangeDictionary d;
            d = new ResultRangeDictionary();
            d.setRange(dictEntry);
            d.setId(new Integer(value));
            item.value = d;
            break;
        case NUMERIC:
            item.value = new ResultRangeNumeric();
            item.value.setRange(value);
            hasOnlyDictionary = false;
            break;
        case TITER:
            item.value = new ResultRangeTiter();
            item.value.setRange(value);
            hasOnlyDictionary = false;
            break;
        case DATE:
            item.value = new ResultRangeDate();
            item.value.setRange(value);
            hasOnlyDictionary = false;
            break;
        case DATE_TIME:
            item.value = new ResultRangeDateTime();
            item.value.setRange(value);
            hasOnlyDictionary = false;
            break;
        case TIME:
            item.value = new ResultRangeTime();
            item.value.setRange(value);
            hasOnlyDictionary = false;
            break;
        case ALPHA_LOWER:
            item.value = new ResultRangeAlpha(ResultRangeAlpha.Type.LOWER);
            item.value.setRange(value);
            hasOnlyDictionary = false;
            break;
        case ALPHA_MIXED:
            item.value = new ResultRangeAlpha(ResultRangeAlpha.Type.MIXED);
            item.value.setRange(value);
            hasOnlyDictionary = false;
            break;
        case ALPHA_UPPER:
            item.value = new ResultRangeAlpha(ResultRangeAlpha.Type.UPPER);
            item.value.setRange(value);
            hasOnlyDictionary = false;
            break;
    }
    list = getUnits(unitId);
    if (list == null) {
        list = new ArrayList<Item>();
        units.put(unitId, list);
    }
    list.add(item);
}

[Buggy Hunk]
list = getUnits(unitId);

[Patch]
list = units.get(unitId);

[Demonstration 2]

[Buggy Method]
public Result prettyPrintWhenNeeded() {
    if (isPrettyPrint()) {
        ObjectMapper mapper = new ObjectMapper();
        final ObjectWriter objectWriter = mapper.writerWithDefaultPrettyPrinter();
        try {
            String prettyPrint = objectWriter.writeValueAsString(jsonNode);
            return Results.ok(prettyPrint).as("application/json");
        } catch (JsonProcessingException e) {
            // fall back to default JSON print
        }
    }
    return Results.ok(jsonNode);
}

[Buggy Hunk]
return Results.ok(prettyPrint).as("application/json");

[Patch]
return Results.ok(prettyPrint).as(CONTENT_TYPE);

[Demonstration 3]

[Buggy Method]
public static String write(Object obj) throws JsonProcessingException {
    return objectMapper.writeValueAsString(obj);
}

[Buggy Hunk]
return objectMapper.writeValueAsString(obj);

[Patch]
return defaultObjectMapper.writeValueAsString(obj);