|
|
|
@ -16,6 +16,8 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.testcontainers.lifecycle;
|
|
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.WeakHashMap;
|
|
|
|
|
|
|
|
|
|
import org.testcontainers.lifecycle.Startable;
|
|
|
|
@ -34,12 +36,12 @@ import org.springframework.context.ConfigurableApplicationContext;
|
|
|
|
|
public class TestcontainersLifecycleApplicationContextInitializer
|
|
|
|
|
implements ApplicationContextInitializer<ConfigurableApplicationContext> {
|
|
|
|
|
|
|
|
|
|
private static WeakHashMap<ConfigurableApplicationContext, Boolean> applied = new WeakHashMap<>();
|
|
|
|
|
private static Set<ConfigurableApplicationContext> applied = Collections.newSetFromMap(new WeakHashMap<>());
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void initialize(ConfigurableApplicationContext applicationContext) {
|
|
|
|
|
synchronized (applied) {
|
|
|
|
|
if (applied.put(applicationContext, Boolean.TRUE) == Boolean.TRUE) {
|
|
|
|
|
if (!applied.add(applicationContext)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|