Actually, I'm not sure yet how it is better to work with `locks`, but according to the `ReentrantReadWriteLock` JavaDocs, here is a polishing: https://github.com/artembilan/spring-integration/commit/f32cbbd87cc1faeb845980d6887a35dc75a6d3f8
Doug Lea suggests to use `Write lock downgrade algorithm` for similar cases.

BTW, JIRA has this comment:
> Also would need a mechanism to close the session (when quiescent) to handle credential changes.

As I understand we should reset `this.sharedJschSession = null`, when new `password` or `privateKey` are provided. Right?