Skip to content

Commit

Permalink
Fix for #126
Browse files Browse the repository at this point in the history
- NPE if options is missing in river settings.
  • Loading branch information
richardwilly98 committed Sep 18, 2013
1 parent 90554df commit f9d782f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ public synchronized static MongoDBRiverDefinition parseSettings(
}
builder.mongoServers(mongoServers);

MongoClientOptions.Builder mongoClientOptionsBuilder = MongoClientOptions
.builder().autoConnectRetry(true)
.socketKeepAlive(true);

// MongoDB options
if (mongoSettings.containsKey(OPTIONS_FIELD)) {
Map<String, Object> mongoOptionsSettings = (Map<String, Object>) mongoSettings
Expand All @@ -377,10 +381,8 @@ public synchronized static MongoDBRiverDefinition parseSettings(
.nodeBooleanValue(mongoOptionsSettings
.get(ADVANCED_TRANSFORMATION_FIELD), false));

MongoClientOptions.Builder mongoClientOptionsBuilder = MongoClientOptions
.builder().autoConnectRetry(true)
mongoClientOptionsBuilder
.connectTimeout(builder.connectTimeout)
.socketKeepAlive(true)
.socketTimeout(builder.socketTimeout);

if (builder.mongoSecondaryReadPreference) {
Expand All @@ -392,8 +394,6 @@ public synchronized static MongoDBRiverDefinition parseSettings(
.socketFactory(getSSLSocketFactory());
}

builder.mongoClientOptions(mongoClientOptionsBuilder.build());

if (mongoOptionsSettings.containsKey(PARENT_TYPES_FIELD)) {
Set<String> parentTypes = new HashSet<String>();
Object parentTypesSettings = mongoOptionsSettings
Expand Down Expand Up @@ -497,6 +497,7 @@ public synchronized static MongoDBRiverDefinition parseSettings(
}
}
}
builder.mongoClientOptions(mongoClientOptionsBuilder.build());

// Credentials
if (mongoSettings.containsKey(CREDENTIALS_FIELD)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
"host": "localhost",
"port": %s
}],
"options": {
"secondary_read_preference": true
},
"db": "%s",
"collection": "%s",
"gridfs": false
Expand Down

0 comments on commit f9d782f

Please sign in to comment.