[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); final DbIo dbIo = createInstance(config);
if (config.getKeepConnected()) { if (config.getKeepConnected()) {
dbIo.open();
dbIoStored.add(dbIo); dbIoStored.add(dbIo);
} }
dbIo.open(); dbIo.open();

View File

@ -26,10 +26,6 @@ public class DbIoMorphia extends DbIo implements Closeable {
public DbIoMorphia(final DbConfig config) throws IOException { public DbIoMorphia(final DbConfig config) throws IOException {
super(config); 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() { public Datastore getDatastore() {

View File

@ -15,10 +15,6 @@ public class DbIoSql extends DbIo {
public DbIoSql(final DbConfig config) throws IOException { public DbIoSql(final DbConfig config) throws IOException {
super(config); 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() { public Connection getConnection() {

View File

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