[Demonstration 1]

[Buggy Method]
@Test
public void testListInDetail() throws Exception {
    Optional<? extends AvailabilityZoneApi> availabilityZoneApi = api.getAvailabilityZoneApi("RegionOne");
    if (availabilityZoneApi.isPresent()) {
        FluentIterable<? extends AvailabilityZoneDetails> zones = availabilityZoneApi.get().listInDetail();
        for (AvailabilityZoneDetails zone : zones) {
            assertNotNull(zone.getName());
            assertTrue(zone.getState().isAvailable(), "zone: " + zone.getName() + " is not available.");
            String hostName = zone.getHosts().keySet().iterator().next();
            assertNotNull(hostName, "Expected host name to be not null");
            String hostServiceName = zone.getHosts().get(hostName).keySet().iterator().next();
            assertNotNull(hostServiceName, "Expected host service name to be not null");
            AvailabilityZoneDetails.HostService hostService = zone.getHosts().get(hostName).get(hostServiceName);
            assertTrue(hostService.isAvailable(), "Couldn't find host service availability");
            assertTrue(hostService.isActive(), "Couldn't find host service state");
            assertNotNull(hostService.getUpdated(), "Expected Updated time, but none received ");
        }
    }
}

[Buggy Hunk]
AvailabilityZoneDetails.HostService hostService = zone.getHosts().get(hostName).get(hostServiceName);

[Patch]
HostService hostService = zone.getHosts().get(hostName).get(hostServiceName);

[Demonstration 2]

[Buggy Method]
@NonNull
private List<@NonNull HTNode> buildLatestBranch(int rootNodeSeqNb) throws ClosedChannelException {
    List<@NonNull HTNode> list = new ArrayList<>();
    HTNode nextChildNode = fTreeIO.readNode(rootNodeSeqNb);
    list.add(nextChildNode);
    /* Follow the last branch up to the leaf */
    while (nextChildNode.getNodeType() == HTNode.NodeType.CORE) {
        nextChildNode = fTreeIO.readNode(((CoreNode) nextChildNode).getLatestChild());
        list.add(nextChildNode);
    }
    return Collections.synchronizedList(list);
}

[Buggy Hunk]
private @NonNull List<@NonNull HTNode> buildLatestBranch(int rootNodeSeqNb) throws ClosedChannelException {

[Patch]
private synchronized @NonNull List<@NonNull HTNode> buildLatestBranch(int rootNodeSeqNb) throws ClosedChannelException {

[Demonstration 3]

[Buggy Method]
private void buildStyleguideHierarchy() {
    if (sections.size() == 0) {
        return;
    }
    int maxLevels = sections.values().stream().max(Comparator.comparingInt(value -> value.getStyleGuidePath().length)).get().getStyleGuidePath().length;
    int minLevels = sections.values().stream().min(Comparator.comparingInt(value -> value.getStyleGuidePath().length)).get().getStyleGuidePath().length;
    Map<Integer, List<StyleguideSection>> sectionDepths = new TreeMap<>();
    for (StyleguideSection section : sections.values()) {
        if (!sectionDepths.containsKey(section.getDepth())) {
            sectionDepths.put(section.getDepth(), new ArrayList<>());
        }
        sectionDepths.get(section.getDepth()).add(section);
    }
    for (int i = minLevels; i <= maxLevels; i++) {
        if (!sectionDepths.containsKey(i)) {
            continue;
        }
        if (!sectionDepths.containsKey(i - 1)) {
            continue;
        }
        for (StyleguideSection sectionAtDepth : sectionDepths.get(i)) {
            for (StyleguideSection possibleParent : sectionDepths.get(i - 1)) {
                if (possibleParent.getTerminatingPath().equalsIgnoreCase(sectionAtDepth.getPathAtLevel(i - 1))) {
                    sectionAtDepth.setParent(possibleParent);
                    break;
                }
            }
        }
    }
    for (StyleguideSection section : sections.values()) {
        if (section.getDepth() > 1 && section.getParent() == null) {
            Clog.w("No parent section defined for section {}", section.getStyleGuideReference());
        }
        for (StyleguideSection possibleChild : sections.values()) {
            if (possibleChild.getParent() != null && possibleChild.getParent() == section) {
                section.getChildren().add(possibleChild);
            }
        }
    }
}

[Buggy Hunk]
if(possibleParent.getTerminatingPath().equalsIgnoreCase(sectionAtDepth.getPathAtLevel(i - 1))) {

[Patch]
if(possibleParent.isParentOf(sectionAtDepth)) {