[
https://issues.apache.org/jira/browse/CAMEL-9319?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15005766#comment-15005766
]
Claus Ibsen edited comment on CAMEL-9319 at 11/15/15 7:05 AM:
--------------------------------------------------------------
[~ancosen] do you want to give this a try?
The client should be moved to the consumer / producer so its not stored on the
endpoint
https://github.com/apache/camel/blob/master/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshEndpoint.java#L47
And the endpoint should be singleton=true
https://github.com/apache/camel/blob/master/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshEndpoint.java#L78
The sendExecCommand can likely be moved to a SshHelper method as a public
static and take in the client as parameter, then the producer/consumer can
reuse it
https://github.com/apache/camel/blob/master/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshEndpoint.java#L81
That means we can keep the endpoint nice and simple as it should.
And double check in the sendExecCommand that all the resources are closed
properly, eg as those memory/thread leaks reported in the SO link.
was (Author: davsclaus):
[~ancosen] do you want to give this a try?
The client should be moved to the consumer / producer so its not stored on the
exchange
https://github.com/apache/camel/blob/master/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshEndpoint.java#L47
And the endpoint should be singleton=true
https://github.com/apache/camel/blob/master/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshEndpoint.java#L78
The sendExecCommand can likely be moved to a SshHelper method as a public
static and take in the client as parameter, then the producer/consumer can
reuse it
https://github.com/apache/camel/blob/master/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshEndpoint.java#L81
That means we can keep the endpoint nice and simple as it should.
And double check in the sendExecCommand that all the resources are closed
properly, eg as those memory/thread leaks reported in the SO link.
> SshClient resource leak when used from ProducerTemplate
> -------------------------------------------------------
>
> Key: CAMEL-9319
> URL: https://issues.apache.org/jira/browse/CAMEL-9319
> Project: Camel
> Issue Type: Bug
> Components: camel-ssh
> Affects Versions: 2.16.0, 2.15.4
> Environment: Any OS, any hardware, tested with Spring-Boot.
> Reporter: Daniel Gruszczyk
> Priority: Minor
> Fix For: 2.16.2, 2.17.0
>
>
> When using ProducerTemplate for execution of an ssh command (i.e.
> {{producerTemplate.requestBody("ssh://...", String.class)}}), 11 threads are
> being created, that are never killed. Any subsequent calls create new
> threads, eventually this exhausts memory and thread resources on the machine.
> These threads are not being killed even when explicitly stopping the
> ProducerTemplate.
> Here is a more detailed discussion, together with profiler results and code
> to reproduce the issue:
> http://stackoverflow.com/questions/33671567/spring-boot-camel-producertemplate-thousands-of-threads
> http://camel.465427.n5.nabble.com/Spring-Boot-Camel-producerTemplate-ssh-spawning-thousands-of-threads-td5773741.html
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)