Polish "Prevent container to be closed twice"

See gh-35120
This commit is contained in:
Stephane Nicoll
2023-04-24 15:38:12 +02:00
parent 5df6913f18
commit facf48e423
3 changed files with 63 additions and 14 deletions

View File

@@ -23,7 +23,7 @@ import org.springframework.context.ConfigurableApplicationContext;
/**
* {@link ApplicationContextInitializer} to manage the lifecycle of {@link Startable
* startable container}.
* startable containers}.
*
* @author Phillip Webb
* @since 3.1.0

View File

@@ -20,16 +20,16 @@ import org.testcontainers.lifecycle.Startable;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
/**
* {@link BeanPostProcessor} to manage the lifecycle of {@link Startable startable
* container}.
* containers}.
*
* @author Phillip Webb
* @author Stephane Nicoll
* @see TestcontainersLifecycleApplicationContextInitializer
*/
class TestcontainersLifecycleBeanPostProcessor implements DestructionAwareBeanPostProcessor {
class TestcontainersLifecycleBeanPostProcessor implements BeanPostProcessor {
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
@@ -39,14 +39,4 @@ class TestcontainersLifecycleBeanPostProcessor implements DestructionAwareBeanPo
return bean;
}
@Override
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException {
// Startable extends AutoCloseable will always be closed by context
}
@Override
public boolean requiresDestruction(Object bean) {
return bean instanceof Startable;
}
}