Fix NPE in the AbstractInboundFileSynchronizer for remote dir
Related to: #9129
The `remoteDirectoryPath` might be `null`, so it is not correct to attempt `remoteDirectoryPath.charAt(0)`.
Plus `/null` is not correct path.
* Use `/` for empty remote dir.
* Check for `remoteDirectoryPath != null`
(cherry picked from commit 467c96171e)
This commit is contained in:
committed by
Spring Builds
parent
f18626fdce
commit
2b9dac0c8f
@@ -444,7 +444,7 @@ public abstract class AbstractInboundFileSynchronizer<F>
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean copyFileToLocalDirectory(String remoteDirectoryPath, // NOSONAR
|
||||
protected boolean copyFileToLocalDirectory(@Nullable String remoteDirectoryPath, // NOSONAR
|
||||
@Nullable EvaluationContext localFileEvaluationContext, F remoteFile, File localDirectory,
|
||||
Session<F> session) throws IOException {
|
||||
|
||||
@@ -503,12 +503,15 @@ public abstract class AbstractInboundFileSynchronizer<F>
|
||||
String host = hostPort.substring(0, colonIndex);
|
||||
String port = hostPort.substring(colonIndex + 1);
|
||||
try {
|
||||
String remoteDir = "/";
|
||||
if (remoteDirectoryPath != null) {
|
||||
remoteDir =
|
||||
remoteDirectoryPath.charAt(0) == '/'
|
||||
? remoteDirectoryPath :
|
||||
'/' + remoteDirectoryPath;
|
||||
}
|
||||
String remoteFileMetadata =
|
||||
new URI(protocol(), null, host, Integer.parseInt(port),
|
||||
remoteDirectoryPath.charAt(0) == '/'
|
||||
? remoteDirectoryPath :
|
||||
'/' + remoteDirectoryPath,
|
||||
null, remoteFileName)
|
||||
new URI(protocol(), null, host, Integer.parseInt(port), remoteDir, null, remoteFileName)
|
||||
.toString();
|
||||
this.remoteFileMetadataStore.put(buildMetadataKey(localFile), remoteFileMetadata);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user