Skip to content

Commit 0f8211b

Browse files
committed
Support Docker Compose in AOT-processed tests
Keep Docker Compose disabled while AOT processing is in progress, but allow it to initialize when an application or test runs using generated AOT artifacts. Fixes gh-36273 Signed-off-by: goutamadwant <workwithgoutam@gmail.com>
1 parent c1d83d0 commit 0f8211b

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

core/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/lifecycle/DockerComposeLifecycleManager.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.apache.commons.logging.LogFactory;
2727
import org.jspecify.annotations.Nullable;
2828

29-
import org.springframework.aot.AotDetector;
3029
import org.springframework.boot.SpringApplicationShutdownHandlers;
3130
import org.springframework.boot.docker.compose.core.DockerCompose;
3231
import org.springframework.boot.docker.compose.core.DockerComposeFile;
@@ -97,8 +96,8 @@ class DockerComposeLifecycleManager {
9796
}
9897

9998
void start() {
100-
if (Boolean.getBoolean(AbstractAotProcessor.AOT_PROCESSING) || AotDetector.useGeneratedArtifacts()) {
101-
logger.trace("Docker Compose support disabled with AOT and native images");
99+
if (Boolean.getBoolean(AbstractAotProcessor.AOT_PROCESSING)) {
100+
logger.trace("Docker Compose support disabled during AOT processing");
102101
return;
103102
}
104103
if (!this.properties.isEnabled()) {

core/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/lifecycle/DockerComposeLifecycleManagerTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,14 @@ void startWhenAotProcessingDoesNotStart() {
142142
}
143143

144144
@Test
145-
void startWhenUsingAotArtifactsDoesNotStart() {
145+
void startWhenUsingAotArtifactsStarts() {
146146
withSystemProperty(AotDetector.AOT_ENABLED, "true", () -> {
147147
EventCapturingListener listener = new EventCapturingListener();
148148
this.eventListeners.add(listener);
149149
setUpRunningServices();
150150
this.lifecycleManager.start();
151-
assertThat(listener.getEvent()).isNull();
152-
then(this.dockerCompose).should(never()).hasDefinedServices();
151+
assertThat(listener.getEvent()).isNotNull();
152+
then(this.dockerCompose).should().hasDefinedServices();
153153
});
154154
}
155155

0 commit comments

Comments
 (0)