Skip to content

Commit

Permalink
Change config loading order to give URLs precedence (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryannedolan authored Feb 11, 2025
1 parent a15f08f commit 9d5dbd6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public Connection connect(String url, Properties props) throws SQLException {

WrappedSchemaPlus wrappedRootSchema = new WrappedSchemaPlus(rootSchema);

// Load properties from url and from getConnection()
// Load properties from the URL and from getConnection()'s properties.
// URL properties take precedence.
Properties properties = new Properties();
properties.putAll(props); // via getConnection()
properties.putAll(ConnectStringParser.parse(url.substring(getConnectStringPrefix().length())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public Connection connect(String url, Properties props) throws SQLException {
return null;
}
Properties properties = new Properties();
properties.putAll(ConnectStringParser.parse(url.substring(getConnectStringPrefix().length())));
properties.putAll(props); // in case the driver is loaded via getConnection()
properties.putAll(ConnectStringParser.parse(url.substring(getConnectStringPrefix().length())));
try {
Connection connection = super.connect(url, props);
if (connection == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public Connection connect(String url, Properties props) throws SQLException {
}
// Connection string properties are given precedence over config properties
Properties properties = new Properties();
properties.putAll(ConnectStringParser.parse(url.substring(getConnectStringPrefix().length())));
properties.putAll(props); // in case the driver is loaded via getConnection()
properties.putAll(ConnectStringParser.parse(url.substring(getConnectStringPrefix().length())));
String cluster = properties.getProperty("cluster");
if (cluster == null) {
throw new IllegalArgumentException("Missing required cluster property. Need: jdbc:venice://cluster=...");
Expand Down

0 comments on commit 9d5dbd6

Please sign in to comment.