[Demonstration 1]

[Buggy Method]
@ApiOperation(value = "Re-query a location from an existing query. " + "This runs asynchronously and returns a query object which can later be used to get the results.")
@RequestMapping(path = "/requery/query/{queryId}/locationMap/{queryLocationMapId}", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
@ResponseBody
public Query requeryPatients(@PathVariable("queryId") Long queryId, @PathVariable("queryLocationMapId") Long queryLocationMapId) throws JsonProcessingException, IOException {
    CommonUser user = UserUtil.getCurrentUser();
    //auditManager.addAuditEntry(QueryType.SEARCH_PATIENT, "/search", user.getSubjectName());
    QueryDTO initiatedQuery = searchManager.requeryForPatientRecords(queryLocationMapId, user);
    return DtoToDomainConverter.convert(initiatedQuery);
}

[Buggy Hunk]
public @ResponseBody Query requeryPatients(@PathVariable("queryId") Long queryId,

[Patch]
public synchronized @ResponseBody Query requeryPatients(@PathVariable("queryId") Long queryId,

[Demonstration 2]

[Buggy Method]
@Test
public void testOnMouseHoverMarqueeZoom() {
    Assert.assertTrue(html5Tester.testOnMouseHoverMarqueeZoom());
}

[Buggy Hunk]
Assert.assertTrue(html5Tester.testOnMouseHoverMarqueeZoom());

[Patch]
Assert.assertTrue(desktopTester.testOnMouseHoverMarqueeZoom());

[Demonstration 3]

[Buggy Method]
private Map<String, Object> dispatchAndCollect(Map<String, Object> params, Map<String, Task> tasks) throws DispatchFailedException, ComposerEvaluationException {
    Map<String, Object> responses = new HashMap<>();
    List<String> dispatched = new ArrayList<>();
    Map<Future<Object>, String> futures = new HashMap<>();
    responses.putAll(params);
    int remaining = tasks.size();
    while (remaining > 0) {
        for (String key : tasks.keySet()) {
            Task task = tasks.get(key);
            if (!responses.containsKey(key) && !dispatched.contains(key)) {
                List<String> dependencies = task.getDependencies();
                Map<String, Object> collectedDependencies = collectDependencies(responses, dependencies);
                if (collectedDependencies.size() == dependencies.size()) {
                    Future<Object> future = dispatchTask(task, responses);
                    dispatched.add(key);
                    futures.put(future, key);
                }
            }
        }
        if (dispatched.isEmpty()) {
            throw new DispatchFailedException("No possible resolution of dependencies found.");
        }
        try {
            Future future = completionService.take();
            String key = futures.get(future);
            responses.put(key, future.get());
            dispatched.remove(key);
            remaining--;
        } catch (InterruptedException | ExecutionException e) {
            throw new DispatchFailedException("Unable to fetch all required data", e);
        }
    }
    return responses;
}

[Buggy Hunk]
Future<Object> future = dispatchTask(task, responses);

[Patch]
Future<Object> future = dispatchTask(task, collectedDependencies);