james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Sitsky <s...@nuix.com.au>
Subject JDBCMailRepository connection leak?
Date Wed, 24 Oct 2001 07:09:14 GMT
G'day,

I was browsing though JDBCMailRepository.java, and noticed in many of the 
methods (store, retrieve, remove, list), a JDBC connection is obtained, 
but in the event of an exception being thrown, the connection isn't closed 
in the catch() block, which will result in a connection leak, since 
connection.close() isn't called, although the connection object be garbage 
collected of course.

The code should be refactored to have a finally() block so that the code 
looks like:

method()
{
    try
    {
        Connection c = getConnection();

        ...
    }
    catch (Exception e)
    {
        ...
    }
    finally
    {
        c.close();
    }
}

-- 
Cheers,
David

---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org


Mime
View raw message