Skip to content

Commit

Permalink
Skip ServerConfig creation for datasources missing db config, closes #…
Browse files Browse the repository at this point in the history
…402

(cherry picked from commit 443b970)
  • Loading branch information
hertg authored and mergify[bot] committed Oct 17, 2023
1 parent 08bdb06 commit 7694162
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.reflections.util.ConfigurationBuilder;
import org.reflections.util.FilterBuilder;
import play.Environment;
import play.Logger;
import play.db.DBApi;

/** Ebean server configuration. */
Expand Down Expand Up @@ -49,6 +50,8 @@ public static class EbeanConfigParser implements Provider<EbeanConfig> {
private final Environment environment;
private final DBApi dbApi;

private static final Logger.ALogger LOGGER = Logger.of(DefaultEbeanConfig.class);

@Inject
public EbeanConfigParser(Config config, Environment environment, DBApi dbApi) {
this.config = config;
Expand All @@ -75,6 +78,12 @@ public EbeanConfig parse() {
for (Map.Entry<String, List<String>> entry : ebeanConfig.getDatasourceModels().entrySet()) {
String key = entry.getKey();

if (dbApi.getDatabase(key) == null) {
LOGGER.debug("There is an 'ebean.{}' but no 'db.{}' configuration", key, key);
LOGGER.info("Skipping connection for datasource '{}'", key);
continue;
}

DatabaseConfig serverConfig = new DatabaseConfig();
serverConfig.setName(key);
serverConfig.loadFromProperties();
Expand Down

0 comments on commit 7694162

Please sign in to comment.