Conversation
Add safe cancellation support to FutureCallback This PR adds proper cancellation support to `FutureCallback`: - Implements `cancel()` to mark the future as cancelled and unblock `get()` - `get()` now throws `CancellationException` if cancelled - `isCancelled()` reflects the state This makes `FutureCallback` fully compliant with the `Future` API and prevents hanging `get()` calls. No breaking changes.
|
@inonwir Thanks for the contribution. I have some questions about why this change is necessary. If you look at the implementation of What does it mean to "cancel" a callback? It doesn't make sense. |
|
@zackthehuman |
We are working on a research project for improving open-source projects, by using the latest accepted answer from Stack Overflow that matched with your code snippet. We found this recommendation for improving your code from https://stackoverflow.com/questions/2180534.
Note: Our study is approved by the Institutional Review Board of Mahidol University. You can find the participant information sheet explaining this study HERE.
Type of Recommendation: Add Null Check
Reason: Prevent NullPointerException
Type: Bug
Influences: Fix method bytesToHexString (edited)
[10:42]
Type of Recommendation: Add safe cancellation support to FutureCallback
Reason: Prevent hanging get() calls and ensure compliance with Future API
Type: Bug Fix
Influences: Implements cancel(), updates get() to throw CancellationException, and adds proper isCancelled() state handling