For those of you not following the thread on james-user, we found a JDBC
resource leak that impacts Oracle users seriously (out of resources).

As stated there on james-user:

"This is a bug, and it really ought to be fixed.  The change is
well-understood, used in all other areas, and easily tested.  We know that
we have a number of Oracle users, and this is a resource leak for them.  I
just checked my private tree against the CVS, and I don't have any other
differences that would be termed a serious or potentially wide-spread
defect.  We ought to vote on whether we would prefer to support the Release
with or without the fix."

The code is simply that there is one method (out of all the other similar
places) where the common pattern we use everywhere else had not been
implemented.  The change is attached, and consists of the following:

  1. move two declarations out of a try block so that they
     are available to the finally clause.

  2. add the close statements to the existing finally clause.

We have to support the Release.  I would prefer not to have to point Oracle
users at a patch or immediately issue a point release.

+1 to commit the change pending successful testing by the Oracle user who is
working with us on james-user, as well as normal testing.

        --- Noel
Index: src/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java
===================================================================
RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java,v
retrieving revision 1.13
diff -u -r1.13 AbstractJdbcUsersRepository.java
--- src/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java   4 Oct 
2002 08:17:49 -0000       1.13
+++ src/java/org/apache/james/userrepository/AbstractJdbcUsersRepository.java   24 Nov 
+2002 19:50:36 -0000
@@ -475,16 +475,17 @@
 
         // Always get the user via case-insensitive SQL,
         // then check case if necessary.
+        PreparedStatement getUsersStatement = null;
+        ResultSet rsUsers = null;
         Connection conn = openConnection();
         try {
             // Get a ResultSet containing all users.
             String sql = m_userByNameCaseInsensitiveSql;
-            PreparedStatement getUsersStatement = 
-                conn.prepareStatement(sql);
+            getUsersStatement = conn.prepareStatement(sql);
 
             getUsersStatement.setString(1, name.toLowerCase(Locale.US));
 
-            ResultSet rsUsers = getUsersStatement.executeQuery();
+            rsUsers = getUsersStatement.executeQuery();
 
             // For case-insensitive matching, the first matching user will be 
returned.
             User user = null;
@@ -505,6 +506,8 @@
             throw new CascadingRuntimeException("Error accessing database", sqlExc);
         }
         finally {
+            theJDBCUtil.closeJDBCResultSet(rsUsers);
+            theJDBCUtil.closeJDBCStatement(getUsersStatement);
             theJDBCUtil.closeJDBCConnection(conn);
         }
     }

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to