Skip to content

Fix for not closed GzipSource#488

Merged
vbuberen merged 2 commits into
developfrom
fix/gzip
Nov 1, 2020
Merged

Fix for not closed GzipSource#488
vbuberen merged 2 commits into
developfrom
fix/gzip

Conversation

@vbuberen

@vbuberen vbuberen commented Oct 31, 2020

Copy link
Copy Markdown
Collaborator

📄 Context

There is an issue #472
Issue appears with StrictMode enabled. We couldn't catch the issue earlier, because sample app has no gzip request with body, so code with error wasn't reachable.

📝 Changes

  • Fixed the issue by adding use { } function to GzipSource in getNativeSource() function.
  • Updated tests to use real Buffer(), since Mockk can't properly react to close() call.
  • Added a fake Gzip request which I fill with some dummy request body and header telling that response is with gzip encoding. It returns 405, but allows to reproduce the issue.
  • Added StrictMode to the sample app, because this is not the first time we have issues reported by people with this mode enabled (for example StrictMode policy violation: android.os.strictmode.LeakedClosableViolation #421)
  • (UPD: after review) Renamed existing gzip request to explicitly mention that it returns just gzip response.

🛠️ How to test

To reproduce the issue remove use from getNativeSource() and use just GzipSource directly. With StrictMode enabled sample will crash when fakeGzipRequest() is called.

⏱️ Next steps

We might want to improve the part of request processing and cover it with some more tests.
Closes #472

@vbuberen vbuberen added the bug Something isn't working label Oct 31, 2020
@vbuberen vbuberen added this to the 3.4.0 milestone Oct 31, 2020

@MiSikora MiSikora left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one minor thing.

As far as the requests revamp go I think we should go with a similar route to responses processing.

Comment thread sample/src/main/java/com/chuckerteam/chucker/sample/HttpBinClient.kt Outdated
@vbuberen vbuberen requested a review from MiSikora November 1, 2020 09:24
@vbuberen vbuberen merged commit bf3132a into develop Nov 1, 2020
@vbuberen vbuberen deleted the fix/gzip branch November 1, 2020 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StrictModeViolation: GzipSource is not closed

2 participants