guardianproject / guardianproject/tor-android

NullPointerException when accessing TorControlConnection too early

Open
#56 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
286
Forks
79
PR merge metrics
No merged PRs in 30d

Description

When a user of `TorService` starts and binds to the service, then ([as documented](https://github.com/guardianproject/tor-android/blob/c5d5b2c00876cbf2e697668dd14ff6021ea18c7b/tor-android-binary/src/main/java/org/torproject/jni/TorService.java#L34)) 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](https://github.com/guardianproject/tor-android/blob/c5d5b2c00876cbf2e697668dd14ff6021ea18c7b/tor-android-binary/src/main/java/org/torproject/jni/TorService.java#L262).

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.