Skip to content

Check NetworkRequest#mDestroyed before each network request? #563

Open

Description

@stefan-niedermann

I recently ran into an issue while trying to make a network request on an NextcloudAPI instance, on which I called close() before.

Of course, it failed, but at an odd place, that I didn't expected (I think context was null at some place).

This made me wondering why we do check for NetworkRequest#mDestroyed when connecting, but not before each request. Wouldn't make it sense to add this check also at the beginning of AidlNetworkRequest#performNetworkRequestV2 and throw a more meaningful IllegalStateException or something alike?

cc @David-Development

Activity

  1. David-Development commented on May 29, 2023

    @David-Development
    Member

    Yes, that makes perfect sense to me. Would for sure improve error handling a lot (and make it easier for devs to find the error in case something goes wrong).

  2. Abhijeet-035 commented on Sep 6, 2026

    @Abhijeet-035

    Hi @David-Development, @stefan-niedermann! I’d like to work on this issue.

    My current understanding is that NetworkRequest#connect() already checks mDestroyed, but a request through AidlNetworkRequest#performNetworkRequestV2() can still be attempted after close(). Since close() marks the API as destroyed and clears its state, this can result in an unrelated exception instead of clearly indicating that the API can no longer be used.

    I’m planning to add an mDestroyed check at the beginning of performNetworkRequestV2() and throw a meaningful IllegalStateException.

    If this approach sounds good, I’d be happy to work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions