Commit 44dd995
* RUBY-3816 Remove instance_variable_set reach-ins in core types
Replace metaprogramming reach-ins that mutated another object's private
state with straightforward OO.
Cluster.create and Database.create only ever mutated the client they were
handed, via instance_variable_set, and were called only from Client#with.
Move that behavior onto Client as reset_cluster! and reset_database!, and
delete the two class factories.
Convert Message.deserialize_array and .deserialize_field from class methods
that set ivars on a passed-in message into instance methods, so the ivar
access is ordinary self-assignment. Update both call sites.
* RUBY-3816 Replace send with public_send/direct calls on public methods
Several sites used Object#send to invoke methods that are already public,
which needlessly bypasses method visibility and hides intent. Switch them
to public_send, or to a direct call where the method name is a literal.
No behavior change: every affected method is public.
* RUBY-3816 Use Monitor#running? instead of reaching into @thread
server_selection_diagnostic_message reached into each server monitor's
private @thread ivar to decide whether the monitor was dead. BackgroundThread
already exposes a public #running? predicate with exactly the needed
semantics (nil thread or dead thread => not running), so use it.
Guard with safe navigation: server.monitor can be nil, and the old
instance_variable_get(:@thread) silently returned nil for that case
(counting the monitor as dead), which &.running? preserves.
* RUBY-3816 Call with_session and Index::View#limit without send
Client#with_session is already public, so three callers that invoked it
via send now call it directly. Collection::View#with_session was private
and reached via send from MapReduce; promote it to a public @api private
method and call it directly.
Also make Index::View#limit public (@api private). Cursor#limit calls
@view.limit, and @view may be an Index::View, so the method must be public
there as it already is on Collection::View. This removes the send that
Cursor previously needed and fixes the case exposed when Cursor#limit
stopped using send.
* RUBY-3816 Expose internal Session and Client methods instead of send
Session#txn_read_concern and Session#causal_consistency_doc were private
and reached via send from operation and view code; make them public
@api private and call them directly.
Client#monitoring was public but then re-marked private, and reached via
send from the auto encrypter; drop the private marker (it is already
documented @api private) and call it directly.
* RUBY-3816 Expose view server_selector and FSBucket#ensure_indexes!
Collection::View#server_selector (from Readable) was private and reached
via send from MapReduce and Aggregation, whose @view is a Collection::View.
Make it public @api private and call it directly.
FSBucket#ensure_indexes! was private and reached via send from the write
stream. Make it public @api private and call it directly.
* RUBY-3816 Expose message field helpers and connection socket interrupt
Message#fields and Message#serialize_fields were private and reached via
send during (de)serialization, including from Compressed. Make them public
@api private and call them directly; promote the Compressed#serialize_fields
override to match.
PushMonitor#stop! reached into its connection with send(:socket).close to
interrupt a blocking read. Add ConnectionCommon#interrupt_socket (@api
private) that encapsulates this, and call it instead.
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* make this `@api private` instead of `private`, so it can be invoked internally
* bump drivers-evergreen-tools to fix npm installation failure
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 7fa0679 commit 44dd995
27 files changed
Lines changed: 151 additions & 140 deletions
File tree
- lib/mongo
- auth/user
- bulk_write
- cluster
- collection
- view
- aggregation
- crypt
- database
- grid
- stream
- index
- options
- protocol
- server_selector
- server
- socket
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
176 | 175 | | |
177 | 176 | | |
178 | 177 | | |
| |||
796 | 795 | | |
797 | 796 | | |
798 | 797 | | |
799 | | - | |
| 798 | + | |
800 | 799 | | |
801 | 800 | | |
802 | | - | |
| 801 | + | |
803 | 802 | | |
804 | 803 | | |
805 | 804 | | |
| |||
855 | 854 | | |
856 | 855 | | |
857 | 856 | | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
858 | 882 | | |
859 | 883 | | |
860 | 884 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | 272 | | |
297 | 273 | | |
298 | 274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
388 | | - | |
| 388 | + | |
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
405 | | - | |
| 405 | + | |
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
396 | | - | |
| 396 | + | |
397 | 397 | | |
398 | 398 | | |
399 | 399 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
239 | 247 | | |
240 | 248 | | |
241 | 249 | | |
| |||
252 | 260 | | |
253 | 261 | | |
254 | 262 | | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | 263 | | |
260 | 264 | | |
261 | 265 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
230 | | - | |
| 230 | + | |
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | | - | |
| 244 | + | |
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
678 | 678 | | |
679 | 679 | | |
680 | 680 | | |
681 | | - | |
| 681 | + | |
682 | 682 | | |
683 | 683 | | |
684 | 684 | | |
| |||
749 | 749 | | |
750 | 750 | | |
751 | 751 | | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
758 | 756 | | |
759 | 757 | | |
760 | 758 | | |
| |||
763 | 761 | | |
764 | 762 | | |
765 | 763 | | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
766 | 770 | | |
767 | 771 | | |
768 | 772 | | |
| |||
0 commit comments