[Bug]: Underlying NullPointerException in ContainerLessJdbcDelegate when using ScriptUtils
Maintainers usually reply within 1 day
@snehal242005 is already working on this.
Since Jul 11, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 52/100
Research direction
Start with org.testcontainers.jdbc.JdbcDatabaseDelegate#closeConnectionQuietly and inspect ContainerLessJdbcDelegate's connection field, then trace the ScriptUtils.runInitScript call shown in the report. Add regression coverage for running a script with ContainerLessJdbcDelegate and verify it completes without a NullPointerException while closing the correct connection.
Written by the indexing model from the issue text.
Description
Module
Core
Testcontainers version
1.21.4
Using the latest Testcontainers version?
Yes
Host OS
Windows
Host Arch
x64
Docker version
Client:
Version: 29.0.2-rd
API version: 1.51 (downgraded from 1.52)
Go version: go1.25.4
Git commit: 5a2d7eb
Built: Tue Nov 18 23:34:16 2025
OS/Arch: windows/amd64
Context: default
Server:
Engine:
Version: 28.3.3
API version: 1.51 (minimum version 1.24)
Go version: go1.24.8
Git commit: bea959c7b793b32a893820b97c4eadc7c87fabb0
Built: Sun Oct 12 08:01:14 2025
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v2.1.5
GitCommit: fcd43222d6b07379a4be9786bda52438f0dd16a1
runc:
Version: 1.3.3
GitCommit: d842d7719497cc3b774fd71620278ac9e17710e0
docker-init:
Version: 0.19.0
GitCommit:
What happened?
Hi,
When running a script with ScriptUtils on ContainerLessJdbcDelegate an underlying NullPointerException occurs.
ScriptUtils.runInitScript( new ContainerLessJdbcDelegate( connection ), initScript );
Reason is the code in org.testcontainers.jdbc.JdbcDatabaseDelegate#closeConnectionQuietly. It closes the connection which is null, as the ContainerLessJdbcDelegate has an own connection field. This could probably be solved by implementing closeConnectionQuietly in ContainerLessJdbcDelegate and closing the own field instead of the one on the super class.
Thank you and best regards
Nils
Relevant log output
2026-03-12 08:28:11 ERROR [main ] o.t.j.JdbcDatabaseDelegate - Could not close JDBC connection
java.lang.NullPointerException: Cannot invoke "java.sql.Connection.close()" because "this.connection" is null
at org.testcontainers.jdbc.JdbcDatabaseDelegate.closeConnectionQuietly(JdbcDatabaseDelegate.java:72)
at org.testcontainers.jdbc.JdbcDatabaseDelegate.closeConnectionQuietly(JdbcDatabaseDelegate.java:16)
at org.testcontainers.delegate.AbstractDatabaseDelegate.close(AbstractDatabaseDelegate.java:45)
at org.testcontainers.ext.ScriptUtils.executeDatabaseScript(ScriptUtils.java:308)
at org.testcontainers.ext.ScriptUtils.executeDatabaseScript(ScriptUtils.java:225)
at org.testcontainers.ext.ScriptUtils.runInitScript(ScriptUtils.java:213)
Additional Information
No response
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 2k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 11
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from testcontainers/testcontainers-java
-
[Bug]: WaitStrategyTarget Handles Multiple Ports Differently to DocumentationPossibly taken @suvvvv claimed this 2 days ago. Opentype/bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
testcontainers/testcontainers-java#12196 ·
Maintainers usually reply within 1 day
-
[Bug]: DockerImageName treats uppercase registry names as repository pathsPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
testcontainers/testcontainers-java#12186 · 1 comment ·
Maintainers usually reply within 1 day
-
[Bug]: withStartupTimeout() changes the startup timeout of all containers that use the default wait strategyPossibly taken @aymenjamaaoui claimed this 18 days ago. Opentype/bug
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
testcontainers/testcontainers-java#12171 · 1 comment ·
Maintainers usually reply within 1 day
-
[Enhancement]: Document why singleton containers are required under Spring's test context cachingPossibly taken @zakaullah075 claimed this 111 days ago. Opentype/enhancement
Difficulty 1/5 Under an hour Newbie friendliness 85/100
testcontainers/testcontainers-java#11967 · 1 comment ·
Maintainers usually reply within 1 day
-
[Bug]: Cannot reuse Selenium BrowserWebDriverContainers under LinuxPossibly taken @kdelay claimed this 132 days ago. Opentype/bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
testcontainers/testcontainers-java#11941 ·
Maintainers usually reply within 1 day
All issues in testcontainers/testcontainers-java
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
erkamyaman/rust-anything#1381 ·
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
java-native-access/jna#1757 ·