[FIX] some open close corrections

This commit is contained in:
Edouard DUPIN 2024-12-15 23:47:10 +01:00
parent 1713e20252
commit 30ef425d75
4 changed files with 4 additions and 10 deletions

View File

@ -31,6 +31,7 @@ public class DbIoFactory {
}
final DbIo dbIo = createInstance(config);
if (config.getKeepConnected()) {
dbIo.open();
dbIoStored.add(dbIo);
}
dbIo.open();

View File

@ -26,10 +26,6 @@ public class DbIoMorphia extends DbIo implements Closeable {
public DbIoMorphia(final DbConfig config) throws IOException {
super(config);
// If we want to stay connected, we instantiate a basic connection (only force close can remove it).
if (this.config.getKeepConnected()) {
open();
}
}
public Datastore getDatastore() {

View File

@ -15,10 +15,6 @@ public class DbIoSql extends DbIo {
public DbIoSql(final DbConfig config) throws IOException {
super(config);
// If we want to stay connected, we instantiate a basic connection (only force close can remove it).
if (this.config.getKeepConnected()) {
open();
}
}
public Connection getConnection() {

View File

@ -122,14 +122,15 @@ public class ConfigureDb {
da.deleteDB(ConfigBaseVariable.bdDatabase);
} else if ("MONGO".equalsIgnoreCase(modeTest)) {
da.deleteDB(ConfigBaseVariable.bdDatabase);
} else {}
}
}
public static void clear() throws IOException {
LOGGER.info("Remove the test db");
removeDB();
// The connection is by default open ==> close it at the end of test:
da.close();
DbIoFactory.closeAllForceMode();
ConfigBaseVariable.clearAllValue();
da.close();
}
}