Commit 75d8249
EVCacheValueSerde: drop bodyLength from the wire format
The bodyLength field was meant to serve two purposes — additive
forward-compat (skip extension bytes past the known fields) and
corruption detection (reject trailing bytes). Those goals conflict:
extension bytes and under-framed length prefixes are observationally
identical to the reader, so the design could only catch one and ended up
catching the cosmetic one — trailing bytes the serializer cannot produce
by construction — while letting length-prefix under-framing slip
through unchecked.
Removing bodyLength entirely. End-of-envelope is now implicit at
bytes.length. Newer writers append optional fields after createTime;
older readers stop after the known fields and leave any remaining
bytes unread. Required fields still need the version-byte rollout
documented in the class javadoc.
Tests: the two forward-compat tests (v0 pinned-payload trip-wire and
future-extension-bytes) refrozen against the simpler format and both
pass; the bodyLength-specific corruption tests are removed
(testDecodeBinaryWithBogusBodyLengthReturnsNull,
testDecodeBinaryWithNegativeBodyLengthReturnsNull,
testDecodeBinaryWithTrailingBytesBeyondBodyReturnsNull). The remaining
bounds-check tests are simplified to drop the no-longer-present bodyLength
prefix from their crafted bytes.
Bit-corruption detection for value bytes / length-prefix tampering is
deferred to a follow-up — it will not be bodyLength.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 2ca789b commit 75d8249
2 files changed
Lines changed: 40 additions & 108 deletions
File tree
- evcache-core/src
- main/java/com/netflix/evcache/pool
- test/java/com/netflix/evcache/pool
Lines changed: 24 additions & 45 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
24 | | - | |
| 23 | + | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
32 | | - | |
33 | | - | |
34 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
| |||
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
100 | 99 | | |
101 | 100 | | |
102 | 101 | | |
103 | 102 | | |
104 | | - | |
105 | 103 | | |
106 | 104 | | |
107 | 105 | | |
| |||
115 | 113 | | |
116 | 114 | | |
117 | 115 | | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
122 | 120 | | |
123 | 121 | | |
124 | 122 | | |
| |||
133 | 131 | | |
134 | 132 | | |
135 | 133 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | 134 | | |
149 | 135 | | |
150 | 136 | | |
| |||
173 | 159 | | |
174 | 160 | | |
175 | 161 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
| 162 | + | |
| 163 | + | |
185 | 164 | | |
186 | 165 | | |
187 | 166 | | |
| |||
Lines changed: 16 additions & 63 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | | - | |
224 | | - | |
| 223 | + | |
| 224 | + | |
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | 228 | | |
257 | | - | |
258 | | - | |
| 229 | + | |
259 | 230 | | |
260 | 231 | | |
261 | 232 | | |
262 | 233 | | |
263 | 234 | | |
264 | | - | |
265 | | - | |
| 235 | + | |
| 236 | + | |
266 | 237 | | |
267 | 238 | | |
268 | 239 | | |
269 | | - | |
270 | | - | |
| 240 | + | |
271 | 241 | | |
272 | 242 | | |
273 | 243 | | |
274 | 244 | | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | 245 | | |
287 | 246 | | |
288 | 247 | | |
289 | | - | |
| 248 | + | |
290 | 249 | | |
291 | 250 | | |
292 | 251 | | |
| |||
297 | 256 | | |
298 | 257 | | |
299 | 258 | | |
300 | | - | |
301 | 259 | | |
302 | 260 | | |
303 | 261 | | |
| |||
312 | 270 | | |
313 | 271 | | |
314 | 272 | | |
315 | | - | |
316 | | - | |
| 273 | + | |
| 274 | + | |
317 | 275 | | |
318 | 276 | | |
319 | 277 | | |
320 | | - | |
| 278 | + | |
321 | 279 | | |
322 | | - | |
323 | | - | |
324 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
325 | 283 | | |
326 | 284 | | |
327 | 285 | | |
328 | 286 | | |
329 | 287 | | |
330 | 288 | | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
339 | 292 | | |
340 | 293 | | |
341 | 294 | | |
| |||
0 commit comments