mizosoft / methanol

⚗️ Lightweight HTTP extensions for Java
https://mizosoft.github.io/methanol
MIT License
241 stars 12 forks source link

Fix missed response for HttpResponsePublisher #69

Closed mizosoft closed 7 months ago

mizosoft commented 7 months ago

Because onResponse(response) decrements ongoing prematurely (before submitting the response and potentially completing downstream), the last response passed might be missed when a race happens with onInitialResponseBodyCompletion(). Consider this scenario:

The fix is to not prematurely decrement ongoing when the last response is received, but do so after the response is submitted. This way, onInitialResponseBodyCompletion never perceives a completed stream that is not really completed.

coveralls commented 7 months ago

Coverage Status

coverage: 91.309% (+0.006%) from 91.303% when pulling 790bdddc63b89c13f578350d37386718ec50ab4b on fix-missed-response into e77b44d5552de7d042bd6e9c63d26bd122904477 on master.