GH-3370: Remove synchronized from RemoteFileUtils (#3380)
* GH-3370: Remove synchronized from RemoteFileUtils Fixes https://github.com/spring-projects/spring-integration/issues/3370 The `synchronized` on the `RemoteFileUtils.makeDirectories()` makes an application too slow, especially when we deal with different paths in different sessions * Remove the `synchronized` from that method and rework `SftpSession.mkdir()` to return `false` when "A file cannot be created if it already exists" exception is thrown from the server. Essentially make an `exists()` call to be sure that an exception is really related to "file-already-exists" answer from the server **Cherry-pick to 5.3.x, 5.2.x & 4.3.x** * * Re-throw an exception in the `SftpSession.mkdir()` when error code is not `4` or remote dir does not exist * * Check `session.mkdir()` result in the `RemoteFileUtils` to throw an `IOException` when `false` * * Fix mock test to return `true` for `mkdir` instead of `null`
This commit is contained in:
@@ -219,7 +219,7 @@ public class SftpOutboundTests {
|
||||
final List<String> madeDirs = new ArrayList<>();
|
||||
doAnswer(invocation -> {
|
||||
madeDirs.add(invocation.getArgument(0));
|
||||
return null;
|
||||
return true;
|
||||
}).when(session).mkdir(anyString());
|
||||
handler.handleMessage(new GenericMessage<>("qux"));
|
||||
assertThat(madeDirs.size()).isEqualTo(3);
|
||||
|
||||
Reference in New Issue
Block a user