pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mikko Tiihonen <mikko.tiihonen@iki.fi>
To: pgsql-jdbc <pgsql-jdbc@postgresql.org>
Subject: [PATCH] Stop test cases from leaking connections
Date: Fri, 20 Jul 2007 22:14:06 +0300
Message-ID: <1184958846.1632.33.camel@dual.local> (raw)

Hi,

The following patch fixes connection leaks in the current unit test
cases. The patch allows passing the tests with under 10 connections in
the server.

inline patch 1: org/postgresql/test/jdbc2/TimezoneTest.java, org/postgresql/test/jdbc2/optional/BaseDataSourceTest.java, org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java and 2 more (+9/-7 lines) download inline-1.patchIndex: org/postgresql/test/jdbc2/TimezoneTest.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/jdbc2/TimezoneTest.java,v retrieving revision 1.4 diff -u -r1.4 TimezoneTest.java --- org/postgresql/test/jdbc2/TimezoneTest.java 16 Apr 2007 18:31:38 -0000 1.4 +++ org/postgresql/test/jdbc2/TimezoneTest.java 20 Jul 2007 19:04:12 -0000 @@ -97,6 +97,7 @@ TimeZone.setDefault(saveTZ); TestUtil.dropTable(con, "testtimezone"); + TestUtil.closeDB(con); } public void testGetTimestamp() throws Exception Index: org/postgresql/test/jdbc2/optional/BaseDataSourceTest.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/jdbc2/optional/BaseDataSourceTest.java,v retrieving revision 1.11 diff -u -r1.11 BaseDataSourceTest.java --- org/postgresql/test/jdbc2/optional/BaseDataSourceTest.java 11 Jan 2005 08:25:48 -0000 1.11 +++ org/postgresql/test/jdbc2/optional/BaseDataSourceTest.java 20 Jul 2007 19:04:12 -0000 @@ -62,6 +62,7 @@ */ protected void tearDown() throws Exception { + TestUtil.closeDB(con); con = TestUtil.openDB(); TestUtil.dropTable(con, "poolingtest"); TestUtil.closeDB(con); Index: org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java,v retrieving revision 1.15 diff -u -r1.15 ConnectionPoolTest.java --- org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java 11 Jan 2005 08:25:48 -0000 1.15 +++ org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java 20 Jul 2007 19:04:12 -0000 @@ -320,7 +320,7 @@ try { PooledConnection pc = getPooledConnection(); - Connection con = pc.getConnection(); + con = pc.getConnection(); assertTrue(!con.isClosed()); con.close(); assertTrue(con.isClosed()); @@ -346,7 +346,7 @@ try { PooledConnection pc = getPooledConnection(); - Connection con = pc.getConnection(); + con = pc.getConnection(); Statement s = con.createStatement(); Connection conRetrieved = s.getConnection(); @@ -368,7 +368,7 @@ try { PooledConnection pc = getPooledConnection(); - Connection con = pc.getConnection(); + con = pc.getConnection(); s = con.createStatement(); } catch (SQLException e) @@ -400,7 +400,7 @@ try { PooledConnection pc = getPooledConnection(); - Connection con = pc.getConnection(); + con = pc.getConnection(); PreparedStatement s = con.prepareStatement("select 'x'"); Connection conRetrieved = s.getConnection(); @@ -422,7 +422,7 @@ try { PooledConnection pc = getPooledConnection(); - Connection con = pc.getConnection(); + con = pc.getConnection(); CallableStatement s = con.prepareCall("select 'x'"); Connection conRetrieved = s.getConnection(); Index: org/postgresql/test/jdbc2/optional/PoolingDataSourceTest.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/jdbc2/optional/PoolingDataSourceTest.java,v retrieving revision 1.7 diff -u -r1.7 PoolingDataSourceTest.java --- org/postgresql/test/jdbc2/optional/PoolingDataSourceTest.java 11 Jan 2005 08:25:48 -0000 1.7 +++ org/postgresql/test/jdbc2/optional/PoolingDataSourceTest.java 20 Jul 2007 19:04:13 -0000 @@ -34,11 +34,11 @@ protected void tearDown() throws Exception { - super.tearDown(); if (bds instanceof PoolingDataSource) { ((PoolingDataSource) bds).close(); } + super.tearDown(); } /** Index: org/postgresql/test/jdbc3/Jdbc3CallableStatementTest.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/jdbc3/Jdbc3CallableStatementTest.java,v retrieving revision 1.3 diff -u -r1.3 Jdbc3CallableStatementTest.java --- org/postgresql/test/jdbc3/Jdbc3CallableStatementTest.java 15 Jul 2007 15:03:31 -0000 1.3 +++ org/postgresql/test/jdbc3/Jdbc3CallableStatementTest.java 20 Jul 2007 19:04:13 -0000 @@ -94,7 +94,7 @@ stmt.execute("drop function myiofunc(a INOUT int, b OUT int) "); stmt.execute("drop function myif(a INOUT int, b IN int)"); stmt.close(); - + TestUtil.closeDB(con); } public void testSomeInOut() throws Throwable {

view thread (2+ messages)  latest in thread

Message-ID: <1184958846.1632.33.camel@dual.local>
Permalink:  ../1184958846.1632.33.camel@dual.local/
Also on:    postgresql.org/message-id/1184958846.1632.33.camel@dual.local

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: mikko.tiihonen@iki.fi
  Subject: Re: [PATCH] Stop test cases from leaking connections
  In-Reply-To: <1184958846.1632.33.camel@dual.local>
  References: <1184958846.1632.33.camel@dual.local>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox