#1999 - Additionally support empty string for read only url with config.isAutoReadOnlyDataSource()

This commit is contained in:
rob bygrave
2020-04-29 22:15:15 +12:00
parent 2a03198393
commit ed0e9e7006
2 changed files with 12 additions and 2 deletions
@@ -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());