Check if database pool was closed before return from cache
@@ -96,7 +96,11 @@ public class OCachedDatabasePoolFactoryImpl implements OCachedDatabasePoolFactor
return pool;
}
- return poolCache.computeIfAbsent(key, hash -> {
+ ODatabasePoolInternal db = poolCache.get(key);
+ if (db != null && !db.isClosed()) {
+ return db;
+ }
+
OrientDBConfig config = OrientDBConfig.builder()
.addConfig(OGlobalConfiguration.DB_POOL_MAX, maxPoolSize)
.build();
@@ -104,9 +108,11 @@ public class OCachedDatabasePoolFactoryImpl implements OCachedDatabasePoolFactor
if (parentConfig != null) {
config.setParent(parentConfig);
}
+ db = new ODatabasePoolImpl(orientDB, database, username, password, config);
+
+ poolCache.put(key, db);
- return new ODatabasePoolImpl(orientDB, database, username, password, config);
- });
+ return db;
}
/**
