[Demonstration 1]

[Buggy Method]
public static <T> Optional<T> createInstance(ConstructionParams params, SimulationModel model) throws ClassNotFoundException {
    return getEligibleConstructor(Class.forName(params.className)).flatMap(constructor -> {
        Object[] constructorParams = params.constructorParams.stream().map(o -> model.getWrapperById((Long) o)).toArray();
        try {
            T obj = (T) constructor.newInstance(constructorParams);
            for (Map.Entry<String, Object> prop : params.paramsMap.entrySet()) {
                if (isContextClass(PropertyUtils.getPropertyType(obj, prop.getKey()))) {
                    PropertyUtils.setSimpleProperty(obj, prop.getKey(), model.getWrapperById(((Integer) prop.getValue()).longValue()).getWrapped());
                } else {
                    PropertyUtils.setSimpleProperty(obj, prop.getKey(), prop.getValue());
                }
            }
            return Optional.of(obj);
        } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            e.printStackTrace();
            return Optional.empty();
        }
    });
}

[Buggy Hunk]
.map(o -> model.getWrapperById((Long) o)).toArray();

[Patch]
.map(o -> model.getWrapperById(((Integer) o).longValue()).getWrapped()).toArray();

[Demonstration 2]

[Buggy Method]
@Override
public List<UserMeal> getBetween(LocalDateTime startDate, LocalDateTime endDate, int userId) {
    return em.createNamedQuery(UserMeal.BETWEEN, UserMeal.class).setParameter("start_date", startDate).setParameter("end_date", endDate).getResultList();
}

[Buggy Hunk]
return em.createNamedQuery(UserMeal.BETWEEN, UserMeal.class).setParameter("start_date", startDate).setParameter("end_date", endDate).getResultList();

[Patch]
return em.createNamedQuery(UserMeal.BETWEEN, UserMeal.class).setParameter("start_date", startDate).setParameter("end_date", endDate).setParameter("user_id", userId).getResultList();

[Demonstration 3]

[Buggy Method]
@Override
public Set<TaskGroupInformation> list(String locale) {
    //TODO: move this to default implementation after move to java 8 (and use streams)
    Objects.requireNonNull(locale);
    Set<TaskGroupInformation> ret = new HashSet<>();
    for (TaskGroupInformation info : listAll()) {
        if (info.matchesLocale(locale)) {
            ret.add(info.newCopyBuilder().locale(locale).build());
        }
    }
    return ret;
}

[Buggy Hunk]
ret.add(info.newCopyBuilder().locale(locale).build());

[Patch]
ret.add(info);