| Steps to reproduce: Use one of the examples on the https://extensions.xwiki.org/xwiki/bin/view/Extension/JIRA/JIRA%20Module#HExamples and call them several times while taking a thread dump of XWiki's Java process in between. Expected result: The number of threads named "httpclient-io:thread-1" and "I/O dispatcher" doesn't grow. Actual result: Every time a client is retrieved, one thread named httpclient-io:thread-1 and ten threads named I/O dispatcher followed by a continuously increasing number are created. In the thread dump, you can see the following stack traces for them:
After some time, this exhausts the number of threads that are available from the operating system and will bring the XWiki instance down. As a workaround, it is possible to call close() on the returned REST client which terminates the started threads again. In Groovy, a try-with-resource block can be used to automatically close the client. While this could be considered a best practice, it feels too easy to miss and I think it would actually be much better for performance if all clients could share a single connection pool instead of starting a new one for every client. |