diff --git a/pom.xml b/pom.xml
index 75fa63795e..3eba098a18 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springframework.data
spring-data-mongodb-parent
- 1.11.0.BUILD-SNAPSHOT
+ 1.11.0.DATAMONGO-1620-SNAPSHOT
pom
Spring Data MongoDB
diff --git a/spring-data-mongodb-cross-store/pom.xml b/spring-data-mongodb-cross-store/pom.xml
index dc5a04a7ad..10a0ad925d 100644
--- a/spring-data-mongodb-cross-store/pom.xml
+++ b/spring-data-mongodb-cross-store/pom.xml
@@ -6,7 +6,7 @@
org.springframework.data
spring-data-mongodb-parent
- 1.11.0.BUILD-SNAPSHOT
+ 1.11.0.DATAMONGO-1620-SNAPSHOT
../pom.xml
@@ -48,7 +48,7 @@
org.springframework.data
spring-data-mongodb
- 1.11.0.BUILD-SNAPSHOT
+ 1.11.0.DATAMONGO-1620-SNAPSHOT
diff --git a/spring-data-mongodb-distribution/pom.xml b/spring-data-mongodb-distribution/pom.xml
index 9876e11ee3..38559fc7de 100644
--- a/spring-data-mongodb-distribution/pom.xml
+++ b/spring-data-mongodb-distribution/pom.xml
@@ -13,7 +13,7 @@
org.springframework.data
spring-data-mongodb-parent
- 1.11.0.BUILD-SNAPSHOT
+ 1.11.0.DATAMONGO-1620-SNAPSHOT
../pom.xml
diff --git a/spring-data-mongodb-log4j/pom.xml b/spring-data-mongodb-log4j/pom.xml
index c0436bac90..2e9ec23d29 100644
--- a/spring-data-mongodb-log4j/pom.xml
+++ b/spring-data-mongodb-log4j/pom.xml
@@ -5,7 +5,7 @@
org.springframework.data
spring-data-mongodb-parent
- 1.11.0.BUILD-SNAPSHOT
+ 1.11.0.DATAMONGO-1620-SNAPSHOT
../pom.xml
diff --git a/spring-data-mongodb/pom.xml b/spring-data-mongodb/pom.xml
index ea1b594b99..1644427e2b 100644
--- a/spring-data-mongodb/pom.xml
+++ b/spring-data-mongodb/pom.xml
@@ -11,7 +11,7 @@
org.springframework.data
spring-data-mongodb-parent
- 1.11.0.BUILD-SNAPSHOT
+ 1.11.0.DATAMONGO-1620-SNAPSHOT
../pom.xml
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoParsingUtils.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoParsingUtils.java
index 29c92097a7..f794fd9013 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoParsingUtils.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoParsingUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2015 the original author or authors.
+ * Copyright 2011-2017 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.
@@ -129,6 +129,7 @@ public static boolean parseMongoClientOptions(Element element, BeanDefinitionBui
setPropertyValue(clientOptionsDefBuilder, optionsElement, "heartbeat-socket-timeout", "heartbeatSocketTimeout");
setPropertyValue(clientOptionsDefBuilder, optionsElement, "ssl", "ssl");
setPropertyReference(clientOptionsDefBuilder, optionsElement, "ssl-socket-factory-ref", "sslSocketFactory");
+ setPropertyValue(clientOptionsDefBuilder, optionsElement, "server-selection-timeout", "serverSelectionTimeout");
mongoClientBuilder.addPropertyValue("mongoClientOptions", clientOptionsDefBuilder.getBeanDefinition());
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoClientOptionsFactoryBean.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoClientOptionsFactoryBean.java
index fe844df6e3..c435cc7f07 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoClientOptionsFactoryBean.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoClientOptionsFactoryBean.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 the original author or authors.
+ * Copyright 2015-2017 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.
@@ -18,8 +18,10 @@
import javax.net.SocketFactory;
import javax.net.ssl.SSLSocketFactory;
+import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.data.mongodb.MongoDbFactory;
+import org.springframework.data.mongodb.util.MongoClientVersion;
import com.mongodb.DBDecoderFactory;
import com.mongodb.DBEncoderFactory;
@@ -30,7 +32,7 @@
/**
* A factory bean for construction of a {@link MongoClientOptions} instance.
- *
+ *
* @author Christoph Strobl
* @author Oliver Gierke
* @since 1.7
@@ -62,13 +64,14 @@ public class MongoClientOptionsFactoryBean extends AbstractFactoryBean
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The WriteConcern that will be the default value used when asking the MongoDbFactory for a DB object
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The reference to a MongoTemplate. Will default to 'mongoTemplate'.
+
+
+
+
+
+
+ Enables creation of indexes for queries that get derived from the method name
+ and thus reference domain class properties. Defaults to false.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The reference to a DbFactory.
+
+
+
+
+
+
+
+
+
+
+
+ The reference to a MongoTypeMapper to be used by this MappingMongoConverter.
+
+
+
+
+
+
+ The reference to a MappingContext. Will default to 'mappingContext'.
+
+
+
+
+
+
+ Disables JSR-303 validation on MongoDB documents before they are saved. By default it is set to false.
+
+
+
+
+
+
+
+
+
+ Enables abbreviating the field names for domain class properties to the
+ first character of their camel case names, e.g. fooBar -> fb. Defaults to false.
+
+
+
+
+
+
+
+
+
+ The reference to a FieldNamingStrategy.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The WriteConcern that will be the default value used when asking the MongoDbFactory for a DB object
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A reference to a custom converter.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The reference to a DbFactory.
+
+
+
+
+
+
+
+
+
+
+
+ The WriteConcern that will be the default value used when asking the MongoDbFactory for a DB object
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The reference to a DbFactory.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/config/MongoClientParserIntegrationTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/config/MongoClientParserIntegrationTests.java
index b3f9c05410..8ad4105ef0 100644
--- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/config/MongoClientParserIntegrationTests.java
+++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/config/MongoClientParserIntegrationTests.java
@@ -19,6 +19,7 @@
import static org.hamcrest.core.Is.*;
import static org.hamcrest.core.IsInstanceOf.*;
import static org.junit.Assert.*;
+import static org.junit.Assume.*;
import org.junit.Before;
import org.junit.Test;
@@ -28,6 +29,8 @@
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.io.ClassPathResource;
+import org.springframework.data.mongodb.util.MongoClientVersion;
+import org.springframework.test.util.ReflectionTestUtils;
import com.mongodb.MongoClient;
import com.mongodb.MongoCredential;
@@ -36,7 +39,7 @@
/**
* Integration tests for {@link MongoClientParser}.
- *
+ *
* @author Christoph Strobl
*/
public class MongoClientParserIntegrationTests {
@@ -113,4 +116,24 @@ public void createsMongoClientWithCredentialsCorrectly() {
context.close();
}
}
+
+ @Test // DATAMONGO-1620
+ public void createsMongoClientWithServerSelectionTimeoutCorrectly() {
+
+ assumeThat(MongoClientVersion.isMongo3Driver(), is(true));
+
+ reader.loadBeanDefinitions(new ClassPathResource("namespace/mongoClient-bean.xml"));
+
+ AbstractApplicationContext context = new GenericApplicationContext(factory);
+ context.refresh();
+
+ try {
+
+ MongoClient client = context.getBean("mongo-client-with-server-selection-timeout", MongoClient.class);
+ assertThat(ReflectionTestUtils.getField(client.getMongoClientOptions(), "serverSelectionTimeout"),
+ is((Object) 100));
+ } finally {
+ context.close();
+ }
+ }
}
diff --git a/spring-data-mongodb/src/test/resources/namespace/mongoClient-bean.xml b/spring-data-mongodb/src/test/resources/namespace/mongoClient-bean.xml
index 8f6a36b231..4b157b561e 100644
--- a/spring-data-mongodb/src/test/resources/namespace/mongoClient-bean.xml
+++ b/spring-data-mongodb/src/test/resources/namespace/mongoClient-bean.xml
@@ -15,4 +15,9 @@
+
+
+
+
+