This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 146589 - Database connections added through a layer file may not be detected
Summary: Database connections added through a layer file may not be detected
Status: RESOLVED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Andrei Badea
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-08 23:32 UTC by David Vancouvering
Modified: 2008-09-19 17:36 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Vancouvering 2008-09-08 23:32:16 UTC
I made a change to cache connections in the ConnectionList class.  This was done as a workaround to the fact that a
Lookup for a given database connection doesn't return the same object even though it should, and thus the live JDBC
connection associated with the DatabaseConnection is lost.

However, this solution is not workable long-term, because if an API user dynamically adds a connection, we don't pick
this up right now without a restart.

One possible solution is to use the lookup listener to detect the new connection being added and add it to the cache
this way.  

We should create a unit test that reproduces this problem (a dynamically added connection not being detected), and then
verifies that we've fixed it.
Comment 1 David Vancouvering 2008-09-08 23:33:47 UTC
Changing the title of the bug to reflect the problem, not the solution.  Note that I haven't reproduced the problem, but
I am pretty sure it's there knowing how the code is written.
Comment 2 David Vancouvering 2008-09-15 19:30:45 UTC
Actually, this is not true.  I am noticing programmatically added connections being detected.

The issue is if someone adds a connection using a layer file - I don't think we notice those.

The fix is to add a lookup listener that adds the new connection to the cache.
Comment 3 Andrei Badea 2008-09-16 15:34:41 UTC
The right solution is to ask for the maintainer of data systems to fix the lookup problem. I do not support the addition
of yet another caching layer. That is the task of data systems, they should perform it correctly.

Another thing it that I'm not convinced that the caching is actually working around the lookup problem. The lookup bug
was filed back in 5.5 times, still the DB Explorer worked fine before 6.5 as far as I can remember. I suspect the
problem is a different one: the DatabaseConnection instances returned by the lookup were not held strongly by the DB
Explorer. Lookup doesn't hold them strongly, so they could be garbage-collected. Keeping them in ConnectionList is not
right -- just a workaround.
Comment 4 David Vancouvering 2008-09-16 17:12:45 UTC
Yes, good points. I'd rather not cache if we can help it.  I was unaware of the strong/weak holding of references being
part of the issue.  
Comment 5 David Vancouvering 2008-09-16 17:17:19 UTC
Rob, I'm passing this over to you because I think this issue is intimately involved with what you're working on.  Feel
free to assign back to me if you want.
Comment 6 Rob Englander 2008-09-16 19:20:22 UTC
No problem, I'll work on it.
Comment 7 Andrei Badea 2008-09-19 17:36:50 UTC
Fixed as a side effect of #4c829f9abb13.