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

Fix missing null check for JDBC init script #9118

Merged
merged 3 commits into from
Aug 20, 2024

Conversation

mmorshedi
Copy link
Contributor

In PR #7680, a new feature was introduced to support multiple init scripts in JdbcDatabaseContainer. However, during this update, a critical null check was inadvertently removed from the JdbcDatabaseContainer.runInitScriptIfRequired method. This check was responsible for ignoring null values for the initScript parameter.

As a result, when no init script is defined, a null value is passed to ScriptUtils.runInitScript, leading to an exception being thrown and preventing the database container from starting.

This commit reinstates the missing null check, ensuring that undefined init scripts are properly handled. Additionally, a test has been added to verify that the issue is resolved and the database container can start without an init script.

In PR testcontainers#7680, a new feature was introduced to support multiple init scripts in JdbcDatabaseContainer. However, during this update, a critical null check was inadvertently removed from the `JdbcDatabaseContainer.runInitScriptIfRequired` method. This check was responsible for ignoring null values for the `initScript` parameter.

As a result, when no init script is defined, a null value is passed to `ScriptUtils.runInitScript`, leading to an exception being thrown and preventing the database container from starting.

This commit reinstates the missing null check, ensuring that undefined init scripts are properly handled. Additionally, a test has been added to verify that the issue is resolved and the database container can start without an init script.
@mmorshedi
Copy link
Contributor Author

@eddumelendez Could you please review this fix for a breaking change?

@eddumelendez eddumelendez added this to the next milestone Aug 19, 2024
@eddumelendez eddumelendez merged commit 251bca5 into testcontainers:main Aug 20, 2024
104 checks passed
@eddumelendez
Copy link
Member

Thanks for your contribution, @mmorshedi!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants