mirror of https://github.com/apache/openjpa.git
make sure tests cleanup EMs and EMFs
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1021802 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2f648350b4
commit
58d1f4966a
|
@ -76,10 +76,18 @@ public abstract class AbstractCachedEMFTestCase extends AbstractPersistenceTestC
|
|||
@Override
|
||||
protected boolean removeEldestEntry(Map.Entry<K,V> entry) {
|
||||
OpenJPAEntityManagerFactorySPI oemf = (OpenJPAEntityManagerFactorySPI)entry.getValue();
|
||||
// if (oemf != null && oemf.isOpen()) {
|
||||
// oemf.close();
|
||||
// }
|
||||
return this.size() > 2;
|
||||
if (this.size() > 2) {
|
||||
// if the eldest should be removed, then try to close it first
|
||||
if (oemf != null && oemf.isOpen()) {
|
||||
try {
|
||||
oemf.close();
|
||||
} catch (Exception e) {
|
||||
// no-op - eat it
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ public abstract class SingleEMFTestCase
|
|||
throw e;
|
||||
} finally {
|
||||
closeEMF(emf);
|
||||
emf = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue