Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.0.x] Skip connection for datasources with omitted db configuration (backport #403) by @hertg #405

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading