longzenvo / log4jdbc

Automatically exported from code.google.com/p/log4jdbc
0 stars 0 forks source link

ResultSet.getStatement creates new Connection??? #33

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Resultset.getStatement() method call

What is the expected output? What do you see instead?

In connection.log reports new connection creation when ResultSet.getStatement() 
is called.
According to 
http://download.oracle.com/javase/6/docs/api/java/sql/ResultSet.html#getStatemen
t%28%29 null or the Statement which produced the ResultSet is returned. I 
wouldn't expect a new Connection creation here:

Current code:
     Statement s = realResultSet.getStatement();
      if (s == null)
      {
        return (Statement) reportReturn(methodCall, s);
      }
      else
      {
        //todo: what's going on here?
        return (Statement) reportReturn(methodCall, new StatementSpy(new ConnectionSpy(s.getConnection()), s));
      }

What about this suggested code?:

  Statement s = realResultSet.getStatement();
  return (Statement) reportReturn(methodCall, s);

What version of the product are you using? On what operating system?
log4jdbc3-1.2alpha2.jar 

Original issue reported on code.google.com by Zsolt.S...@gmail.com on 8 Nov 2010 at 1:33

GoogleCodeExporter commented 9 years ago
I also found this to be a real issue  and a quite serious problem exactly with 
the noted code block.
The problem is, that new ConnectionSpy objects are created, and added to the 
connectionTracker -Map in ConnectionSpy class, but they will never be removed 
from this map.
This results in nonstopping growing of the connectionTracker-map.
Within our application, which has quite high database useage, and which is 
restarted rarely, this resulted in blocking problems (the access to the 
connectionTracker map gets slow and is inside synchronized block), and 
additionally a memory leak problem, all available memory will be used for the 
connectionTracker -map.

Original comment by uwe.lamp...@gmail.com on 19 Nov 2010 at 10:53

GoogleCodeExporter commented 9 years ago
Thanks for the report.  I will fix it soon.

Original comment by arthur.b...@gmail.com on 19 Nov 2010 at 2:06

GoogleCodeExporter commented 9 years ago
Fixed, SVN rev 93.

Original comment by arthur.b...@gmail.com on 8 Jan 2011 at 3:21

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 10f13dece77b.

Original comment by arthur.b...@gmail.com on 19 Mar 2013 at 3:24