#fixed code
                             public void commitAndRelease(boolean modifiesInedges, boolean modifiesOutedges) throws IOException {
		int nblocks = blockIds.length;

		if (modifiesInedges) {
			int startStreamBlock = rangeStartEdgePtr / blocksize;
			for(int i=0; i < nblocks; i++) {
				String blockFilename = ChiFilenames.getFilenameShardEdataBlock(edgeDataFilename, i, blocksize);
				if (i >= startStreamBlock) {
					// Synchronous write
					CompressedIO.writeCompressed(new File(blockFilename), 
							dataBlockManager.getRawBlock(blockIds[i]),
							blockSizes[i]);
				} else {
					// Asynchronous write (not implemented yet, so is same as synchronous)
					CompressedIO.writeCompressed(new File(blockFilename), 
							dataBlockManager.getRawBlock(blockIds[i]),
							blockSizes[i]);
				}
			}

		} else if (modifiesOutedges) {
			int last = streamingOffsetEdgePtr;
			if (last == 0) {
				last = edataFilesize;
			}
			int startblock = (int) (rangeStartEdgePtr / blocksize);
			int endblock = (int) (last / blocksize);
			for(int i=startblock; i <= endblock; i++) {
				String blockFilename = ChiFilenames.getFilenameShardEdataBlock(edgeDataFilename, i, blocksize);
				CompressedIO.writeCompressed(new File(blockFilename), 
						dataBlockManager.getRawBlock(blockIds[i]),
						blockSizes[i]);
			}
		}
		/* Release all blocks */
		for(Integer blockId : blockIds) {
			dataBlockManager.release(blockId);
		}
	}
#vulnerable code 
                                public void commitAndRelease(boolean modifiesInedges, boolean modifiesOutedges) throws IOException {
        byte[] data = dataBlockManager.getRawBlock(blockId);

        if (modifiesInedges) {
            FileOutputStream fos = new FileOutputStream(new File(edgeDataFilename));
            fos.write(data);
            fos.close();
        } else if (modifiesOutedges) {
            ucar.unidata.io.RandomAccessFile rFile =
                    new ucar.unidata.io.RandomAccessFile(edgeDataFilename, "rwd");
            rFile.seek(rangeStartEdgePtr);
            int last = streamingOffsetEdgePtr;
            if (last == 0) last = edataFilesize;
            rFile.write(data, rangeStartEdgePtr, last  - rangeStartEdgePtr);
            rFile.close();
        }
        dataBlockManager.release(blockId);

    } 
                            #location 16 
                            #vulnerability type RESOURCE_LEAK