Jens-G opened a new pull request, #3579: URL: https://github.com/apache/thrift/pull/3579
## THRIFT-6065: Make TMemoryStream growable so it can be written and then read ### Problem `TMemoryStream` could not be written to: - `Write()` did `Data.set(Position + i, …)` into a **fixed-size** `Bytes`, which cannot grow, so writing to a freshly constructed stream was out of bounds. On the **neko** target the no-argument constructor never initialized `Position`, so the first write threw `"Invalid operation (+)"`. - `Write()` never advanced `Position`. - The constructor left `Position` at the end of any supplied data, so a stream built from existing bytes could not be read without first doing `Position = 0` (the only existing consumer, `ConstantsTest`, did exactly that workaround). ### Change Back the stream with a **growable** buffer: writing past the current end enlarges the backing `Bytes` (capacity doubling, amortized O(1) appends) and advances `Position`; a separate `Length` tracks the logical size used by `Read`/`Peek`; the constructor always initializes `Position = 0`. `Read`/`Write` use `blit`. Cross-target `Bytes` API only. This lets a single `TMemoryStream` serve as an in-memory transport for a write-then-read round-trip (write, set `Position = 0`, read) — the pattern that previously required a temporary file via `TFileStream`. ### Test Adds to `lib/haxe/test` `StreamTest` (runs in the suite's Normal mode): an `Xtruct` round-trip through a single `TMemoryStream` over `TJSONProtocol` (write → rewind → read) plus a grow-on-write assertion (1000 single-byte appends read back intact). Validated locally on neko (Haxe lib unit tests have no CI job, as for all Haxe lib testing here): `StreamTest` memory cases pass; a protocol-level round-trip of a recursive struct over a single `TMemoryStream` round-trips; and the existing `ConstantsTest` (the prior consumer, `new TStreamTransport(stream, stream)` + `readUuid`) still passes — confirming no regression. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
