Welcome Guest  |  Register  |  Login
Login Name Password
  Search  
  Index  | Recent Threads  | Unanswered Threads  | Who's Online  | Help


Quick Go »

No member browsing this thread
Thread Status: Active
Total posts in this thread: 1
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 3302 times and has 0 replies Next Thread
Male nlmarco
Expert
Member's Avatar

Germany
Joined: Mar 15, 2004
Post Count: 766
Status: Offline
Reply to this Post  Reply with Quote 
Some questions about the code in ManagedConnectionImpl

Hello Andy and Erik,

I fixed a memory leak (see NUCJDOJCA-5) and have a few questions about the code in ManagedConnectionImpl:

1) What's the difference between cleanup() and destroy()? IMHO both methods do [nearly] the same. Should we maybe put all code in cleanup() and simply call this method from destroy()? According to the JavaDoc of the cleanup() method, it should be able to be called multiple times without causing an exception (and the current implementation complies to this requirement) - so this change should be ok IMHO.

If I understand it correctly, the only difference is that cleanup() is always called when a ManagedConnection goes back to the JavaEE server's connection-pool (and thus the ManagedConnection can be reused later after this method was called), while destroy() is final and no other usage of the ManagedConnection will happen afterwards. However, in both cases, the internal JDOPersistenceManager is closed now [which was IMHO missing before] - and I think that's fine since recreating a JDOPersistenceManager is a fast operation, right? So there's no need to behave differently in cleanup() and destroy(). What do you think?

2) There's a package-protected method called clearHandles() which is, however, only called from the outside - not e.g. by cleanup() or destroy(). In contrast to cleanup(), it does not do this:
for (Iterator i = handles.iterator(); i.hasNext();)
{
((PersistenceManagerImpl)i.next()).setManagedConnection(null);
}

And in contrast to destroy(), it does not do this:
List handlesToClose = new ArrayList(handles);
for (Iterator it = handlesToClose.iterator(); it.hasNext(); )
{
PersistenceManagerImpl om = ((PersistenceManagerImpl)it.next());
if (!om.isClosed())
{
om.close();
}
}

Isn't this wrong? When the handles are cleared, shouldn't the setManagedConnection(null) and the om.close() be done on every handle that is removed from the handles? Or is it ensured that this is done by the other code which calls the clearHandles() method?

I thought about moving the handle-cleanup code from cleanup() and destroy() to the clearHandles() method, and then call clearHandles() from cleanup() [and cleanup() from destroy() - as described in (1)]. Do you think that makes sense?
----------------------------------------
Best regards, Marco smile
jfire: free erp, crm, scm and more
[Sep 10, 2008 11:08:53 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread