Skip to content

RequestFuture#get blocks forever if an in-flight request is cancelled #85

Open
@jpd236

Description

@jpd236

RequestFuture#get waits for either onResponse or onErrorResponse to be called before attempting to return a result. However, if a request is cancelled, by design, neither callback will be executed. This means get() will block forever (or until the user-specified timeout, if one is given).

Proposal to fix:

  • Add an optional CancelListener that can be set on a request
  • Have cancel() only set mCanceled = true when called from the main thread, and queue a runnable to do so otherwise
  • Call the cancel listener when setting mCanceled = true (on the main thread)
  • Have RequestFuture implement CancelListener and set itself as the listener in setRequest, and call notify() in the listener.
  • Ensure we use setRequest everywhere we use RequestFuture so it is cancellable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions