fix: return mapped port from MariaDBContainer.getLivenessCheckPortNumbers#11577
Open
PreAgile wants to merge 2 commits intotestcontainers:mainfrom
Open
fix: return mapped port from MariaDBContainer.getLivenessCheckPortNumbers#11577PreAgile wants to merge 2 commits intotestcontainers:mainfrom
PreAgile wants to merge 2 commits intotestcontainers:mainfrom
Conversation
PreAgile
added a commit
to PreAgile/testcontainers-java
that referenced
this pull request
Mar 22, 2026
…ssion - Added PR testcontainers#11577 to active PRs tracking - Updated testcontainers#10359 status from "무주공산" to "PR 제출 완료" - Updated priority list to reflect all 3 PRs now in review - Softened liveness check impact description per review feedback - Added deprecated class test coverage rationale
8c09ded to
d5e9301
Compare
…bers MariaDBContainer.getLivenessCheckPortNumbers() returned the hardcoded internal port (3306) instead of the mapped external port. This was originally fixed for other containers in a prior PR but MariaDB was missed. The new MariaDBContainer class then copied the same buggy implementation. Delegate to super.getLivenessCheckPortNumbers() which correctly maps internal ports to external mapped ports via getMappedPort(). Applied to both: - org.testcontainers.mariadb.MariaDBContainer (current) - org.testcontainers.containers.MariaDBContainer (deprecated)
d5e9301 to
8fa3ee5
Compare
AB-xdev
reviewed
Mar 23, 2026
| @Override | ||
| public Set<Integer> getLivenessCheckPortNumbers() { | ||
| return Sets.newHashSet(MARIADB_PORT); | ||
| return super.getLivenessCheckPortNumbers(); |
Contributor
There was a problem hiding this comment.
I don't see any reason why this override method should exist in the fist place when it's doing exactly the same as it's super counterpart.
Contributor
Author
There was a problem hiding this comment.
Good point!
You're right — since super.getLivenessCheckPortNumbers() already handles the port mapping correctly,
there's no reason to keep this override.
I've removed the method entirely from both classes instead of delegating to super.
Thanks for catching this!
…iaDBContainer The override was simply delegating to super, which is redundant. Removing the method entirely lets the parent class handle port mapping correctly. Also removed the associated test helper since it's no longer needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix
MariaDBContainer.getLivenessCheckPortNumbers()to return the mapped external port instead of the hardcoded internal port.Problem
getLivenessCheckPortNumbers()returnsSets.newHashSet(3306)(the internal container port) instead of the mapped external port. This causesHostPortWaitStrategyand other liveness checks to potentially inspect the wrong port for readiness.Root Cause
This bug was originally fixed for other containers in PR #5734 but MariaDB was missed. The new
MariaDBContainerclass (PR #11083) then copied the same buggy implementation.Fix
Delegate to
super.getLivenessCheckPortNumbers()which correctly maps internal ports to external mapped ports viagetMappedPort().Applied to both:
org.testcontainers.mariadb.MariaDBContainer(current)org.testcontainers.containers.MariaDBContainer(deprecated)Test
Added test verifying
getLivenessCheckPortNumbers()returns the mapped port, following the same pattern used inMySQLContainerTest,PostgreSQLContainerTest, andMSSQLServerContainerTest.Fixes #10359