Threads leak with async RESTEasy client calls
Environment
- JBoss Enterprise Application Platform (EAP) 7.2.x
Issue
- After switching our application code to utilize async RESTEasy client calls, we are seeing a continually growing number of threads. The thread names are like 'pool-#-thread-#' so it looks to resemble a leak as described by JBoss EAP has many threads named like "pool-161-thread-20"
Resolution
- Upgrade to EAP 7.3.0+. Here RESTEasy uses a This content is not included.cached thread pool with a max idle time of 60 seconds so any threads can be automatically released in time.
- Instead of creating a new client repeatedly, create it once as a thread safe client and cache and reuse it.
Root Cause
- RESTEasy clients are being repeatedly created and never closed. This creates a new thread pool executor each time, which is leaked and never shutdown Content from github.com is not included.if the client is never closed
Components
Category
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.