[nobug] properly close EMs in tests
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EntityManagerJUnitTestSuite.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EntityManagerJUnitTestSuite.java
index ef9f262..ddf681b 100644
--- a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EntityManagerJUnitTestSuite.java
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/EntityManagerJUnitTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2017 Oracle and/or its affiliates, IBM Corporation. All rights reserved.
+ * Copyright (c) 1998, 2018 Oracle and/or its affiliates, IBM Corporation. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -4911,8 +4911,9 @@
if (isTransactionActive(em)){
rollbackTransaction(em);
}
- closeEntityManager(em);
throw ex;
+ } finally {
+ closeEntityManager(em);
}
beginTransaction(em);
try{
@@ -4923,8 +4924,9 @@
if (isTransactionActive(em)){
rollbackTransaction(em);
}
- closeEntityManager(em);
throw ex;
+ } finally {
+ closeEntityManager(em);
}
if (optimisticLockException == null){
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/InvalidNamedQueryTest.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/InvalidNamedQueryTest.java
index db22f2c..2eaf08b 100644
--- a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/InvalidNamedQueryTest.java
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/InvalidNamedQueryTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014, 2015 IBM Corporation. All rights reserved.
+ * Copyright (c) 2014, 2018 IBM Corporation. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -43,6 +43,8 @@
fail("Shouldn't have got here!");
} catch (PersistenceException re) {
// expected
+ } finally {
+ closeEntityManagerFactory();
}
}
@@ -58,6 +60,7 @@
if (em != null) {
em.close();
}
+ closeEntityManagerFactory();
}
}
@@ -75,6 +78,7 @@
if (em != null) {
em.close();
}
+ closeEntityManagerFactory();
}
}
@@ -105,6 +109,7 @@
if (em != null) {
em.close();
}
+ closeEntityManagerFactory();
}
}
}