I am using RestTemplate from spring-android-rest-template 1.0.0.M4, which I construct on demand using
Unfortunately, both constructors are leaking threads whose lifetime exceeds that of the respective RestTemplate instance as HttpAccessor has a private field that initializes a new HttpComponentsClientHttpRequestFactory anyway:
new RestTemplate(new SimpleClientHttpRequestFactory());
The spawned threads (one per RestTemplate instance) look like this:
private ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
The threads are cleaned up in a finalizer, but given a sufficient amount of RestTemplate creations, the application will still crash due to a depletion of resources.
Daemon Thread [<17> RefQueueWorker@org.apache.http.impl.conn.tsccm.ConnPoolByRoute@44eb3ce8] (Running)