[Demonstration 1]

[Buggy Method]
private Map<String, FsVolumeSpi> getStorageIDToVolumeMap() throws DiskBalancerException {
    Map<String, FsVolumeSpi> pathMap = new HashMap<>();
    FsDatasetSpi.FsVolumeReferences references;
    try {
        try (AutoCloseableLock lock = this.dataset.acquireDatasetLock()) {
            references = this.dataset.getFsVolumeReferences();
            for (int ndx = 0; ndx < references.size(); ndx++) {
                FsVolumeSpi vol = references.get(ndx);
                pathMap.put(vol.getStorageID(), vol);
            }
            references.close();
        }
    } catch (IOException ex) {
        LOG.error("Disk Balancer - Internal Error.", ex);
        throw new DiskBalancerException("Internal error", ex, DiskBalancerException.Result.INTERNAL_ERROR);
    }
    return pathMap;
}

[Buggy Hunk]
try(AutoCloseableLock lock = this.dataset.acquireDatasetLock()) {

[Patch]
try(AutoCloseableLock lock = this.dataset.acquireDatasetLock(true)) {

[Demonstration 2]

[Buggy Method]
public void send(Message message, InetSocketAddress receiver) throws JAXBException, IOException, TimeoutException, InterruptedException {
    this.send(message, receiver, DEFAULT_TIMEOUT);
}

[Buggy Hunk]
throws JAXBException, IOException, TimeoutException, InterruptedException {

[Patch]
throws JAXBException, IOException, TimeoutException, InterruptedException, SenderStoppedException {

[Demonstration 3]

[Buggy Method]
private void allocate(BaseByteBuffer<T> buffer, int capacity) {
    int normalSize = normalizeCapacity(capacity);
    if (isTinyOrSmall(normalSize)) {
        Subpage<T>[] table;
        int tableId;
        if (isTiny(normalSize)) {
            table = tinySubpagePool;
            tableId = tinyId(normalSize);
        } else {
            table = smallSubpagePool;
            tableId = smallId(normalSize);
        }
        synchronized (this) {
            final Subpage<T> head = table[tableId];
            final Subpage<T> s = head.next;
            if (s != head) {
                long handle = s.allocate();
                s.getChunk().initBuf(buffer, handle, normalSize);
                return;
            }
        }
        allocateNormal(buffer, capacity, normalSize);
        return;
    } else if (normalSize <= chunkSize) {
        //分配大于pageSize 小于chunkSize
        allocateNormal(buffer, capacity, normalSize);
        return;
    } else {
        //分配huge
        allocateHuge(buffer, capacity);
    }
}

[Buggy Hunk]
s.getChunk().initBuf(buffer, handle, normalSize);

[Patch]
s.getChunk().initBuf(buffer, handle, capacity);