[Demonstration 1]

[Buggy Method]
private MarginResults makeResult(String response, MarginCallType callType) throws IOException {
    List<?> list = transformer.deserialiseToList(response);
    List<Result<MarginValuation>> results = list.stream().map(map -> (com.acuo.common.model.results.MarginValuation) map).map(map -> new MarginValuation(map.getName(), map.getAccount(), map.getChange(), map.getMargin(), null, map.getPortfolioId())).map(Result::success).collect(Collectors.toList());
    MarginResults marginResults = new MarginResults();
    marginResults.setMarginType(callType.name());
    marginResults.setResults(results);
    marginResults.setValuationDate(LocalDate.now());
    marginResults.setCurrency("USD");
    return marginResults;
}

[Buggy Hunk]
marginResults.setValuationDate(LocalDate.now());

[Patch]
marginResults.setValuationDate(LocalDateUtils.minus(LocalDate.now(), 1));

[Demonstration 2]

[Buggy Method]
public void getEvents(final Consumer onSuccess) {
    //setup CountDownLatch
    final CountDownLatch latch = new CountDownLatch(2);
    Consumer countDown = new Consumer() {

        @Override
        public void run(Object result) {
            latch.countDown();
        }
    };
    //start asynchronous tasks
    getEventEntries(countDown);
    getEventCategories(countDown);
    //wait for task to finish
    try {
        latch.await();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    //tasks finished
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    try {
        JSONObject categories = new JSONObject(prefs.getString("categories", "{}"));
        JSONObject events = new JSONObject(prefs.getString("event_entries", "{}"));
        JSONArray eventArray = events.getJSONArray("HomeWorks");
        JSONObject res = new JSONObject();
        for (int eventIndex = 0; eventIndex < eventArray.length(); eventIndex++) {
            JSONObject event = eventArray.getJSONObject(eventIndex);
            JSONObject resEvent = new JSONObject();
            int categoryId = event.getJSONObject("Category").getInt("Id");
            String date = event.getString("Date");
            resEvent.put("Category", categories.get(String.valueOf(categoryId)));
            resEvent.put("Description", event.getString("Content"));
            resEvent.put("LessonNo", event.getString("LessonNo"));
            if (!res.has(date)) {
                res.put(date, new JSONArray());
            }
            res.getJSONArray(date).put(resEvent);
        }
        log("Resolved events:   " + res.toString());
        prefs.edit().putString("events", res.toString()).commit();
        onSuccess.run(res);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

[Buggy Hunk]
public void getEvents(final Consumer onSuccess) {

[Patch]
private void getEvents(final Consumer onSuccess) {

[Demonstration 3]

[Buggy Method]
void restartConsumer() {
    try {
        String id = getID();
        if (id.startsWith("/*")) {
            id = "atmosphere";
        }
        if (consumer != null) {
            consumer.close();
            consumer = null;
        }
        logger.info("Create JMS consumer: {}", id);
        String selector = String.format("BroadcasterId = '%s'", id);
        consumer = session.createConsumer(topic, selector);
        consumer.setMessageListener(new MessageListener() {

            @Override
            public void onMessage(Message msg) {
                try {
                    TextMessage textMessage = (TextMessage) msg;
                    String message = textMessage.getText();
                    if (message != null && bc != null) {
                        broadcastReceivedMessage(message);
                    }
                } catch (JMSException ex) {
                    logger.warn("Failed to broadcast message", ex);
                }
            }
        });
        logger.info("Consumer created for topic {}, with filter {}", topicId, selector);
    } catch (Throwable ex) {
        String msg = "Unable to initialize JMSBroadcaster";
        logger.error(msg, ex);
        throw new IllegalStateException(msg, ex);
    }
}

[Buggy Hunk]
consumer = session.createConsumer(topic, selector);

[Patch]
consumer = consumerSession.createConsumer(topic, selector);