Details
-
Bug
-
Resolution: Done
-
Minor
-
None
-
None
-
None
-
None
-
NEW
-
NEW
Description
When using timeout in JUnit test as is e.g. here [1], JUnit executes the test method in separate Thread. When handling database transactions in such test incorrectly, they can remain open and can cause various problems, e.g. deadlocks.
Example:
Currently in this test [1] this assert [2] fails. Because the method runs in separate thread, the transaction remains open with some readlocks on ProcessInstanceLog. Because the assert fails, JUnit interrupts the test method Thread and in After method, database connection is disposed so also database is dropped, because of create-drop Hibernate setting. But the table ProcessInstanceLog cannot be dropped, because there is still open transaction with locks on this table from other Thread.
I will make PR for this.
[1] https://github.com/droolsjbpm/jbpm/blob/master/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/TransactionsTest.java#L72
[2] https://github.com/droolsjbpm/jbpm/blob/master/jbpm-test-coverage/src/test/java/org/jbpm/test/functional/TransactionsTest.java#L78