Upgrade to Embedded Mongo 3.4.2

As part of the upgrade, the property for configuring features has
been removed as support for feature-aware versions has been removed
from Embedded Mongo. For advanced configuration where features were
specified, users should provide a MongodConfig bean instead.

Closes gh-29985
Closes gh-30219
pull/30406/head
Andy Wilkinson 3 years ago
parent a8c44221ec
commit 2282f9cc88

@ -24,7 +24,6 @@ import java.util.Map;
import java.util.stream.Stream;
import com.mongodb.MongoClientSettings;
import de.flapdoodle.embed.mongo.Command;
import de.flapdoodle.embed.mongo.MongodExecutable;
import de.flapdoodle.embed.mongo.MongodStarter;
import de.flapdoodle.embed.mongo.config.Defaults;
@ -32,10 +31,10 @@ import de.flapdoodle.embed.mongo.config.ImmutableMongodConfig;
import de.flapdoodle.embed.mongo.config.MongodConfig;
import de.flapdoodle.embed.mongo.config.Net;
import de.flapdoodle.embed.mongo.config.Storage;
import de.flapdoodle.embed.mongo.distribution.Feature;
import de.flapdoodle.embed.mongo.distribution.IFeatureAwareVersion;
import de.flapdoodle.embed.mongo.distribution.Version;
import de.flapdoodle.embed.mongo.distribution.Versions;
import de.flapdoodle.embed.mongo.packageresolver.Command;
import de.flapdoodle.embed.process.config.RuntimeConfig;
import de.flapdoodle.embed.process.config.process.ProcessOutput;
import de.flapdoodle.embed.process.config.store.DownloadConfig;
@ -146,16 +145,12 @@ public class EmbeddedMongoAutoConfiguration {
private IFeatureAwareVersion determineVersion(EmbeddedMongoProperties embeddedProperties) {
Assert.state(embeddedProperties.getVersion() != null, "Set the spring.mongodb.embedded.version property or "
+ "define your own MongodConfig bean to use embedded MongoDB");
if (embeddedProperties.getFeatures() == null) {
for (Version version : Version.values()) {
if (version.asInDownloadPath().equals(embeddedProperties.getVersion())) {
return version;
}
for (Version version : Version.values()) {
if (version.asInDownloadPath().equals(embeddedProperties.getVersion())) {
return version;
}
return Versions.withFeatures(createEmbeddedMongoVersion(embeddedProperties));
}
return Versions.withFeatures(createEmbeddedMongoVersion(embeddedProperties),
embeddedProperties.getFeatures().toArray(new Feature[0]));
return Versions.withFeatures(createEmbeddedMongoVersion(embeddedProperties));
}
private GenericVersion createEmbeddedMongoVersion(EmbeddedMongoProperties embeddedProperties) {

@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 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.
@ -16,10 +16,6 @@
package org.springframework.boot.autoconfigure.mongo.embedded;
import java.util.Set;
import de.flapdoodle.embed.mongo.distribution.Feature;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.convert.DataSizeUnit;
import org.springframework.util.unit.DataSize;
@ -43,12 +39,6 @@ public class EmbeddedMongoProperties {
private final Storage storage = new Storage();
/**
* Comma-separated list of features to enable. Uses the defaults of the configured
* version by default.
*/
private Set<Feature> features = null;
public String getVersion() {
return this.version;
}
@ -57,14 +47,6 @@ public class EmbeddedMongoProperties {
this.version = version;
}
public Set<Feature> getFeatures() {
return this.features;
}
public void setFeatures(Set<Feature> features) {
this.features = features;
}
public Storage getStorage() {
return this.storage;
}

@ -1618,9 +1618,10 @@
},
{
"name": "spring.mongodb.embedded.features",
"defaultValue": [
"sync_delay"
]
"deprecation": {
"level": "error",
"reason": "Feature support has been removed from Embedded Mongo. A custom MongodConfig bean should be defined instead."
}
},
{
"name": "spring.mustache.prefix",

@ -18,9 +18,7 @@ package org.springframework.boot.autoconfigure.mongo.embedded;
import java.io.File;
import java.nio.file.Path;
import java.util.EnumSet;
import java.util.Map;
import java.util.stream.Collectors;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
@ -28,7 +26,6 @@ import de.flapdoodle.embed.mongo.MongodExecutable;
import de.flapdoodle.embed.mongo.MongodStarter;
import de.flapdoodle.embed.mongo.config.MongodConfig;
import de.flapdoodle.embed.mongo.config.Storage;
import de.flapdoodle.embed.mongo.distribution.Feature;
import de.flapdoodle.embed.mongo.distribution.Version;
import de.flapdoodle.embed.process.config.RuntimeConfig;
import de.flapdoodle.embed.process.config.store.DownloadConfig;
@ -101,15 +98,6 @@ class EmbeddedMongoAutoConfigurationTests {
assertVersionConfiguration("3.4.1", "3.4.1");
}
@Test
void customFeatures() {
EnumSet<Feature> features = EnumSet.of(Feature.TEXT_SEARCH, Feature.SYNC_DELAY, Feature.NO_HTTP_INTERFACE_ARG);
loadWithValidVersion("spring.mongodb.embedded.features="
+ features.stream().map(Feature::name).collect(Collectors.joining(", ")));
assertThat(this.context.getBean(EmbeddedMongoProperties.class).getFeatures())
.containsExactlyElementsOf(features);
}
@Test
void useRandomPortByDefault() {
loadWithValidVersion();

@ -310,7 +310,7 @@ bom {
]
}
}
library("Embedded Mongo", "3.3.1") {
library("Embedded Mongo", "3.4.2") {
group("de.flapdoodle.embed") {
modules = [
"de.flapdoodle.embed.mongo"

Loading…
Cancel
Save