#vulnerable code 
                                @Test
    public void testMaxLifetime() throws Exception
    {
        HikariConfig config = new HikariConfig();
        config.setMinimumIdle(0);
        config.setMaximumPoolSize(1);
        config.setInitializationFailFast(true);
        config.setConnectionTestQuery("VALUES 1");
        config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");

        System.setProperty("com.zaxxer.hikari.housekeeping.periodMs", "100");

        HikariDataSource ds = new HikariDataSource(config);

        try
        {
            System.clearProperty("com.zaxxer.hikari.housekeeping.periodMs");
    
            ds.setMaxLifetime(700);
    
            Assert.assertSame("Total connections not as expected", 0, TestElf.getPool(ds).getTotalConnections());
            Assert.assertSame("Idle connections not as expected", 0, TestElf.getPool(ds).getIdleConnections());
    
            Connection connection = ds.getConnection();
            Assert.assertNotNull(connection);
    
            Assert.assertSame("Second total connections not as expected", 1, TestElf.getPool(ds).getTotalConnections());
            Assert.assertSame("Second idle connections not as expected", 0, TestElf.getPool(ds).getIdleConnections());
            connection.close();
    
            Assert.assertSame("Idle connections not as expected", 1, TestElf.getPool(ds).getIdleConnections());
    
            Connection connection2 = ds.getConnection();
            Assert.assertSame("Expected the same connection", connection, connection2);
            Assert.assertSame("Second total connections not as expected", 1, TestElf.getPool(ds).getTotalConnections());
            Assert.assertSame("Second idle connections not as expected", 0, TestElf.getPool(ds).getIdleConnections());
            connection2.close();

            Thread.sleep(2000);

            connection2 = ds.getConnection();
            Assert.assertNotSame("Expected a different connection", connection, connection2);
    
            connection2.close();
    
            Assert.assertSame("Post total connections not as expected", 1, TestElf.getPool(ds).getTotalConnections());
            Assert.assertSame("Post idle connections not as expected", 1, TestElf.getPool(ds).getIdleConnections());
        }
        finally
        {
            ds.shutdown();
        }
    } 
                            #location 51 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                @Test
    public void testMaxLifetime() throws Exception
    {
        HikariConfig config = new HikariConfig();
        config.setMinimumIdle(0);
        config.setMaximumPoolSize(1);
        config.setInitializationFailFast(true);
        config.setConnectionTestQuery("VALUES 1");
        config.setDataSourceClassName("com.zaxxer.hikari.mocks.StubDataSource");

        System.setProperty("com.zaxxer.hikari.housekeeping.periodMs", "100");

        HikariDataSource ds = new HikariDataSource(config);

        try
        {
            System.clearProperty("com.zaxxer.hikari.housekeeping.periodMs");
    
            ds.setMaxLifetime(700);
    
            Assert.assertSame("Total connections not as expected", 0, TestElf.getPool(ds).getTotalConnections());
            Assert.assertSame("Idle connections not as expected", 0, TestElf.getPool(ds).getIdleConnections());
    
            Connection connection = ds.getConnection();
            Assert.assertNotNull(connection);
    
            Assert.assertSame("Second total connections not as expected", 1, TestElf.getPool(ds).getTotalConnections());
            Assert.assertSame("Second idle connections not as expected", 0, TestElf.getPool(ds).getIdleConnections());
            connection.close();
    
            Assert.assertSame("Idle connections not as expected", 1, TestElf.getPool(ds).getIdleConnections());
    
            Connection connection2 = ds.getConnection();
            Assert.assertSame("Expected the same connection", connection, connection2);
            Assert.assertSame("Second total connections not as expected", 1, TestElf.getPool(ds).getTotalConnections());
            Assert.assertSame("Second idle connections not as expected", 0, TestElf.getPool(ds).getIdleConnections());
            connection2.close();

            Thread.sleep(2000);

            connection2 = ds.getConnection();
            Assert.assertNotSame("Expected a different connection", connection, connection2);
    
            connection2.close();
    
            Assert.assertSame("Post total connections not as expected", 1, TestElf.getPool(ds).getTotalConnections());
            Assert.assertSame("Post idle connections not as expected", 1, TestElf.getPool(ds).getIdleConnections());
        }
        finally
        {
            ds.close();
        }
    }