Skip to content

NullPointerException when accessing TorControlConnection too early #56

Open

Description

@grote

When a user of TorService starts and binds to the service, then (as documented) tries to use the TorControlConnection, it can happen that it hasn't been assigned and a NullPointerException is thrown. This is because the TorControlConnection gets only assigned in another thread after doing some extra work.

How is a user of the library supposed to know when the control connection becomes available? Are they expected to register a broadcast receiver and wait for the TorService.STATUS_ON event? That would be quite a cumbersome, but possible solution. If it is that, it should at least get documented.

Activity

  1. grote commented on Nov 25, 2021

    @grote
    ContributorAuthor

    By chance, I just stumbled about this unconventional workaround in Orbot.

  2. n8fr8 commented on Nov 26, 2021

    @n8fr8
    Member
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