gnodet-bot commented on code in PR #30483:
URL: https://github.com/apache/camel/pull/30483#discussion_r4665727915
##########
components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpExistsFileIT.java:
##########
@@ -369,6 +370,17 @@ public LinkOption[] resolveFileAccessLinkOptions(
return
SftpFileSystemAccessor.super.resolveFileAccessLinkOptions(
subsystem, file, cmd, extension, followLinks);
}
+
+ @Override
+ public Path resolveLocalFilePath(
+ SftpSubsystemProxy subsystem, Path rootDir, String
remotePath)
+ throws IOException {
+ // The noop sends channel.realpath("."), so the server
receives remotePath="."
+ if (".".equals(remotePath)) {
+ noopRealpathCount.incrementAndGet();
+ }
+ return
SftpFileSystemAccessor.super.resolveLocalFilePath(subsystem, rootDir,
remotePath);
+ }
Review Comment:
🐛 **Bug: `noopRealpath()` counter never fires.**
JSch's `channel.realpath(".")` calls `remoteAbsolutePath(".")` before
writing the SFTP packet (confirmed in jsch-2.28.8 bytecode: `realpath`
instruction 3 is `invokespecial remoteAbsolutePath`). The server receives
`"/sendnoop/."`, not `"."`. `".".equals(remotePath)` is always false,
`noopRealpathCount` stays at 0, and `testSendNoopDefault` fails its
`assertTrue(noopRealpath() > 0)` assertion.
Fix: check the suffix. `cd()` calls also absolutize but produce paths like
`"/sendnoop"` (no trailing `"/."`), so they won't match.
```suggestion
@Override
public Path resolveLocalFilePath(
SftpSubsystemProxy subsystem, Path rootDir, String
remotePath)
throws IOException {
// JSch prepends cwd, so realpath(".") arrives as
"/dir/." not "."; check suffix.
if (".".equals(remotePath) || remotePath.endsWith("/."))
{
noopRealpathCount.incrementAndGet();
}
return
SftpFileSystemAccessor.super.resolveLocalFilePath(subsystem, rootDir,
remotePath);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]