-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Support multiple init scripts in JdbcDatabaseContainer #7680
Conversation
69bdb96
to
1059fb9
Compare
This feature is essential, the PR looks good, I hope it will be accepted as soon as possible, good work. |
Inspired by PRs: testcontainers#2578 and testcontainers#1997 Closes testcontainers#2232
1059fb9
to
a30f8ec
Compare
This is a must-have feature. Could anyone please approve and merge this PR? |
Using |
Thanks for your contribution, @savinov ! |
Looks like this change is breaking for the case when initScriptPath isn't provided. Then initScriptPaths is initialized with one null element, and then application failed when trying to get the resource in ScriptUtils.runInitScript() method. |
Same issue |
@savinov could somebody fix it, please? Thnx in advance :) |
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.
if (initScriptPath != null) { | ||
ScriptUtils.runInitScript(getDatabaseDelegate(), initScriptPath); | ||
} | ||
initScriptPaths.forEach(path -> ScriptUtils.runInitScript(getDatabaseDelegate(), path)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we lost the null point checker here
Inspired by PRs: #2578 and #1997
Closes #2232