File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1230,6 +1230,11 @@ mongoc_uri_get_local_threshold_option (const mongoc_uri_t *uri)
1230
1230
BSON_ITER_HOLDS_INT32 (& iter )) {
1231
1231
1232
1232
retval = bson_iter_int32 (& iter );
1233
+
1234
+ if (retval < 0 ) {
1235
+ MONGOC_WARNING ("Invalid localThresholdMS: %d" , retval );
1236
+ retval = MONGOC_TOPOLOGY_LOCAL_THRESHOLD_MS ;
1237
+ }
1233
1238
}
1234
1239
1235
1240
return retval ;
Original file line number Diff line number Diff line change @@ -903,6 +903,19 @@ test_mongoc_uri_local_threshold_ms (void)
903
903
ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri ), = = , 99 );
904
904
905
905
mongoc_uri_destroy (uri );
906
+
907
+
908
+ uri = mongoc_uri_new (
909
+ "mongodb://localhost/?" MONGOC_URI_LOCALTHRESHOLDMS "=-1" );
910
+
911
+ /* localthresholdms is invalid, return the default */
912
+ capture_logs (true);
913
+ ASSERT_CMPINT (mongoc_uri_get_local_threshold_option (uri ), = = ,
914
+ MONGOC_TOPOLOGY_LOCAL_THRESHOLD_MS );
915
+ ASSERT_CAPTURED_LOG ("mongoc_uri_get_local_threshold_option" ,
916
+ MONGOC_LOG_LEVEL_WARNING , "Invalid localThresholdMS: -1" );
917
+
918
+ mongoc_uri_destroy (uri );
906
919
}
907
920
908
921
You can’t perform that action at this time.
0 commit comments