Environment
OkHttp 4.2.2
Only happens on Windows. On linux and MacOS, the correct (expected) behavior occurs.
Description
On Windows, the OkHttp Cache does not update response body data for a request when a later response has the same ETag as a previous response.
Steps
- Request a URL /a/b
- Response Header: 404, no ETag
- Response Body: '{ "message": "Not Found" }'
- Cache Updated
- Request a URL /a/b with "If-Modified-Since" header
- Response Header: 304, ETag "C"
- Cache automatically converts - client sees:
- Response Header: 404, ETag "C"
- Response Body: '{ "message": "Not Found" }'
- Request a URL /a/b with "Cache-Control: no-cache" to force retrieval of new data
- Response Header: 200, ETag "C"
- Response Body: '{ data: "..." }'
- NOTE: Yes, that is the same ETag with different data - not good, but cache should still work
- Cache Updated? (I think this is where the problem starts).
- Request a URL /a/b with "If-None-Match" equal to ETag "C"
Expected Result
- Response Header: 304, ETag "C"
- Cache automatically converts - client sees:
- Response Header: 200, ETag "C"
- Response Body: '{ data: "..." }'
Actual Result
- Response Header: 304, ETag "C"
- Cache automatically converts - client sees:
- Response Header: 200, ETag "C"
- Response Body: '{ "message": "Not Found" }'
Automated Test
I know it is not great to point to a test on an external project but the test fully automated and will repro the issue every time:
https://github.com/github-api/github-api/blob/967512629821b706e8d06ef9b3e57061f397d073/src/test/java/org/kohsuke/github/extras/okhttp3/GitHubCachingTest.java#L59
To run automated repro:
- clone the repository on Windows with JDK 8+
- remove the
assumeFalse() call
- run
mvn install
Notes
This issue was found and can be reproduced using https://github.com/github-api/github-api .
It is exposed due to a bug in GitHub server responses (see hub4j/github-api#669) but it is still a bug in this OkHttp Cache behavior on Windows.
Environment
OkHttp 4.2.2
Only happens on Windows. On linux and MacOS, the correct (expected) behavior occurs.
Description
On Windows, the OkHttp Cache does not update response body data for a request when a later response has the same ETag as a previous response.
Steps
Expected Result
Actual Result
Automated Test
I know it is not great to point to a test on an external project but the test fully automated and will repro the issue every time:
https://github.com/github-api/github-api/blob/967512629821b706e8d06ef9b3e57061f397d073/src/test/java/org/kohsuke/github/extras/okhttp3/GitHubCachingTest.java#L59
To run automated repro:
assumeFalse()callmvn installNotes
This issue was found and can be reproduced using https://github.com/github-api/github-api .
It is exposed due to a bug in GitHub server responses (see hub4j/github-api#669) but it is still a bug in this OkHttp Cache behavior on Windows.