Merge branch '3.1.x'

Closes gh-37194
pull/37196/head
Moritz Halbritter 1 year ago
commit 313627934e

@ -56,7 +56,7 @@ public final class ContainerConnectionSource<C extends Container<?>> implements
private final Set<Class<?>> connectionDetailsTypes;
private Supplier<C> containerSupplier;
private final Supplier<C> containerSupplier;
ContainerConnectionSource(String beanNameSuffix, Origin origin, Class<C> containerType, String containerImageName,
MergedAnnotation<ServiceConnection> annotation, Supplier<C> containerSupplier) {

@ -74,8 +74,12 @@ class ServiceConnectionContextCustomizerFactory implements ContextCustomizerFact
field.getDeclaringClass().getName(), Container.class.getName()));
Class<C> containerType = (Class<C>) fieldValue.getClass();
C container = (C) fieldValue;
return new ContainerConnectionSource<>("test", origin, containerType, container.getDockerImageName(),
annotation, () -> container);
// container.getDockerImageName() fails if there is no running docker environment
// When running tests that doesn't matter, but running AOT processing should be
// possible without a Docker environment
String dockerImageName = isAotProcessingInProgress() ? null : container.getDockerImageName();
return new ContainerConnectionSource<>("test", origin, containerType, dockerImageName, annotation,
() -> container);
}
private Object getFieldValue(Field field) {
@ -83,4 +87,8 @@ class ServiceConnectionContextCustomizerFactory implements ContextCustomizerFact
return ReflectionUtils.getField(field, null);
}
private boolean isAotProcessingInProgress() {
return Boolean.getBoolean("spring.aot.processing");
}
}

Loading…
Cancel
Save