Load content to buffer before attempting deserialization #1705
Load content to buffer before attempting deserialization #1705ChrisPulman merged 4 commits intoreactiveui:mainfrom
Conversation
…w content can be captured in ApiException if an exception occurs during deserialization
|
Unfortunately the tests are falling with this addition, please could you see how this may be resolved. |
|
The failing test was for the non-seekable stream case: to address this I'm now obtaining the underlying stream with |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1705 +/- ##
==========================================
- Coverage 87.73% 87.63% -0.11%
==========================================
Files 33 33
Lines 2348 2329 -19
Branches 294 290 -4
==========================================
- Hits 2060 2041 -19
- Misses 208 210 +2
+ Partials 80 78 -2 ☔ View full report in Codecov by Sentry. |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What kind of change does this PR introduce?
Fixes issue #1384 by ensuring response content is loaded to a buffer before attempting serialization.
What is the current behavior?
When an exception is thrown during deserialization,
ApiExceptionattempts to capture the request content to theContentproperty to make it available when the exception is being handled (e.g. so apps can log the content to aid debugging). However, the underlying stream in theHttpContentobject has already been consumed by the deserialization and cannot be re-read.What is the new behavior?
By loading the content to a buffer before attempting to deserialize we ensure the stream can be re-read by
ApiException.What might this PR break?
I've moved the
LoadIntoBufferAsynccall to just before the call to the (de)serializer to ensure we only do this on this exact code path, rather than as soon as thecontentvariable is set as I originally suggested in #1384. This should avoid any problems that could arise from API calls that expect to handle theHttpContentorStreamdirectly (callingLoadIntoBufferAsyncis probably not desirable for these scenarios where we might expect endpoints to return long-lived connections or very large payloads).Please check if the PR fulfills these requirements
Other information: