mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1999 - Additionally support empty string for read only url with config.isAutoReadOnlyDataSource()
This commit is contained in:
@@ -74,14 +74,22 @@ class InitDataSource {
|
||||
// it has explicitly been set to null, not expected but ok
|
||||
return null;
|
||||
}
|
||||
final String url = roConfig.getUrl();
|
||||
if ("none".equalsIgnoreCase(url) || (url == null && !config.isAutoReadOnlyDataSource())) {
|
||||
final String readOnlyUrl = roConfig.getUrl();
|
||||
if ("none".equalsIgnoreCase(readOnlyUrl) || notAutoReadOnly(readOnlyUrl)) {
|
||||
// no read-only DataSource will be used
|
||||
return null;
|
||||
}
|
||||
return roConfig;
|
||||
}
|
||||
|
||||
private boolean notAutoReadOnly(String readOnlyUrl) {
|
||||
return isEmpty(readOnlyUrl) && !config.isAutoReadOnlyDataSource();
|
||||
}
|
||||
|
||||
private boolean isEmpty(String url) {
|
||||
return url == null || url.trim().isEmpty();
|
||||
}
|
||||
|
||||
private DataSource createFromConfig(DataSourceConfig dsConfig, boolean readOnly) {
|
||||
if (dsConfig == null) {
|
||||
throw new PersistenceException("No DataSourceConfig defined for " + config.getName());
|
||||
|
||||
Reference in New Issue
Block a user