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 229250 - If more than one connector listed--names keep multiplying in connection wizard driver name list
Summary: If more than one connector listed--names keep multiplying in connection wizar...
Status: VERIFIED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.3.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Jiri Rechtacek
URL:
Keywords: NETFIX, PATCH_AVAILABLE
: 152756 192176 220533 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-05-01 17:51 UTC by MackSix
Modified: 2013-06-27 02:16 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Screenshot of problem. (57.11 KB, image/png)
2013-05-01 17:51 UTC, MackSix
Details
patch part1 v1 - randomly failing unittest (3.11 KB, patch)
2013-06-01 20:57 UTC, matthias42
Details | Diff
patch part2 v1 - constantly failing unittest (763 bytes, patch)
2013-06-01 21:00 UTC, matthias42
Details | Diff
patch part3 v1 - unittest/reproducer for this bug (3.75 KB, patch)
2013-06-01 21:01 UTC, matthias42
Details | Diff
patch part4 v1 - potential fix (11.51 KB, patch)
2013-06-01 21:09 UTC, matthias42
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description MackSix 2013-05-01 17:51:55 UTC
Created attachment 134013 [details]
Screenshot of problem.

1. Run Netbeans and add MySql database in Services Window>>Databases Context Menu.
2. Add new Connector/J 5.1.24 to Services Window>>Databases>>Drivers and name it MySql (Connector/J 5.1.24). (Do not delete the default driver!)
3. Open some project, like the Pet Catalog from the Java EE sample projects that uses MySQL but does not have a Connector added. You will get an error on the project and in the context menu select "Resolve data source problem...".
4. Click "Add connection".
5. Open the "Driver Name" drop down list and you will see 2 entries, "MySQL (Connector/J driver) and "MySQL (Connector/J 5.1.24)". The first one may be listed twice at this point.
6. Click Cancel and then Close and open the "Resolve data source problem..." from the Project context menu again and repeat steps 4 & 5 but now you will see the names are duplicated and there may be 2 or 3 of each of them listed.

If you continue to repeat this, the names continue to duplicate. It does not happen if only the default connector is present in Services Window>>>>Databases>>Drivers

See attached screenshot.

Product Version: NetBeans IDE 7.3.1 (Build 201304162201)
Java: 1.7.0_21; Java HotSpot(TM) 64-Bit Server VM 23.21-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_21-b11
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Comment 1 MackSix 2013-05-01 18:08:27 UTC
Actually, you don't need to open a project. You can see the same behavior with these steps:

1. Run Netbeans and add MySql database in Services Window>>Databases Context
Menu.
2. Add new Connector/J 5.1.24 to Services Window>>Databases>>Drivers and name
it MySql (Connector/J 5.1.24). (Do not delete the default driver!)
3. In Services Window>>Databases Context Menu select "New connection...".
4. Choose "MySql (Connector/J 5.1.24) and then Click "Next".
5. Open the "Driver Name" drop down list and you will see 2 entries, "MySQL
(Connector/J driver) and "MySQL (Connector/J 5.1.24)". The first one may be
listed twice at this point.
6. Click Cancel and repeat steps 3 through 5 but now you will see
the names are duplicated and there may be 2 or 3 of each of them listed.

Keep repeating steps 3 through 5 to duplicate the names more.
Comment 2 MackSix 2013-05-02 01:26:05 UTC
Changing this to code component since it is not MySQL specific, it also happens with PostgreSQL when 2 different versions of the connector are present.
Comment 3 Jaroslav Havlin 2013-05-02 06:14:06 UTC
Reproduced. Thank you, MackSix.
Comment 4 matthias42 2013-05-08 18:03:41 UTC
*** Bug 152756 has been marked as a duplicate of this bug. ***
Comment 5 matthias42 2013-05-10 17:34:54 UTC
*** Bug 220533 has been marked as a duplicate of this bug. ***
Comment 6 matthias42 2013-05-10 17:38:47 UTC
*** Bug 192176 has been marked as a duplicate of this bug. ***
Comment 7 matthias42 2013-06-01 20:52:48 UTC
I tracked it down. The problem lies in the DriverListUtil#getJdbcUtils method. It happens every time two different drivers for the same class are registered. In that case everytime getJdbcUrls is called, one additional entry is created.
Comment 8 matthias42 2013-06-01 20:57:33 UTC
Created attachment 135207 [details]
patch part1 v1 - randomly failing unittest

