From 750246f02154b32abb8faff54efa8a4fc38305ae Mon Sep 17 00:00:00 2001 From: Eugene Date: Sun, 13 Jan 2019 00:44:28 +0200 Subject: [PATCH 1/2] Fix stopping of Embedded Mongo before context is closed See gh-15692 --- .../mongo/embedded/EmbeddedMongoAutoConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java index afc8d0f4ed..5af8835c1c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java @@ -212,7 +212,7 @@ public class EmbeddedMongoAutoConfiguration { "[console>]", Processors.logTo(logger, Slf4jLevel.DEBUG))); return new RuntimeConfigBuilder().defaultsWithLogger(Command.MongoD, logger) .processOutput(processOutput).artifactStore(getArtifactStore(logger)) - .build(); + .daemonProcess(false).build(); } private ArtifactStoreBuilder getArtifactStore(Logger logger) { From 20f26c4d30160514bace8e394a9b87e41082341a Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 11 Feb 2019 17:34:40 +0000 Subject: [PATCH 2/2] Polish "Fix stopping of Embedded Mongo before context is closed" See gh-15692 --- .../mongo/embedded/EmbeddedMongoAutoConfiguration.java | 2 +- .../embedded/EmbeddedMongoAutoConfigurationTests.java | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java index 5af8835c1c..df7e6fbdfb 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfigurationTests.java index bfe0e8855b..e3c07ebc9e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import java.util.EnumSet; import java.util.stream.Collectors; import com.mongodb.MongoClient; +import de.flapdoodle.embed.mongo.MongodExecutable; import de.flapdoodle.embed.mongo.config.IMongodConfig; import de.flapdoodle.embed.mongo.config.Storage; import de.flapdoodle.embed.mongo.distribution.Feature; @@ -174,6 +175,13 @@ public class EmbeddedMongoAutoConfigurationTests { .isEqualTo("testing"); } + @Test + public void shutdownHookIsNotRegistered() { + load(); + assertThat(this.context.getBean(MongodExecutable.class).isRegisteredJobKiller()) + .isFalse(); + } + private void assertVersionConfiguration(String configuredVersion, String expectedVersion) { this.context = new AnnotationConfigApplicationContext();