Skip to content
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 @@ -131,11 +131,6 @@ public Connection connect(
LOGGER.finest(() -> "Use a separate DataSource object to create a connection.");
// use a new data source instance to instantiate a connection
final DataSource ds = createDataSource();
targetDriverDialect.prepareDataSource(
ds,
protocol,
hostSpec,
copy);
conn = this.openConnection(ds, protocol, targetDriverDialect, hostSpec, copy);

} else {
Expand All @@ -145,11 +140,6 @@ public Connection connect(
this.lock.lock();
LOGGER.finest(() -> "Use main DataSource object to create a connection.");
try {
targetDriverDialect.prepareDataSource(
this.dataSource,
protocol,
hostSpec,
copy);
conn = this.openConnection(this.dataSource, protocol, targetDriverDialect, hostSpec, copy);
} finally {
this.lock.unlock();
Expand All @@ -170,11 +160,16 @@ protected Connection openConnection(
final @NonNull HostSpec hostSpec,
final @NonNull Properties props)
throws SQLException {

final boolean enableGreenNodeReplacement = PropertyDefinition.ENABLE_GREEN_NODE_REPLACEMENT.getBoolean(props);
try {
targetDriverDialect.prepareDataSource(
ds,
protocol,
hostSpec,
props);
return ds.getConnection();
} catch (Throwable throwable) {
if (!PropertyDefinition.ENABLE_GREEN_NODE_REPLACEMENT.getBoolean(props)) {
if (!enableGreenNodeReplacement) {
throw throwable;
}

Expand Down