#vulnerable code 
                                @Test
    public void testAsyncLogUsesNanoTimeClock() throws Exception {
        final File file = new File("target", "NanoTimeToFileTest.log");
        // System.out.println(f.getAbsolutePath());
        file.delete();
        final AsyncLogger log = (AsyncLogger) LogManager.getLogger("com.foo.Bar");
        final long before = System.nanoTime();
        log.info("Use actual System.nanoTime()");
        assertTrue("using SystemNanoClock", log.getNanoClock() instanceof SystemNanoClock);

        NanoClockFactory.setMode(Mode.Dummy);
        final long DUMMYNANOTIME = 0;
        
        // trigger a new nano clock lookup
        log.updateConfiguration(log.getContext().getConfiguration());
        
        log.info("Use dummy nano clock");
        assertTrue("using SystemNanoClock", log.getNanoClock() instanceof DummyNanoClock);
        
        CoreLoggerContexts.stopLoggerContext(file); // stop async thread

        final BufferedReader reader = new BufferedReader(new FileReader(file));
        final String line1 = reader.readLine();
        final String line2 = reader.readLine();
        // System.out.println(line1);
        // System.out.println(line2);
        reader.close();
        file.delete();

        assertNotNull("line1", line1);
        assertNotNull("line2", line2);
        final String[] line1Parts = line1.split(" AND ");
        assertEquals("Use actual System.nanoTime()", line1Parts[2]);
        assertEquals(line1Parts[0], line1Parts[1]);
        long loggedNanoTime = Long.parseLong(line1Parts[0]);
        assertTrue("used system nano time", loggedNanoTime - before < TimeUnit.SECONDS.toNanos(1));
        
        final String[] line2Parts = line2.split(" AND ");
        assertEquals("Use dummy nano clock", line2Parts[2]);
        assertEquals(String.valueOf(DUMMYNANOTIME), line2Parts[0]);
        assertEquals(String.valueOf(DUMMYNANOTIME), line2Parts[1]);
    } 
                            #location 42 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                @Test
    public void testAsyncLogUsesNanoTimeClock() throws Exception {
        final File file = new File("target", "NanoTimeToFileTest.log");
        // System.out.println(f.getAbsolutePath());
        file.delete();
        final AsyncLogger log = (AsyncLogger) LogManager.getLogger("com.foo.Bar");
        final long before = System.nanoTime();
        log.info("Use actual System.nanoTime()");
        assertTrue("using SystemNanoClock", log.getNanoClock() instanceof SystemNanoClock);

        final long DUMMYNANOTIME = -53;
        log.getContext().getConfiguration().setNanoClock(new DummyNanoClock(DUMMYNANOTIME));
        log.updateConfiguration(log.getContext().getConfiguration());

        // trigger a new nano clock lookup
        log.updateConfiguration(log.getContext().getConfiguration());

        log.info("Use dummy nano clock");
        assertTrue("using SystemNanoClock", log.getNanoClock() instanceof DummyNanoClock);

        CoreLoggerContexts.stopLoggerContext(file); // stop async thread

        final BufferedReader reader = new BufferedReader(new FileReader(file));
        final String line1 = reader.readLine();
        final String line2 = reader.readLine();
        // System.out.println(line1);
        // System.out.println(line2);
        reader.close();
        file.delete();

        assertNotNull("line1", line1);
        assertNotNull("line2", line2);
        final String[] line1Parts = line1.split(" AND ");
        assertEquals("Use actual System.nanoTime()", line1Parts[2]);
        assertEquals(line1Parts[0], line1Parts[1]);
        long loggedNanoTime = Long.parseLong(line1Parts[0]);
        assertTrue("used system nano time", loggedNanoTime - before < TimeUnit.SECONDS.toNanos(1));

        final String[] line2Parts = line2.split(" AND ");
        assertEquals("Use dummy nano clock", line2Parts[2]);
        assertEquals(String.valueOf(DUMMYNANOTIME), line2Parts[0]);
        assertEquals(String.valueOf(DUMMYNANOTIME), line2Parts[1]);
    }