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

Handle drivers which don't support URL-encoding (1.x) #240

Merged

Conversation

spikymonkey
Copy link
Contributor

1.2.6 introduced a change to URL-encode credentials in JDBC connection
strings by default. This was to prevent special characters from
interfering with connections, but unfortunately some drivers can't
handle the encoding. Also in some clouds, the JDBC URL is passed to us
in URL encoded form. Again, in the case where the driver is unable to
URL-decode the URL itself, this causes connection failures.

This commit introduces UrlDecodingDataSource, which is returned in all
cases by whichever DataSourceCreator is in play.
UrlDecodingDataSource transparently delegates to an underlying
DataSource, except in the case where a connection attempt is made and
no previous connection attempt has been successful. In this case, if the
connection attempt with the configured JDBC URL fails, a test connection
is attempted using a URL-decoded version of the JDBC URL. If this is
successful, the underlying DataSource is updated with the decoded JDBC
URL and used to provide a final connection, which is returned to the
client.

Fixes gh-237 for the 1.x branch

1.2.6 introduced a change to URL-encode credentials in JDBC connection
strings by default. This was to prevent special characters from
interfering with connections, but unfortunately some drivers can't
handle the encoding. Also in some clouds, the JDBC URL is passed to us
in URL encoded form. Again, in the case where the driver is unable to
URL-decode the URL itself, this causes connection failures.

This commit introduces `UrlDecodingDataSource`, which is returned in all
cases by whichever `DataSourceCreator` is in play.
`UrlDecodingDataSource` transparently delegates to an underlying
`DataSource`, except in the case where a connection attempt is made and
no previous connection attempt has been successful. In this case, if the
connection attempt with the configured JDBC URL fails, a test connection
is attempted using a URL-decoded version of the JDBC URL. If this is
successful, the underlying `DataSource` is updated with the decoded JDBC
URL and used to provide a final connection, which is returned to the
client.

Fixes spring-cloudgh-237
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants