mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Polish
This commit is contained in:
parent
d86e82d026
commit
3997771f6c
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user