#fixed code
                                @Test
    public void testUnmap() throws IOException, InterruptedException {

        String TMP = System.getProperty("java.io.tmpdir");
        String basePath = TMP + "/testUnmap";
        File file = new File(basePath);
        File dir = file.getParentFile();
        long free0 = dir.getFreeSpace();

        MappedFile mfile = new MappedFile(basePath, 1024 * 1024);
        MappedMemory map0 = mfile.acquire(0);
        fill(map0.buffer());
        MappedMemory map1 = mfile.acquire(1);
        fill(map1.buffer().force());
        long free1 = dir.getFreeSpace();

        mfile.release(map1);
        mfile.release(map0);

        mfile.close();

//        printMappings();
        long free2 = dir.getFreeSpace();
        delete(file);
        long free3 = 0;
        for (int i = 0; i < 100; i++) {
            free3 = dir.getFreeSpace();
            System.out.println("Freed " + free0 + " ~ " + free1 + " ~ " + free2 + " ~ " + free3 + ", delete = " + file.delete());
            if (free3 > free1)
                break;
            Thread.sleep(500);
        }
        assertTrue("free3-free1: " + (free3 - free1), free3 > free1);
    }
#vulnerable code 
                                @Test
    public void testUnmap() throws IOException, InterruptedException {

        String TMP = System.getProperty("java.io.tmpdir");
        String basePath = TMP + "/testUnmap";
        File file = new File(basePath);
        File dir = file.getParentFile();
        long free0 = dir.getFreeSpace();

        MappedFile mfile = new MappedFile(basePath, 1024 * 1024);
        MappedMemory map0 = mfile.acquire(0);
        fill(map0.buffer());
        MappedMemory map1 = mfile.acquire(1);
        fill(map1.buffer().force());
        long free1 = dir.getFreeSpace();

        map1.release();
        map0.release();
        mfile.close();

//        printMappings();
        long free2 = dir.getFreeSpace();
        delete(file);
        long free3 = 0;
        for (int i = 0; i < 100; i++) {
            free3 = dir.getFreeSpace();
            System.out.println("Freed " + free0 + " ~ " + free1 + " ~ " + free2 + " ~ " + free3 + ", delete = " + file.delete());
            if (free3 > free1)
                break;
            Thread.sleep(500);
        }
        assertTrue("free3-free1: " + (free3 - free1), free3 > free1);
    } 
                            #location 19 
                            #vulnerability type RESOURCE_LEAK