help wanted
Description
Hello we are using Finagle as a HttpClient - it works really good. Great job.
Unfortunately Finagle generates resource leak under standard behavior that applications are deployed and undeployed many times on JBoss AS, Tomcat etc. By resource leak I mean that if I 100 times deploy and undeploy an application that uses Finagle I'll get at least 100 threads
The problem is that finagle contains unstopable threads
Problem is withh HighResTimer Thread There is no possibility to stop it using Finagle API.
object HighResTimer {
/**
* The default Timer used for configuration.
*
* It is a shared resource and as such, `stop` is ignored.
*/
val Default: com.twitter.util.Timer =
new JavaTimer(true, Some("HighResTimer")) {
override def stop(): Unit = ()
}
Unfortunately we can't use our own HighResTimer using params because Default is initialized when Http.client is created and there are two instances
/**
* Retries failures that are guaranteed to be safe to retry
* (see [[RetryPolicy.RetryableWriteException]]).
*/
private[finagle] def moduleRequeueable[Req, Rep]: Stackable[ServiceFactory[Req, Rep]] =
new Stack.Module[ServiceFactory[Req, Rep]] {
def role: Stack.Role = Retries.Role
def description: String =
"Retries requests, at the service application level, that have been rejected"
val parameters = Seq(
implicitly[Stack.Param[Stats]],
implicitly[Stack.Param[Budget]],
implicitly[Stack.Param[HighResTimer]]
)
There are two alternative solutions
- possibility to stop this Thread
- Do not instantiate HighResTimer when Client is created