Skip to content

Commit 43cb484

Browse files
garyrussellartembilan
authored andcommitted
GH-3620: Fix Shared SFTP Session
Resolves #3620 Shared session field was captured outside of the lock, causing multiple sessions in a multi-threaded environment. **cherry-pick to 5.4.x, 5.3.x**
1 parent e37cdcd commit 43cb484

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -382,11 +382,11 @@ public void setChannelConnectTimeout(Duration timeout) {
382382

383383
@Override
384384
public SftpSession getSession() {
385-
JSchSessionWrapper jschSession = this.sharedJschSession;
386385
SftpSession sftpSession;
387386
if (this.sharedSessionLock != null) {
388387
this.sharedSessionLock.lock();
389388
}
389+
JSchSessionWrapper jschSession = this.sharedJschSession;
390390
try {
391391
boolean freshJschSession = false;
392392
if (jschSession == null || !jschSession.isConnected()) {

0 commit comments

Comments
 (0)