Remove useless checked exception throw clause

pull/6883/merge
Stephane Nicoll 8 years ago
parent ad9d912009
commit ea18fe58e4

@ -16,8 +16,6 @@
package org.springframework.boot.autoconfigure.mongo;
import java.net.UnknownHostException;
import javax.annotation.PreDestroy;
import com.mongodb.MongoClient;
@ -68,7 +66,7 @@ public class MongoAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public MongoClient mongo() throws UnknownHostException {
public MongoClient mongo() {
this.mongo = this.factory.createMongoClient(this.options);
return this.mongo;
}

@ -16,7 +16,6 @@
package org.springframework.boot.autoconfigure.mongo;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -59,10 +58,8 @@ public class MongoClientFactory {
* to an embedded MongoDB instance.
* @param options the options
* @return the Mongo client
* @throws UnknownHostException if the configured host is unknown
*/
public MongoClient createMongoClient(MongoClientOptions options)
throws UnknownHostException {
public MongoClient createMongoClient(MongoClientOptions options) {
Integer embeddedPort = getEmbeddedPort();
if (embeddedPort != null) {
return createEmbeddedMongoClient(options, embeddedPort);
@ -91,8 +88,7 @@ public class MongoClientFactory {
Collections.emptyList(), options);
}
private MongoClient createNetworkMongoClient(MongoClientOptions options)
throws UnknownHostException {
private MongoClient createNetworkMongoClient(MongoClientOptions options) {
if (hasCustomAddress() || hasCustomCredentials()) {
if (this.properties.getUri() != null) {

@ -16,7 +16,6 @@
package org.springframework.boot.autoconfigure.mongo;
import java.net.UnknownHostException;
import java.util.List;
import com.mongodb.MongoClient;
@ -52,7 +51,7 @@ public class MongoClientFactoryTests {
private MockEnvironment environment = new MockEnvironment();
@Test
public void portCanBeCustomized() throws UnknownHostException {
public void portCanBeCustomized() {
MongoProperties properties = new MongoProperties();
properties.setPort(12345);
MongoClient client = createMongoClient(properties);
@ -62,7 +61,7 @@ public class MongoClientFactoryTests {
}
@Test
public void hostCanBeCustomized() throws UnknownHostException {
public void hostCanBeCustomized() {
MongoProperties properties = new MongoProperties();
properties.setHost("mongo.example.com");
MongoClient client = createMongoClient(properties);
@ -72,7 +71,7 @@ public class MongoClientFactoryTests {
}
@Test
public void credentialsCanBeCustomized() throws UnknownHostException {
public void credentialsCanBeCustomized() {
MongoProperties properties = new MongoProperties();
properties.setUsername("user");
properties.setPassword("secret".toCharArray());
@ -82,7 +81,7 @@ public class MongoClientFactoryTests {
}
@Test
public void databaseCanBeCustomized() throws UnknownHostException {
public void databaseCanBeCustomized() {
MongoProperties properties = new MongoProperties();
properties.setDatabase("foo");
properties.setUsername("user");
@ -93,7 +92,7 @@ public class MongoClientFactoryTests {
}
@Test
public void authenticationDatabaseCanBeCustomized() throws UnknownHostException {
public void authenticationDatabaseCanBeCustomized() {
MongoProperties properties = new MongoProperties();
properties.setAuthenticationDatabase("foo");
properties.setUsername("user");
@ -104,7 +103,7 @@ public class MongoClientFactoryTests {
}
@Test
public void uriCanBeCustomized() throws UnknownHostException {
public void uriCanBeCustomized() {
MongoProperties properties = new MongoProperties();
properties.setUri("mongodb://user:secret@mongo1.example.com:12345,"
+ "mongo2.example.com:23456/test");
@ -119,7 +118,7 @@ public class MongoClientFactoryTests {
}
@Test
public void uriCannotBeSetWithCredentials() throws UnknownHostException {
public void uriCannotBeSetWithCredentials() {
MongoProperties properties = new MongoProperties();
properties.setUri("mongodb://127.0.0.1:1234/mydb");
properties.setUsername("user");
@ -131,7 +130,7 @@ public class MongoClientFactoryTests {
}
@Test
public void uriCannotBeSetWithHostPort() throws UnknownHostException {
public void uriCannotBeSetWithHostPort() {
MongoProperties properties = new MongoProperties();
properties.setUri("mongodb://127.0.0.1:1234/mydb");
properties.setHost("localhost");
@ -143,7 +142,7 @@ public class MongoClientFactoryTests {
}
@Test
public void uriIsIgnoredInEmbeddedMode() throws UnknownHostException {
public void uriIsIgnoredInEmbeddedMode() {
MongoProperties properties = new MongoProperties();
properties.setUri("mongodb://mongo.example.com:1234/mydb");
this.environment.setProperty("local.mongo.port", "4000");
@ -153,14 +152,12 @@ public class MongoClientFactoryTests {
assertServerAddress(allAddresses.get(0), "localhost", 4000);
}
private MongoClient createMongoClient(MongoProperties properties)
throws UnknownHostException {
private MongoClient createMongoClient(MongoProperties properties) {
return createMongoClient(properties, null);
}
private MongoClient createMongoClient(MongoProperties properties,
Environment environment)
throws UnknownHostException {
Environment environment) {
return new MongoClientFactory(properties, environment).createMongoClient(null);
}

@ -16,8 +16,6 @@
package org.springframework.boot.autoconfigure.mongo;
import java.net.UnknownHostException;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientOptions;
import org.junit.Rule;
@ -56,7 +54,7 @@ public class MongoPropertiesTests {
}
@Test
public void allMongoClientOptionsCanBeSet() throws UnknownHostException {
public void allMongoClientOptionsCanBeSet() {
MongoClientOptions.Builder builder = MongoClientOptions.builder();
builder.alwaysUseMBeans(true);
builder.connectionsPerHost(101);

Loading…
Cancel
Save