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 130877

Summary: Duplicated connection nodes
Product: db Reporter: Lukas Jungmann <jungi>
Component: CodeAssignee: David Vancouvering <davidvc>
Status: VERIFIED FIXED    
Severity: blocker CC: sustaining
Priority: P2 Keywords: REGRESSION
Version: 6.x   
Hardware: All   
OS: Windows Vista   
Issue Type: DEFECT Exception Reporter:
Attachments: screenshot
screenshot
screenshot from mostly up-to-date (~6hours old) 6.1rc1

Description Lukas Jungmann 2008-03-23 21:46:12 UTC
jdk6.0_05, netbeans-hudson-trunk-1247-javaee

-start IDE w/ fresh user dir
-expand Databases node in services tab

=> see attachment
Comment 1 Lukas Jungmann 2008-03-23 21:46:37 UTC
Created attachment 58898 [details]
screenshot
Comment 2 David Vancouvering 2008-03-23 22:24:50 UTC
Hi, jungi, can you please tell me the date on this build?  I checked in some changes on Friday, and I want to know if
this is something you have seen on a build *after* or *before* this change.

If you can tell me the actual Mercurial revision number, even better.

Thanks,

David
Comment 3 Lukas Jungmann 2008-03-23 23:03:23 UTC
Hi David, the build is from today evening CET, only few hours old - 23.3.2008 17:53:54 - see:
http://deadlock.netbeans.org/hudson/job/trunk/1247/ for more details (not sure how long the link will be active)

I can also reproduce this in my own build from today's morning on JDK5.0.15, hg tip shows:
D:\hg\development>hg tip
changeset:   75022:b911c98a7c14
tag:         tip
user:        jungi@netbeans.org
date:        Sun Mar 23 18:38:58 2008 +0100
summary:     IZ #119811: Missing/incorrect step name in samples wizard
Comment 4 Lukas Jungmann 2008-03-23 23:09:13 UTC
btw: the order of steps seems to be quite important here, so:

if I start the IDE with fresh userdir, expand databases node, register glassfish and check DB nodes then everything
seems to be OK

if I start the IDE with fresh userdir, register glassfish, expand databases node and check DB nodes then sample DB
connection is shown twice as on a screenshot I attached.

--lukas
Comment 5 Lukas Jungmann 2008-03-24 00:26:14 UTC
there seems to be something strange, see attached screenshot (sorry, I really don't remember what I've done now...)
Comment 6 Lukas Jungmann 2008-03-24 00:26:56 UTC
Created attachment 58905 [details]
screenshot
Comment 7 David Vancouvering 2008-03-24 04:40:12 UTC
Great, thanks for the details, jungi.
Comment 8 David Vancouvering 2008-03-24 20:06:53 UTC
Just tried this on my Mac, and I can't reproduce.  I'll try on XP.  I don't have a Vista installation...
Comment 9 David Vancouvering 2008-03-24 22:37:29 UTC
I'm not sure what happened, but I can now reliably reproduce this even without registering Glassfish.  Investigating...
Comment 10 David Vancouvering 2008-03-25 04:34:51 UTC
http://hg.netbeans.org/main?cmd=changeset;node=14f68c0f292c
Comment 11 Lukas Jungmann 2008-04-08 16:13:50 UTC
still reproducible in 6.1 see attached screenshot

note that my current steps we're a bit different:
-started IDE with fresh userdir
-create some web app and work with it for a while
-go to services tab and expand the DB node

=> there was no jdbc/sample connection registered

-never mind, I created my own DB (music) and got to issue 132037
-well, so I restarted the IDE, went to DB node and expanded it

=> jdbc/sample connection is registered twice
Comment 12 Lukas Jungmann 2008-04-08 16:15:34 UTC
Created attachment 59845 [details]
screenshot from mostly up-to-date (~6hours old) 6.1rc1
Comment 13 David Vancouvering 2008-04-08 18:53:54 UTC
Hm, what you're describing sounds like a slightly different bug, but same behavior.

Can you make the duplicate connection go away with a restart?  
Comment 14 Lukas Jungmann 2008-04-08 19:21:37 UTC
Unfortunately no - restart doesn't remove the duplicated node :( Do you want me to file another bug for that and let
this one be closed?
Comment 15 David Vancouvering 2008-04-08 19:49:30 UTC
No, it's OK, we can use this bug.
Comment 16 David Vancouvering 2008-06-18 06:51:01 UTC
OK, reproduced on Windows XP off of a fresh trunk build.

Just to be clear, this is based off of a build with -Dcluster.config=standard, and I pre-register Glassfish by setting
-J-Dcom.sun.aas.installRoot=/path/to/Glassfish when I start NB.

