From 5df6913f1835af2b6f3dc4157a65709dcafb2026 Mon Sep 17 00:00:00 2001 From: Yanming Zhou Date: Mon, 24 Apr 2023 10:10:28 +0800 Subject: [PATCH] Prevent container to be closed twice See gh-35120 --- .../lifecycle/TestcontainersLifecycleBeanPostProcessor.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/lifecycle/TestcontainersLifecycleBeanPostProcessor.java b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/lifecycle/TestcontainersLifecycleBeanPostProcessor.java index 71f5777319..dab2d53b1c 100644 --- a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/lifecycle/TestcontainersLifecycleBeanPostProcessor.java +++ b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/lifecycle/TestcontainersLifecycleBeanPostProcessor.java @@ -41,9 +41,7 @@ class TestcontainersLifecycleBeanPostProcessor implements DestructionAwareBeanPo @Override public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException { - if (bean instanceof Startable startable) { - startable.stop(); - } + // Startable extends AutoCloseable will always be closed by context } @Override