What version of gRPC-Java are you using?
latest
What is your environment?
Android/Linux
Steps to reproduce the bug
- Call BinderChannelBuilder.forAddress() on a directAddress whose package or Service class name doesn't exist.
- Send a request over the new Channel to activate it.
- Observe the request fail with UNIMPLEMENTED as expected.
- shutdown() the Channel and awaitTermination()
What did you expect to see?
No remaining Java references to Channel related resources.
What did you see instead?
Heap dump shows a strong reference to the ServiceBinding in android.app.LoadedApk#mServices (as a ServiceConnection) even after termination.
The problem is that ServiceBinding fails to call Context#unbindService() when bindService() returns false. (See b/37092557 for discussion / longstanding confusion on when to call unbindService())