Synchronize RemoteFileUtils.makeDirectories()

https://stackoverflow.com/questions/55918648

Avoid the race with concurrent threads.

**cherry-pick to 5.x.x, 4.3.x**

(cherry picked from commit 130e1bba31)
This commit is contained in:
Gary Russell
2019-04-30 14:04:50 -04:00
committed by Artem Bilan
parent 05a50fe3a2
commit 34bcd7d60c

View File

@@ -32,7 +32,9 @@ import org.springframework.integration.file.remote.session.Session;
*/
public final class RemoteFileUtils {
private RemoteFileUtils() { }
private RemoteFileUtils() {
super();
}
/**
* Recursively create remote directories.
@@ -43,8 +45,8 @@ public final class RemoteFileUtils {
* @param logger The logger.
* @throws IOException Any IOException.
*/
public static <F> void makeDirectories(String path, Session<F> session, String remoteFileSeparator, Log logger)
throws IOException {
public static synchronized <F> void makeDirectories(String path, Session<F> session, String remoteFileSeparator,
Log logger) throws IOException {
if (!session.exists(path)) {