Commit f93dd01
authored
RPC: Fix
* RPC: Fix getObject() using wrong baseline for receiving diffs
getObject() used localObjects as the diff baseline when receiving from
the remote peer. But the remote computes diffs against the last synced
state (remoteObjects), not the local state. When the local side modifies
a tree (e.g., via a local recipe) before calling getObject(), the two
baselines diverge, producing a hybrid tree that corrupts remoteObjects
and causes subsequent transfers to fail with IndexError/desync.
Fix: use remoteObjects (the last synced state) as the baseline, matching
what the remote peer uses. Python's get_object_from_java() already did
this correctly; Java and TypeScript had the same bug.
* RPC: Reset remote object tracking on getObject() failure to prevent state desync
When getObject() fails mid-deserialization (e.g., ClassCastException), the
sender has already updated its tracking of what the receiver has, but the
receiver never applied the change. This causes all subsequent RPC interactions
for that object to compute diffs against the wrong baseline, leading to
"Expected positions array" and similar desync errors.
Fix by removing remoteObjects[id] when receive() throws, so the next
interaction sends a full ADD (no delta), re-synchronizing both sides.
Also fix Python's handle_visit() to always fetch the tree from Java via
get_object_from_java(), matching the JS implementation. The previous code
used a stale local_objects cache, which meant Python could operate on an
outdated tree version after Java-side modifications or error recovery.
* RPC: Fix Python get_object_from_java missing END_OF_OBJECT on batch boundary
When serialized data items are an exact multiple of the handler's
batchSize, END_OF_OBJECT ends up alone in a separate batch that
receiver.receive() never pulls. Drain the pending batch after
receive() completes — analogous to Java/JS's explicit q.take().
Add integration test with small batchSize to exercise the fix.getObject() desync bugs (#6835)1 parent f03fa74 commit f93dd01
4 files changed
Lines changed: 101 additions & 15 deletions
File tree
- rewrite-core/src
- main/java/org/openrewrite/rpc
- test/java/org/openrewrite/rpc
- rewrite-javascript/rewrite/src/rpc
- rewrite-python/rewrite/src/rewrite/rpc
Lines changed: 14 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
461 | 461 | | |
462 | 462 | | |
463 | 463 | | |
464 | | - | |
465 | | - | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
466 | 469 | | |
467 | 470 | | |
468 | 471 | | |
469 | 472 | | |
470 | 473 | | |
471 | 474 | | |
472 | 475 | | |
473 | | - | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
474 | 485 | | |
475 | 486 | | |
476 | 487 | | |
| |||
Lines changed: 54 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
| 45 | + | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
| |||
82 | 85 | | |
83 | 86 | | |
84 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
85 | 139 | | |
86 | 140 | | |
87 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
128 | 132 | | |
129 | 133 | | |
130 | 134 | | |
| |||
133 | 137 | | |
134 | 138 | | |
135 | 139 | | |
136 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
137 | 149 | | |
138 | 150 | | |
139 | 151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
203 | 213 | | |
204 | 214 | | |
205 | 215 | | |
| |||
1036 | 1046 | | |
1037 | 1047 | | |
1038 | 1048 | | |
1039 | | - | |
1040 | | - | |
1041 | | - | |
1042 | | - | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
1043 | 1052 | | |
1044 | 1053 | | |
1045 | 1054 | | |
| |||
0 commit comments