-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
INT-4175: Fix SftpSessionFactory Race Condition
JIRA: https://jira.spring.io/browse/INT-4175 Fixes GH-1980 (#1980) When the `isSharedSession` is used for the `DefaultSftpSessionFactory`, there is some race condition window when we can call the target `this.jschSession.connect()` several times and end up with the session is already connected. Wrap `sftpSession.connect()` to the `this.sharedSessionLock.readLock().lock()` when `isSharedSession` to protect from that race condition. Note: there is no test for this change because it is pretty tricky to build barriers between threads for this kind of race conditions. Especially after introduction `this.sharedSessionLock.readLock().lock()` around guilty code **Cherry-pick to 4.3.x & 4.2.x** Move `sharedJschSession` connect logic to the existing locking block Fix mock test to reflect the current ConnectionFactory state Conflicts: spring-integration-sftp/src/test/java/org/springframework/integration/sftp/outbound/SftpOutboundTests.java Resolved.
- Loading branch information
1 parent
2ac5ac0
commit 5485962
Showing
2 changed files
with
45 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters