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 2702081611..4cc10f460f 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 @@ -19,10 +19,8 @@ package org.springframework.boot.autoconfigure.mongo.embedded; import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; -import java.util.Collections; import java.util.HashMap; import java.util.Map; -import java.util.Set; import com.mongodb.MongoClient; import de.flapdoodle.embed.mongo.Command; @@ -37,8 +35,10 @@ import de.flapdoodle.embed.mongo.config.RuntimeConfigBuilder; 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.Versions; import de.flapdoodle.embed.process.config.IRuntimeConfig; import de.flapdoodle.embed.process.config.io.ProcessOutput; +import de.flapdoodle.embed.process.distribution.GenericVersion; import de.flapdoodle.embed.process.io.Processors; import de.flapdoodle.embed.process.io.Slf4jLevel; import de.flapdoodle.embed.process.io.progress.Slf4jProgressListener; @@ -65,7 +65,6 @@ import org.springframework.core.env.MutablePropertySources; import org.springframework.core.env.PropertySource; import org.springframework.data.mongodb.core.MongoClientFactoryBean; import org.springframework.data.mongodb.core.ReactiveMongoClientFactoryBean; -import org.springframework.util.Assert; /** * {@link EnableAutoConfiguration Auto-configuration} for Embedded Mongo. @@ -126,9 +125,9 @@ public class EmbeddedMongoAutoConfiguration { @Bean @ConditionalOnMissingBean public IMongodConfig embeddedMongoConfiguration() throws IOException { - IFeatureAwareVersion featureAwareVersion = new ToStringFriendlyFeatureAwareVersion( - this.embeddedProperties.getVersion(), - this.embeddedProperties.getFeatures()); + IFeatureAwareVersion featureAwareVersion = Versions.withFeatures( + new GenericVersion(this.embeddedProperties.getVersion()), + this.embeddedProperties.getFeatures().toArray(new Feature[0])); MongodConfigBuilder builder = new MongodConfigBuilder() .version(featureAwareVersion); if (this.embeddedProperties.getStorage() != null) { @@ -242,66 +241,4 @@ public class EmbeddedMongoAutoConfiguration { } - /** - * A workaround for the lack of a {@code toString} implementation on - * {@code GenericFeatureAwareVersion}. - */ - private static final class ToStringFriendlyFeatureAwareVersion - implements IFeatureAwareVersion { - - private final String version; - - private final Set features; - - private ToStringFriendlyFeatureAwareVersion(String version, - Set features) { - Assert.notNull(version, "version must not be null"); - this.version = version; - this.features = (features != null ? features : Collections.emptySet()); - } - - @Override - public String asInDownloadPath() { - return this.version; - } - - @Override - public boolean enabled(Feature feature) { - return this.features.contains(feature); - } - - @Override - public String toString() { - return this.version; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + this.features.hashCode(); - result = prime * result + this.version.hashCode(); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() == obj.getClass()) { - ToStringFriendlyFeatureAwareVersion other = (ToStringFriendlyFeatureAwareVersion) obj; - boolean equals = true; - equals = equals && this.features.equals(other.features); - equals = equals && this.version.equals(other.version); - return equals; - } - return super.equals(obj); - } - - } - } diff --git a/spring-boot-project/spring-boot-dependencies/pom.xml b/spring-boot-project/spring-boot-dependencies/pom.xml index 5d551bff52..f3f9cfaa9f 100644 --- a/spring-boot-project/spring-boot-dependencies/pom.xml +++ b/spring-boot-project/spring-boot-dependencies/pom.xml @@ -57,7 +57,7 @@ 3.2.6 2.10.5 3.5.2 - 2.0.3 + 2.1.1 5.0.7 2.3.28 6.2.4