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.
In the 200604180200 daily run.
Created attachment 29921 [details] Log
I don't understand why this happens, the tests pass on my machine.
The cause of the fail is that the DataObject-s for the JDBCDriver instances are garbage-collected. FolderLookup does not even send resultChanged events for the new drivers unless allInstances() has been called on the result. Even after obtaining a collection containing the newly added drivers by calling allInstances() on the result in the resultChanged() event, it seems the DataObject-s can still be garbage-collected afterwards. When newInstance() is called again, new DataObject-s and new JDBCDriver-s are created, thus this fail. Disabling the failing test and downgrading to P3, since this has no user impact. Checking in cfg-unit.xml; /cvs/db/test/cfg-unit.xml,v <-- cfg-unit.xml new revision: 1.2.22.1; previous revision: 1.2 done
Adding a (failing for now) test to assert that the same instances are retrieved from JDBCDriverManager that were added to it. Checking in cfg-unit.xml; /cvs/db/test/cfg-unit.xml,v <-- cfg-unit.xml new revision: 1.2.22.2; previous revision: 1.2.22.1 done RCS file: /cvs/db/test/unit/src/org/netbeans/api/db/explorer/Attic/JDBCDriverManagerTest.java,v done Checking in unit/src/org/netbeans/api/db/explorer/JDBCDriverManagerTest.java; /cvs/db/test/unit/src/org/netbeans/api/db/explorer/Attic/JDBCDriverManagerTest.java,v <-- JDBCDriverManagerTest.java new revision: 1.1.2.1; previous revision: 1.1 done
Simplifying the test and showing the driver's data object can indeed be GC'd. Checking in test/unit/src/org/netbeans/api/db/explorer/JDBCDriverManagerTest.java; /cvs/db/test/unit/src/org/netbeans/api/db/explorer/Attic/JDBCDriverManagerTest.java,v <-- JDBCDriverManagerTest.java new revision: 1.1.2.2; previous revision: 1.1.2.1 done
Hopefully fixed. Checking in src/org/netbeans/api/db/explorer/JDBCDriverManager.java; /cvs/db/src/org/netbeans/api/db/explorer/JDBCDriverManager.java,v <-- JDBCDriverManager.java new revision: 1.2.22.1; previous revision: 1.2 done Checking in test/cfg-unit.xml; /cvs/db/test/cfg-unit.xml,v <-- cfg-unit.xml new revision: 1.2.22.3; previous revision: 1.2.22.2 done Checking in test/unit/src/org/netbeans/api/db/explorer/JDBCDriverManagerTest.java; /cvs/db/test/unit/src/org/netbeans/api/db/explorer/Attic/JDBCDriverManagerTest.java,v <-- JDBCDriverManagerTest.java new revision: 1.1.2.3; previous revision: 1.1.2.2 done
Happened again.
Created attachment 31699 [details] New log
Still failing randomly on my machine.
When adding the following line to JDBCDriverConvertor System.out.println("Getting environment for DataObject " + System.identityHashCode(obj)); when the test fails this line is printed twice, each time with a different identity hash code. When the test passes it is only printed once.
Making a change that causes the test to fail more often, if not always. Checking in JDBCDriverManagerTest.java; /cvs/db/test/unit/src/org/netbeans/api/db/explorer/JDBCDriverManagerTest.java,v <-- JDBCDriverManagerTest.java new revision: 1.4; previous revision: 1.3 done
Yarda promised to look at it.
BTW the line mentioned in desc11 is added to JDBCDriverConvertor.getEnvironment().
I have rewritten the tests to use core/startup IDE:------------------------------------------------- IDE: [29.8.07 13:20] Committing started Checking in test/unit/src/org/netbeans/api/db/explorer/JDBCDriverManagerTest.java; /shared/data/ccvs/repository/db/test/unit/src/org/netbeans/api/db/explorer/JDBCDriverManagerTest.java,v <-- JDBCDriverManagerTest.java new revision: 1.5; previous revision: 1.4 done Checking in test/unit/src/org/netbeans/api/db/explorer/DatabaseConnectionTest.java; /shared/data/ccvs/repository/db/test/unit/src/org/netbeans/api/db/explorer/DatabaseConnectionTest.java,v <-- DatabaseConnectionTest.java new revision: 1.3; previous revision: 1.2 done Checking in nbproject/project.xml; /shared/data/ccvs/repository/db/nbproject/project.xml,v <-- project.xml new revision: 1.22; previous revision: 1.21 done Checking in test/unit/src/org/netbeans/modules/db/test/TestBase.java; /shared/data/ccvs/repository/db/test/unit/src/org/netbeans/modules/db/test/TestBase.java,v <-- TestBase.java new revision: 1.7; previous revision: 1.6 done Checking in test/unit/src/org/netbeans/modules/db/test/Util.java; /shared/data/ccvs/repository/db/test/unit/src/org/netbeans/modules/db/test/Util.java,v <-- Util.java new revision: 1.3; previous revision: 1.2 done Checking in test/unit/src/org/netbeans/modules/db/explorer/driver/JDBCDriverConvertorTest.java; /shared/data/ccvs/repository/db/test/unit/src/org/netbeans/modules/db/explorer/driver/JDBCDriverConvertorTest.java,v <-- JDBCDriverConvertorTest.java new revision: 1.9; previous revision: 1.8 done Checking in test/unit/src/org/netbeans/modules/db/explorer/DatabaseConnectionConvertorTest.java; /shared/data/ccvs/repository/db/test/unit/src/org/netbeans/modules/db/explorer/DatabaseConnectionConvertorTest.java,v <-- DatabaseConnectionConvertorTest.java new revision: 1.8; previous revision: 1.7 done Checking in src/org/netbeans/modules/db/explorer/driver/JDBCDriverConvertor.java; /shared/data/ccvs/repository/db/src/org/netbeans/modules/db/explorer/driver/JDBCDriverConvertor.java,v <-- JDBCDriverConvertor.java new revision: 1.19; previous revision: 1.18 done IDE: [29.8.07 13:21] Committing finished
Seems it the DataObject of the new driver can still be garbage-collected before someone calls allInstances() on the respective Lookup.Result. Checking in JDBCDriverManagerTest.java; /cvs/db/test/unit/src/org/netbeans/api/db/explorer/JDBCDriverManagerTest.java,v <-- JDBCDriverManagerTest.java new revision: 1.8; previous revision: 1.7 done
Added the same tests for connections too. Checking in test/unit/src/org/netbeans/modules/db/explorer/ConnectionListTest.java; /cvs/db/test/unit/src/org/netbeans/modules/db/explorer/ConnectionListTest.java,v <-- ConnectionListTest.java initial revision: 1.1 done
This doesn't appear to be happening any more. Marking as fixed. Andrei, please reopen if this is still an issue.
JDBCDriverManagerTest just failed on my computer.
When I run this in the debugger, I see two threads running pretty much simultaneously, and it appears they are both creating a DataObject for the JDBCDriver. I put a breakpoint in JDBCDriverConverter.getEnvironment() and I hit it twice. Each time I hit it, I copied the stack trace. I am including both stack traces as attachments. In one case the source is JDBCDriverConverter$AtomicWriter.run() which calls XMLDataObject.getCookie(). In the other case the source is FolderList$ListTask which is running postCreationTask(), which calls defaultProcessObjects->acceptDataObject->XMLDataObject.getCookie(). So what we end up with are two different data objects, one after the other. This causes the JDBCDriverManagerTest to fail at assertSame() because the driver it created is not the same one that ends up being ultimately stored in the FileObject tree. The same thing is happening with the ConnectionListTest. I'm not sure how this is related to garbage collection. I don't quite understand the test, because is does assertGC() which shows that the data object *can* be garbage collected, which would imply to me that it's possible for a new instance to be created and thus assertSame() will fail. Perhaps Andrei can shed some light on this? It doesn't help that I have no idea what getEnvironment() does or how it's used. The FileObject system is still a bit like black magic to me.
I consider failing unit tests a P2.
Created attachment 55100 [details] Stack trace for first thread calling JDBCDriverConverter.getEnvironment()
Created attachment 55101 [details] Second thread calling JDBCDriverConverter.getEnvironment()
I want to add a note that when I tried Thread.dumpStack() in the code, the two stack traces from the two threads overlayed each other in the output. I'm not sure if that's relevant...
It looks like the second thread is called by a task that is run when a property change event is filed on the folder containing the JDBC driver. Further investigation seems to indicate that the DataObject has been changed, but I'm not sure why. One odd other note: the last debug run, the assertGC() failed. Every other time it has passed. I'm a bit flummoxed.
My *suspicion*, although I don't have data to confirm it yet, is the performance improvements being made for 6.1 in the FileSystem code have invalidated the assumption that allInstances() creates strong references to the DataObjects, and so the fix to this bug no longer works.
I talked with Andrei about this. He believes this issue has always been there, but I didn't used to see it when I ran tests, so I think something has changed since 6.0. Our discussion also convinced me that it's a P3 since it's not user-visible and covers a timing edge case. But the issue ultimately is in openide, so I'm moving it over to that component too.
Commented out assertSame() test in ConnectionListTest and JDBCDriverManagerTest. When this is fixed, these lines should be put back in. Hopefully this won't get missed.
moving opened issues from TM <= 6.1 to TM=Dev
Does the test still fails? Do you have some machine where they are executed daily? Thanks.
Hey, Jarda. The test that gets this failure was commented out because it was causing distractions for us and this issue had been on your queue for some time. If you want to see if the test still fails, uncomment the code that was commented out with the label 75204 in db/test/src/org/netbeans/api/db/explorer/JDBCDriverManagerTest.java and db/test/src/org/netbeans/modules/db/explorer/ConnectionListTest.java They still fail for me
Still fails for me
The problem is that although the convertor was trying to recognize the DataObject inside the writer atomic action, the DataObject was not noticed by the recognized thread until the respective file change event was sent. This could cause the DO to be garbage-collected and recognized again by the recognized thread, but that was too late to match the DO with the original instance.
#a0b670a984b7
Integrated into 'main-golden', will be available in build *200809200201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/a0b670a984b7 User: Andrei Badea <abadea@netbeans.org> Log: #75204: Some tests of the db module fail