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` **Auto-cherry-pick to `6.2.x` & `6.1.x`**