I will try this on MacOS rather than in my XP instance, as it's easier to work directly in Mac.

Comment 17 David Vancouvering 2008-06-18 06:53:00 UTC
Bummer, can't reproduce on Mac.  This means trying to debug across the virtual machine boundary.  Not fun.
Comment 18 David Vancouvering 2008-06-18 06:55:22 UTC
OK, I just looked and config/Databases/Connections actually physically has two copies of the sample connection.  Now I
need to figure out why it's being registered twice.

BTW, I can't reproduce issue 132027 - the sample connections are visible the first time, without restart required.
Comment 19 David Vancouvering 2008-06-18 06:58:00 UTC
OK, I just looked and config/Databases/Connections actually physically has two copies of the sample connection.  Now I
need to figure out why it's being registered twice.

BTW, I can't reproduce issue 132027 - the sample connections are visible the first time, without restart required.

Also, ugh, the Java DB node is not visible, so this is a one-two punch of a bug.
Comment 20 David Vancouvering 2008-06-18 07:13:42 UTC
More info:
- You can reproduce duplicate connection without having to create a web project
- The missing Java DB (and MySQL) nodes is random.  This is actually a separate bug that I closed because I couldn't
reproduce, but I will re-open it.

I logged when the method createSampleDatabase() was run in the derby module, and it's only run once, but we end up with
two connections.  So I haven't found the culprit yet.
Comment 21 David Vancouvering 2008-06-19 00:09:30 UTC
OK, two separate modules are trying to create and register the sample database.  

Here are the stack traces:

java.lang.Exception: Stack trace
	at java.lang.Thread.dumpStack(Thread.java:1206)
	at org.netbeans.modules.derby.api.DerbyDatabases.registerDatabase(DerbyDatabases.java:361)
	at org.netbeans.modules.derby.api.DerbyDatabases.createSampleDatabase(DerbyDatabases.java:282)
	at org.netbeans.modules.j2ee.sun.ide.j2ee.db.RegisterPointbase$ConfigureJavaDBSamples.run(RegisterPointbase.java:319)

java.lang.Exception: Stack trace
	at java.lang.Thread.dumpStack(Thread.java:1206)
	at org.netbeans.modules.derby.api.DerbyDatabases.registerDatabase(DerbyDatabases.java:361)
	at org.netbeans.modules.derby.api.DerbyDatabases.createSampleDatabase(DerbyDatabases.java:282)
	at org.netbeans.modules.derby.Installer$RegisterJDKDerby.registerSampleDatabase(Installer.java:108)
	at org.netbeans.modules.derby.Installer$RegisterJDKDerby.run(Installer.java:87)

There appears to be a timing issue, because registerDatabase calls ConnectionManager.addConnection(), and this in turn
calls RootNodeInfo.addConnectionNoConnect(), which has the following code:

 
        if (ConnectionList.getDefault().contains(dbconn)) {
            return;
        }

It looks like both threads check the ConnectionList simultaneously and then both add their connection to the list.

addConnectionNoConnect should probably synchronize checking the list and then adding to the list.

Comment 22 David Vancouvering 2008-06-19 18:19:10 UTC
http://hg.netbeans.org/main?cmd=changeset;node=96c2d254192c
Comment 23 David Vancouvering 2008-06-19 21:38:05 UTC
As per previous comment, this is fixed now.
Comment 24 Quality Engineering 2008-06-20 15:53:34 UTC
Integrated into 'main-golden', available in NB_Trunk_Production #271 build
Changeset: http://hg.netbeans.org/main/rev/96c2d254192c
User: David Van Couvering <davidvc@netbeans.org>
Log: #130877 - Java DB sample connection was showing up twice
Fixed by adding necessary synchronization when working with ConnectionList
Comment 25 rbalada 2008-07-17 12:07:44 UTC
Lukasi,

can you please verify the bugfix in trunk builds. Only verified bugfixes can go into NB 6.1 Patch (3) release.

Thanks,
-R
Comment 26 Lukas Jungmann 2008-07-17 12:56:04 UTC
v. in trunk
Comment 27 rbalada 2008-07-17 16:10:13 UTC
I've transplanted the changeset http://hg.netbeans.org/main?cmd=changeset;node=96c2d254192c into release61_fixes
repository as http://hg.netbeans.org/release61_fixes?cmd=changeset;node=e6ec4dcef5ec

The changeset http://hg.netbeans.org/main?cmd=changeset;node=14f68c0f292c was already part of release61_fixes source
base see http://hg.netbeans.org/release61_fixes?cmd=changeset;node=14f68c0f292c for ref.