Skip to content

fix ContainerFactory #36574

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

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.28.17
version=0.28.18
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ class LoggingInvocationInterceptor : InvocationInterceptor {
if (timeoutTask.wasTriggered) {
t1 =
TimeoutException(
"Execution was cancelled after %s. If you think your test should be given more time to complete, you can use the @Timeout annotation. If all the test of a connector are slow, " +
" you can override the property 'JunitMethodExecutionTimeout' in your gradle.properties.".formatted(
("Execution was cancelled after %s. If you think your test should be given more time to complete, you can use the @Timeout annotation. If all the test of a connector are slow, " +
" you can override the property 'JunitMethodExecutionTimeout' in your gradle.properties.")
.formatted(
DurationFormatUtils.formatDurationWords(elapsedMs, true, true)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import org.testcontainers.utility.DockerImageName
abstract class ContainerFactory<C : GenericContainer<*>> {
@JvmRecord
private data class ContainerKey<C : GenericContainer<*>>(
val clazz: Class<out ContainerFactory<*>?>?,
val imageName: DockerImageName?,
val methods: MutableList<out NamedContainerModifier<C>>
val clazz: Class<out ContainerFactory<*>>,
val imageName: DockerImageName,
val methods: kotlin.collections.List<String>
)

private class ContainerOrException(
Expand Down Expand Up @@ -90,7 +90,6 @@ abstract class ContainerFactory<C : GenericContainer<*>> {
*
* @Deprecated use shared(String, NamedContainerModifier) instead
*/
@Deprecated("")
fun shared(imageName: String, vararg methods: String): C {
return shared(
imageName,
Expand All @@ -110,7 +109,11 @@ abstract class ContainerFactory<C : GenericContainer<*>> {
namedContainerModifiers: MutableList<out NamedContainerModifier<C>> = ArrayList()
): C {
val containerKey =
ContainerKey<C>(javaClass, DockerImageName.parse(imageName), namedContainerModifiers)
ContainerKey<C>(
javaClass,
DockerImageName.parse(imageName),
namedContainerModifiers.map { it.name() }.toList()
)
// We deliberately avoid creating the container itself eagerly during the evaluation of the
// map
// value.
Expand All @@ -119,7 +122,7 @@ abstract class ContainerFactory<C : GenericContainer<*>> {
val containerOrError =
SHARED_CONTAINERS!!.computeIfAbsent(containerKey) { key: ContainerKey<*>? ->
ContainerOrException {
createAndStartContainer(key!!.imageName, (key as ContainerKey<C>)!!.methods)
createAndStartContainer(key!!.imageName, namedContainerModifiers)
}
}
// Instead, the container creation (if applicable) is deferred to here.
Expand All @@ -131,7 +134,6 @@ abstract class ContainerFactory<C : GenericContainer<*>> {
*
* @Deprecated use exclusive(String, NamedContainerModifier) instead
*/
@Deprecated("")
fun exclusive(imageName: String, vararg methods: String): C {
return exclusive(
imageName,
Expand Down