cfriedt opened a new pull request #2007: URL: https://github.com/apache/thrift/pull/2007
<!-- Explain the changes in the pull request below: --> The TMemoryBuffer policy is "OBSERVER" by default in a constructor where an external pointer to memory, and the size of that memory, are passed in. That scenario is for externally managed buffers. As an observer of a buffer, Thrift should only be able to read. However, previously, `buf.available_read()` would return 0 (and subsequently, `buf.read()` would fail). I've added a test as a separate commit, so it's easy to observe the failure and fix. The current behaviour produces the following failure. ``` TMemoryBufferTest.cpp(141): error: in "TMemoryBufferTest/test_observer": check N == buf.available_read() has failed [1024 != 0] ``` With this change, Thrift applications that use Memory as a transport are able to read `OBSERVER` buffers as well (as one would expect) and the error above is mitigated. <!-- We recommend you review the checklist/tips before submitting a pull request. --> - [x] Did you create an [Apache Jira](https://issues.apache.org/jira/projects/THRIFT/issues/) ticket? (not required for trivial changes) - [x] If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"? - [x] Did you squash your changes to a single commit? (not required, but preferred) - [x] Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"? - [ ] If your change does not involve any code, add ` [skip ci]` at the end of your pull request to free up build resources. <!-- The Contributing Guide at: https://github.com/apache/thrift/blob/master/CONTRIBUTING.md has more details and tips for committing properly. --> ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
