Skip to content

Commit 5e3775a

Browse files
committed
HHH-6897 fix for 'registry contains more than one (2) entity manager factories: EMF_BaseEntityManagerFunctionalTestCase' failure
1 parent 40c6177 commit 5e3775a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/BaseEntityManagerFunctionalTestCase.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,13 @@ protected boolean createSchema() {
195195
@After
196196
@SuppressWarnings( {"UnusedDeclaration"})
197197
public void releaseResources() {
198-
releaseUnclosedEntityManagers();
199-
200-
if ( entityManagerFactory != null ) {
201-
entityManagerFactory.close();
198+
try {
199+
releaseUnclosedEntityManagers();
200+
}
201+
finally {
202+
if ( entityManagerFactory != null && entityManagerFactory.isOpen()) {
203+
entityManagerFactory.close();
204+
}
202205
}
203206
// Note we don't destroy the service registry as we are not the ones creating it
204207
}

0 commit comments

Comments
 (0)