tor-android
tor-android copied to clipboard
NullPointerException when accessing TorControlConnection too early
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.
By chance, I just stumbled about this unconventional workaround in Orbot.
Appreciate those kinds words.
On Thu, Nov 25, 2021, at 4:20 PM, Torsten Grote wrote:
By chance, I just stumbled about this unconventional workaround in Orbot https://github.com/guardianproject/orbot/blob/8e5cc3a7779d8931d734cb6475fb281fdedae901/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java#L766-L779.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/guardianproject/tor-android/issues/56#issuecomment-979473654, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAHRAZ6IOSH25XJ2WVU2ALUN2SDLANCNFSM5IZCKJ7Q. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.