Skip to content

Commit 9d71be8

Browse files
committed
Use HTTPS for embedded MongoDB downloads by default
Closes gh-17191
1 parent be077d7 commit 9d71be8

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
import de.flapdoodle.embed.mongo.distribution.IFeatureAwareVersion;
4040
import de.flapdoodle.embed.process.config.IRuntimeConfig;
4141
import de.flapdoodle.embed.process.config.io.ProcessOutput;
42+
import de.flapdoodle.embed.process.config.store.IDownloadPath;
43+
import de.flapdoodle.embed.process.distribution.Distribution;
44+
import de.flapdoodle.embed.process.distribution.Platform;
4245
import de.flapdoodle.embed.process.io.Processors;
4346
import de.flapdoodle.embed.process.io.Slf4jLevel;
4447
import de.flapdoodle.embed.process.io.progress.Slf4jProgressListener;
@@ -190,8 +193,9 @@ public IRuntimeConfig embeddedMongoRuntimeConfig() {
190193
}
191194

192195
private ArtifactStoreBuilder getArtifactStore(Logger logger) {
193-
return new ExtractedArtifactStoreBuilder().defaults(Command.MongoD).download(new DownloadConfigBuilder()
194-
.defaultsForCommand(Command.MongoD).progressListener(new Slf4jProgressListener(logger)).build());
196+
return new ExtractedArtifactStoreBuilder().defaults(Command.MongoD)
197+
.download(new HttpsDownloadConfigBuilder().defaultsForCommand(Command.MongoD)
198+
.progressListener(new Slf4jProgressListener(logger)).build());
195199
}
196200

197201
}
@@ -270,4 +274,27 @@ public String toString() {
270274

271275
}
272276

277+
private static class HttpsDownloadConfigBuilder extends DownloadConfigBuilder {
278+
279+
@Override
280+
public DownloadConfigBuilder defaultsForCommand(Command command) {
281+
super.defaultsForCommand(command);
282+
downloadPath().setDefault(new PlatformDependentHttpsDownloadPath());
283+
return this;
284+
}
285+
286+
private static class PlatformDependentHttpsDownloadPath implements IDownloadPath {
287+
288+
@Override
289+
public String getPath(Distribution distribution) {
290+
if (distribution.getPlatform() == Platform.Windows) {
291+
return "https://downloads.mongodb.org/";
292+
}
293+
return "https://fastdl.mongodb.org/";
294+
}
295+
296+
}
297+
298+
}
299+
273300
}

0 commit comments

Comments
 (0)