Fix an unreliable unittest, that suffers a race condition (swing event handling, filesystem event delivery and test execution flow). The attached patch places blocks on the relevant filesystem queues and swing threads.
Comment 9 matthias42 2013-06-01 21:00:11 UTC
Created attachment 135208 [details]
patch part2 v1 - constantly failing unittest

The attached patch moved "schema" cleaning into test setup, there it is save to asume the derby database is available. Without this patch the test in DatabaseConnectionTest#testGetJDBCConnectionWithTest fails. The test forcibly shuts down the derby database and in turn the tearDown routine fails...
Comment 10 matthias42 2013-06-01 21:01:24 UTC
Created attachment 135209 [details]
patch part3 v1 - unittest/reproducer for this bug

The error condition of the bug is reproduced by this patch.
Comment 11 matthias42 2013-06-01 21:09:21 UTC
Created attachment 135210 [details]
patch part4 v1 - potential fix

1. Move DriverListUtil#isDriverEquals to JDBCDriver#equals - the implementation is straight forward and unsurprising - and better than the Object#equals implementation in any case

2. Add a "clone" constructor to JdbcUrl

3. Don't hold all potential JdbcUrls in DriverListUtil#urls, but only save a list of templates in DriverListUtil#templateUrl. (while writing this - that last one should be templateUrls)

4. From DriverListutil#getJdbcUrls always return a list of freshly instanced JdbcUrls, in which the display name is composited from the driver name and the jdbc title.
Comment 12 Jaroslav Havlin 2013-06-04 13:36:36 UTC
Patches has been applied:
http://hg.netbeans.org/core-main/rev/d09ecf0ecc08
http://hg.netbeans.org/core-main/rev/c1ea30fe6dac
http://hg.netbeans.org/core-main/rev/8e048bb87ddf
http://hg.netbeans.org/core-main/rev/90117a807fc9

> [...] (while writing this - that last one should be templateUrls)
http://hg.netbeans.org/core-main/rev/4a61674338f9

Thank you very much, great job.
Comment 13 Quality Engineering 2013-06-05 09:33:20 UTC
Integrated into 'main-golden', will be available in build *201306050626* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/d09ecf0ecc08
User: Jaroslav Havlin <jhavlin@netbeans.org>
Log: #229250: Randomly failing unittest

Fix an unreliable unittest, that suffers a race condition (swing event
handling, filesystem event delivery and test execution flow). The attached
patch places blocks on the relevant filesystem queues and swing threads.

Patch by Matthias42.
Comment 14 MackSix 2013-06-14 10:34:55 UTC
Verified Fixed:

Product Version: NetBeans IDE Dev (Build 201306132301)
Java: 1.7.0_21; Java HotSpot(TM) 64-Bit Server VM 23.21-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_21-b11
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Comment 15 Jaroslav Havlin 2013-06-24 14:02:55 UTC
After the change, DriverListUtil.getJdbcUrls() returns JDBC URLs in different order (it indirectly caused bug 231526). It seems safe to use lists instead of sets, as collection templateURLs is read-only. (Fixed in core-main #4aca65476d32).
If you find any problem in the fix, please let me know.

> 4. From DriverListutil#getJdbcUrls always return a list of freshly instanced
> JdbcUrls, in which the display name is composited from the driver name and the
> jdbc title.
I've noticed that Driver Name is now doubled, e.g. "Oracle Thin (Service ID (SID)) on Oracle Thin (Service ID (SID))". The Driver name is usually (maybe always) the same as the JDBC title.
Please, what was the intended format of display name? Could you provide an example? Why wasn't the original display name sufficient?

Thank you in advance.
Comment 16 Jaroslav Havlin 2013-06-24 14:11:22 UTC
> Please, what was the intended format of display name? Could you provide an
> example? Why wasn't the original display name sufficient?
I see now that it's useful if you have more versions of a JDBC driver. So the only problem is that the type is is shown twice. I'm going to fix it.
Comment 17 Jaroslav Havlin 2013-06-24 15:31:51 UTC
(In reply to comment #16)
> So the only problem is that the type is is shown twice. I'm going to fix it.
http://hg.netbeans.org/core-main/rev/0774f565cff6
Comment 18 Quality Engineering 2013-06-27 02:16:43 UTC
Integrated into 'main-golden', will be available in build *201306262301* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/0774f565cff6
User: Jaroslav Havlin <jhavlin@netbeans.org>
Log: #229250: Display name of JdbcUrl contains the type information twice