IosHttpURLConnection should throw when interrupted
- Dominant language
- Java
- Stars
- 6k
- Forks
- 999
- Avg merge
- 19h 20m
- Merged PRs (30d)
- 14
Description
I'm using thread interruption to cancel ongoing http requests made with HttpURLConnection. This works correctly on Android by catching `InterruptedIOException` from methods like `getResponseCode()`. However, on iOS interruptions are ignored and instead `getResponseCode()` returns `-1`.
My proposal would be in the private `getResponse()` method instead of ignoring `InterruptedException`, create a new `InterruptedIOException`, assign it to `responseException`, and then raise it right there around here:
https://github.com/google/j2objc/blob/fae801525820b8a7018e36e4d6c13c8b7ca152f3/jre_emul/Classes/com/google/j2objc/net/IosHttpURLConnection.java#L472
Also, I believe the synchronized-wait check needs to be a `while` loop to account for spurious wake-ups from Object.wait():
https://github.com/google/j2objc/blob/fae801525820b8a7018e36e4d6c13c8b7ca152f3/jre_emul/Classes/com/google/j2objc/net/IosHttpURLConnection.java#L461
I'm still troubleshooting my j2objc build issues so I haven't been able to try this out myself. Once I get it working, I can submit a pull request with these changes but I'm curious to hear if this seems like a problematic change to anybody.
Contributor guide
Assessment
This issue has not been assessed yet.