[Demonstration 1]

[Buggy Method]
public Board generate(int targetNumCars) {
    this.init();
    while (this.board.numCars() < targetNumCars) {
        if (this.cars.isEmpty()) {
            return this.generate(targetNumCars);
        }
        for (int i = 0; i < this.cars.size(); i++) {
            Car c = this.cars.get(i);
            if (this.board.canAddCar(c)) {
                this.updateCars(c);
                break;
            } else {
                this.cars.remove(c);
            }
        }
    }
    return this.board;
}

[Buggy Hunk]
return this.generate(targetNumCars);

[Patch]
this.init(); // start over

[Demonstration 2]

[Buggy Method]
@SuppressWarnings({ "unchecked", "rawtypes" })
private Object typeConvert(Object value, String name, Schema schema) throws IOException {
    if (isNullableSchema(schema)) {
        if (value == null) {
            return null;
        } else {
            schema = getNonNull(schema);
        }
    } else if (value == null) {
        // Always fail on null for non-nullable schemas
        throw new JsonConversionException(value, name, schema);
    }
    switch(schema.getType()) {
        case BOOLEAN:
            if (value instanceof Boolean) {
                return (Boolean) value;
            } else if (value instanceof String) {
                return Boolean.valueOf((String) value);
            } else if (value instanceof Number) {
                return ((Number) value).intValue() == 0 ? Boolean.FALSE : Boolean.TRUE;
            }
            break;
        case DOUBLE:
            if (value instanceof Number) {
                return ((Number) value).doubleValue();
            } else if (value instanceof String) {
                return Double.valueOf((String) value);
            }
            break;
        case FLOAT:
            if (value instanceof Number) {
                return ((Number) value).floatValue();
            } else if (value instanceof String) {
                return Float.valueOf((String) value);
            }
            break;
        case INT:
            if (value instanceof Number) {
                return ((Number) value).intValue();
            } else if (value instanceof String) {
                return Integer.valueOf((String) value);
            }
            break;
        case LONG:
            if (value instanceof Number) {
                return ((Number) value).longValue();
            } else if (value instanceof String) {
                return Long.valueOf((String) value);
            }
            break;
        case STRING:
            return value.toString();
        case ENUM:
            try {
                Class<Enum> enumType = (Class<Enum>) Class.forName(schema.getFullName());
                return Enum.valueOf(enumType, value.toString());
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            }
        case RECORD:
            return convert((Map<String, Object>) value, schema);
        case ARRAY:
            Schema elementSchema = schema.getElementType();
            List listRes = new ArrayList();
            for (Object v : (List) value) {
                listRes.add(typeConvert(v, name, elementSchema));
            }
            return listRes;
        case MAP:
            Schema valueSchema = schema.getValueType();
            Map<String, Object> mapRes = new HashMap<String, Object>();
            for (Map.Entry<String, Object> v : ((Map<String, Object>) value).entrySet()) {
                mapRes.put(v.getKey(), typeConvert(v.getValue(), name, valueSchema));
            }
            return mapRes;
        default:
            throw new IllegalArgumentException("JsonToAvroConverter cannot handle type: " + schema.getType());
    }
    throw new JsonConversionException(value, name, schema);
}

[Buggy Hunk]
throw new JsonConversionException(value, name, schema);

[Patch]
throw new JsonConversionException(null, name, schema);

[Demonstration 3]

[Buggy Method]
@Cacheable(value = "customer")
public Customer getCustomerByEmail(String email) {
    setCacheMiss();
    Customer customer = jpaCustomerRepository.findByEmail(email);
    return customer;
}

[Buggy Hunk]
Customer customer = jpaCustomerRepository.findByEmail(email);

[Patch]
Customer customer = jpaCustomerRepository.findDistinctByEmail(email);