Skip to content

Commit 5e62675

Browse files
committed
DATAMONGO-412 - Fixed duplicate invocation of getUserCredentials().
1 parent c805d9c commit 5e62675

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/AbstractMongoConfiguration.java

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2010-2011 the original author or authors.
2+
* Copyright 2011-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@
1818
import java.util.HashSet;
1919
import java.util.Set;
2020

21-
import com.mongodb.Mongo;
2221
import org.springframework.beans.factory.config.BeanDefinition;
2322
import org.springframework.context.annotation.Bean;
2423
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
@@ -35,6 +34,14 @@
3534
import org.springframework.util.ClassUtils;
3635
import org.springframework.util.StringUtils;
3736

37+
import com.mongodb.Mongo;
38+
39+
/**
40+
* Abstract base class to ease JavaConfig setup for Spring Data MongoDB.
41+
*
42+
* @author Mark Pollack
43+
* @author Oliver Gierke
44+
*/
3845
@Configuration
3946
public abstract class AbstractMongoConfiguration {
4047

@@ -50,10 +57,11 @@ public MongoTemplate mongoTemplate() throws Exception {
5057

5158
@Bean
5259
public MongoDbFactory mongoDbFactory() throws Exception {
53-
if (getUserCredentials() == null) {
60+
UserCredentials credentials = getUserCredentials();
61+
if (credentials == null) {
5462
return new SimpleMongoDbFactory(mongo(), getDatabaseName());
5563
} else {
56-
return new SimpleMongoDbFactory(mongo(), getDatabaseName(), getUserCredentials());
64+
return new SimpleMongoDbFactory(mongo(), getDatabaseName(), credentials);
5765
}
5866
}
5967

0 commit comments

Comments
 (0)