Projects tigase _server server-core Issues #170
Connection leak at DataRepositoryImpl.initRepo() (#170)
Won't Fix
Tony Fu opened 1 decade ago

In case of SQLException, the connection object is never closed.

private void initRepo() throws SQLException {


	// Statement stmt = null;

	ResultSet rs = null;


	try {

		synchronized (db_statements) {

			db_statements.clear();

			DriverManager.setLoginTimeout(DB_CONN_TIMEOUT);

			conn = DriverManager.getConnection(db_conn);

			conn.setAutoCommit(true);

			derby_mode = db_conn.startsWith("jdbc:derby");

			initPreparedStatements();


			// stmt = conn.createStatement();

		}

	} finally {

		release(null, rs);


		// release(stmt, rs);

		// stmt = null;

		rs = null;

	}

}

In fact, the connection is never closed. The release method does nothing:

public void release(Statement stmt, ResultSet rs) {

	if (rs != null) {

		try {

			rs.close();

		} catch (SQLException sqlEx) {

		}

	}


	if (stmt != null) {

		try {

			stmt.close();

		} catch (SQLException sqlEx) {

		}

	}

}
Artur Hefczyc commented 1 decade ago

The connection is never closed because it is reused as many times as possible. The SQL Exception is not enough reason to close the connection. There are many possible SQL exceptions which do not prevent from reusing the connection for further calls and queries.

Therefore the release method is not supposed to close the connection. When the DB connections is broken for whatever reason the JVM and OS takes care of cleaning unused objects and resources.

issue 1 of 1
Type
Bug
Priority
Normal
Assignee
RedmineID
950
Issue Votes (0)
Watchers (0)
Reference
tigase/_server/server-core#170
Please wait...
Page is in error, reload to recover