mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
FIX: possible resource leaking in testcases (all created transactions are closed by followed try statement) (#1273)
This commit is contained in:
committed by
Rob Bygrave
parent
8e9843ab8a
commit
e3425a8850
@@ -28,10 +28,11 @@ public class TestTransactionCallback extends BaseTestCase {
|
||||
public void test_commitAndRollback() {
|
||||
|
||||
|
||||
Transaction txn = Ebean.beginTransaction();
|
||||
Ebean.register(new MyCallback());
|
||||
txn.getConnection();
|
||||
Ebean.commitTransaction();
|
||||
try (Transaction txn = Ebean.beginTransaction()) {
|
||||
Ebean.register(new MyCallback());
|
||||
txn.getConnection();
|
||||
Ebean.commitTransaction();
|
||||
}
|
||||
|
||||
assertEquals(1, countPreCommit);
|
||||
assertEquals(1, countPostCommit);
|
||||
@@ -39,8 +40,11 @@ public class TestTransactionCallback extends BaseTestCase {
|
||||
assertEquals(0, countPostRollback);
|
||||
|
||||
Ebean.beginTransaction();
|
||||
Ebean.register(new MyCallback());
|
||||
Ebean.rollbackTransaction();
|
||||
try {
|
||||
Ebean.register(new MyCallback());
|
||||
} finally {
|
||||
Ebean.rollbackTransaction();
|
||||
}
|
||||
|
||||
assertEquals(1, countPreCommit);
|
||||
assertEquals(1, countPostCommit);
|
||||
|
||||
Reference in New Issue
Block a user