Skip to content

Commit

Permalink
Merge pull request #405 from playframework/mergify/bp/7.0.x/pr-403
Browse files Browse the repository at this point in the history
[7.0.x] Skip connection for datasources with omitted db configuration (backport #403) by @hertg
  • Loading branch information
mkurz authored Oct 17, 2023
2 parents cbf3fa4 + 7694162 commit d5c5e57
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 d5c5e57

Please sign in to comment.