Skip to content

Commit ab058d2

Browse files
committed
RUBY-759 Default value for max write batch size if no manager
1 parent 2f08609 commit ab058d2

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/mongo/mongo_replica_set_client.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,8 @@ def primary_wire_version_feature?(feature)
471471
end
472472

473473
def max_write_batch_size
474-
local_manager && local_manager.primary_pool && local_manager.primary_pool.node.max_write_batch_size
474+
local_manager && local_manager.primary_pool && local_manager.primary_pool.node.max_write_batch_size ||
475+
DEFAULT_MAX_WRITE_BATCH_SIZE
475476
end
476477

477478
private

test/replica_set/max_values_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,5 +141,11 @@ def test_max_write_batch_size
141141
@client.local_manager.primary_pool.node.stubs(:max_write_batch_size).returns(999)
142142
assert_equal 999, @client.max_write_batch_size
143143
end
144+
145+
def test_max_write_batch_size_no_manager
146+
# Simulate no local manager being set yet - RUBY-759
147+
@client.stubs(:local_manager).returns(nil)
148+
assert_equal Mongo::MongoClient::DEFAULT_MAX_WRITE_BATCH_SIZE, @client.max_write_batch_size
149+
end
144150
end
145151

0 commit comments

Comments
 (0)