Files
spring-integration/spring-integration-sftp
Artem Bilan 38fc85a525 Optimize DefaultSftpSessionFactory (#2896)
* Optimize DefaultSftpSessionFactory

Related to https://build.spring.io/browse/INT-MASTERSPRING40-677/

Doesn't look like `DefaultSftpSessionFactory.getSession()` needs
locking around `sharedJschSession`

* change the logic in the `getSession()` to store a `sharedJschSession`
into the local variable and if it is `null` or not connected, create a
new `JSchSessionWrapper`, connect it and store to the `sharedJschSession`
back into the `sharedJschSession` property if `this.isSharedSession`.
This way we always deal with `sharedJschSession` anyway if it is valid
or create a new fresh one if that is invalid.
Without locking we always get an actual state of the `sharedJschSession`
and don't fall into the race condition when `sharedJschSession` is invalid,
but we can't connect to the SFTP channel from the `sftpSession.connect()`

* * Wrap `sharedJschSession` initialization to the lock

* * Store `sharedJschSession` back when it is really fresh and while the lock
2019-04-15 11:41:16 -04:00
..
2016-05-03 11:55:55 -04:00