Skip to content

Commit

Permalink
Revert "Support MongoClient initialization with a URI"
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin authored Jan 6, 2017
1 parent 8e3e0bc commit d76816a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,6 @@ public class InternalMongoConnector implements MongoConnector {
private final MongoClient mongoClient;
private final MongoDatabase database;

/**
* Constructs an instance of {@link InternalMongoConnector}.
*
* @param writeConcern instance of {@link WriteConcern}. Each {@link MongoCollection} produced by
* {@link #getCollection(String)} will be configured with this write concern.
* @param mongoClientURI {@link MongoClientURI} that we just created.
*/
public InternalMongoConnector(final WriteConcern writeConcern, final MongoClientURI mongoClientURI) {
this.writeConcern = writeConcern;
this.mongoClient = new MongoClient(mongoClientURI);
this.database = this.mongoClient.getDatabase(mongoClientURI.getDatabase());
}

/**
* Constructs an instance of {@link InternalMongoConnector}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,6 @@ public MongoConnector build() throws SchedulerConfigException {
return new ExternalMongoConnector(writeConcern, database);
}

if (uri != null) {
// User passed URI.
validateForUri();
MongoClientURI mongoUri = new MongoClientURI(uri);
if(dbName == null){
dbName = mongoUri.getDatabase();
}
return new InternalMongoConnector(writeConcern, mongoUri);
}

// Options below require database name
checkNotNull(dbName, "'Database name' parameter is required.");

Expand All @@ -89,6 +79,12 @@ public MongoConnector build() throws SchedulerConfigException {
return new ExternalMongoConnector(writeConcern, client, dbName);
}

if (uri != null) {
// User passed URI.
validateForUri();
return new InternalMongoConnector(writeConcern, uri, dbName);
}

checkNotNull(addresses, "At least one MongoDB address or a MongoDB URI must be specified.");
final List<ServerAddress> serverAddresses = collectServerAddresses();
final List<MongoCredential> credentials = createCredentials();
Expand Down

0 comments on commit d76816a

Please sign in to comment.