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

JdbcDatabaseContainer. constructUrlForConnection() returning malformed URLs #1976

Closed
mahwy opened this issue Oct 14, 2019 · 4 comments · Fixed by #2049
Closed

JdbcDatabaseContainer. constructUrlForConnection() returning malformed URLs #1976

mahwy opened this issue Oct 14, 2019 · 4 comments · Fixed by #2049

Comments

@mahwy
Copy link

mahwy commented Oct 14, 2019

JdbcDatabaseContainer. constructUrlForConnection() is a simple method that concatenates JDBC URL and a query string starting with ?.

protected String constructUrlForConnection(String queryString) {
return getJdbcUrl() + queryString;
}

But PostgreSQLContainer. getJdbcUrl () returns a JDBC URL with the query string ?loggerLevel=OFF (The change was introduced from this PR: https://github.com/testcontainers/testcontainers-java/pull/1434/files#diff-d62130004eb8d994f60b87f95b1488be)

return "jdbc:postgresql://" + getContainerIpAddress() + ":" + getMappedPort(POSTGRESQL_PORT) + "/" + databaseName + "?loggerLevel=OFF";

This returns invalid URLs for PostgreSQLContainers with custom parameters. For example, given the following URL:
jdbc:tc:fevopostgresql:9.6.11://hostname/databasename?stringtype=unspecified,
the produced connection URL is
jdbc:postgresql://localhost:32793/databasename?loggerLevel=OFF?stringtype=unspecified instead of ...&stringtype=unspecified

@stale
Copy link

stale bot commented Jan 12, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

@stale stale bot added the stale label Jan 12, 2020
@stale
Copy link

stale bot commented Jan 26, 2020

This issue has been automatically closed due to inactivity. We apologise if this is still an active problem for you, and would ask you to re-open the issue if this is the case.

@stale stale bot closed this as completed Jan 26, 2020
@francoiskha
Copy link

Please re-open

@bsideup bsideup reopened this Jan 27, 2020
@stale stale bot removed the stale label Jan 27, 2020
@bsideup bsideup added this to the next milestone Jan 27, 2020
bsideup pushed a commit that referenced this issue Mar 10, 2020
) (#2049)

* Reproduce #1976 in tests

* Override constructUrlForConnection for PostgreSQLContainer

* Lighten PostgreSQLConnectionURLTest

* Lighten PostgreSQLConnectionURLTest

* Cater for base URLs without query strings
@rnorth
Copy link
Member

rnorth commented Apr 13, 2020

This was released in https://github.com/testcontainers/testcontainers-java/releases/tag/1.14.0 🎉

Thanks for the contribution!

quincy pushed a commit to quincy/testcontainers-java that referenced this issue May 28, 2020
…stcontainers#1976) (testcontainers#2049)

* Reproduce testcontainers#1976 in tests

* Override constructUrlForConnection for PostgreSQLContainer

* Lighten PostgreSQLConnectionURLTest

* Lighten PostgreSQLConnectionURLTest

* Cater for base URLs without query strings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants