Skip to content

Commit 4cccee7

Browse files
authored
GH-9453: Correct separator when checking smb path
Fixes: #9453 Issue link: #9453 On a smb file upload, to detect the need for new remote directories, the remote path was checked for the local filesystem path separator. On Windows that is \\ which is never found in a smb path, so the necessary remote path was not created and the operation failed. Use the correct separator which was already available as a constant. **Auto-cherry-pick to `6.3.x` & `6.2.x`**
1 parent a6c3a30 commit 4cccee7

File tree

1 file changed

+2
-4
lines changed
  • spring-integration-smb/src/main/java/org/springframework/integration/smb/session

1 file changed

+2
-4
lines changed

spring-integration-smb/src/main/java/org/springframework/integration/smb/session/SmbSession.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.io.InputStream;
2424
import java.io.OutputStream;
2525
import java.net.URL;
26-
import java.nio.file.FileSystems;
2726
import java.util.Arrays;
2827

2928
import jcifs.smb.SmbException;
@@ -54,15 +53,14 @@
5453
* @author Prafull Kumar Soni
5554
* @author Gregory Bragg
5655
* @author Adam Jones
56+
* @author Paolo Fosser
5757
*
5858
* @since 6.0
5959
*/
6060
public class SmbSession implements Session<SmbFile> {
6161

6262
private static final LogAccessor logger = new LogAccessor(SmbSession.class);
6363

64-
private static final String FILE_SEPARATOR = FileSystems.getDefault().getSeparator();
65-
6664
private static final String SMB_FILE_SEPARATOR = "/";
6765

6866
private final SmbShare smbShare;
@@ -338,7 +336,7 @@ public boolean isDirectory(String _path) throws IOException {
338336
* @throws IOException on error conditions returned by a CIFS server
339337
*/
340338
String mkdirs(String _path) throws IOException {
341-
int idxPath = _path.lastIndexOf(FILE_SEPARATOR);
339+
int idxPath = _path.lastIndexOf(SMB_FILE_SEPARATOR);
342340
if (idxPath > -1) {
343341
String path = _path.substring(0, idxPath + 1);
344342
mkdir(path);

0 commit comments

Comments
 (0)