From: <leg...@at...> - 2003-09-09 08:48:30
|
Message: A new issue has been created in JIRA. --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-319 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-319 Summary: PreparedStatementCache should check for NULL on equals() Type: Patch Status: Unassigned Priority: Trivial Project: Hibernate2 Components: core Assignee: Reporter: Jonas Van Poucke Created: Tue, 9 Sep 2003 3:47 AM Updated: Tue, 9 Sep 2003 3:47 AM Environment: JDK 1.4.1 and 1.4.2 Description: I found PrepeparedStatementCache to throw NullPointerExceptions. The bas news: I could not exactly trace the location of the bug. The problem lies in the fact that java.util.LinkedList has some entries where the element is NULL (in our case the element is a PrepeparedStatementCache$Entry). Also, the line entries.remove(entryMap.get(ps)); is dangerous: the entryMap.get(ps) sometimes return NULL as well. I could not find the point where the key-value pair is removed. The good news: I fixed this bug by modifying the PrepeparedStatementCache in two places: --- Fix 1 --- The equals() method of the Entry inner class should be: public boolean equals(Object other) { Entry oe = (Entry) other; return oe != null && oe.connection == connection && oe.scrollable == scrollable && oe.sql.equals(sql); } That is, I added oe != null --- Fix 2 --- The close(Collection statements) method should also check for NULL elemements: private void close(Collection statements) { PreparedStatement ps; Iterator iter = statements.iterator(); while (iter.hasNext()) { try { ps = (PreparedStatement) iter.next(); if (ps != null) { ps.close(); } } catch (SQLException sqle) { log.warn("could not close statement", sqle); } } } I hope that this patch actually solves a problem in the right place, i.e. that the bug is not created outside of PreparedStatementCache or in the JDK Background: By looking on the net, I found there might be a --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |