New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SftpSession.exists() does not throw exception #3247
Comments
We need to think why is that exception ignored so far because the session contract is:
Meanwhile you can consider a workaround for your use-case like:
So, if an exception is thrown from that |
I think our solution must be like this: https://stackoverflow.com/questions/13202789/how-to-check-directory-is-existed-before-creating-a-new-directory-in-jsch Where a logical answer is present in the comment from Ton Bosma:
Does it make sense? WDYT, @garyrussell ? Thanks |
Even if I treat this as a enhancement I think we need to back-port it to correct a behavior according contract expectations. |
I assume you mean...
Yes, I agree it should be back-ported even though it's a behavior change. |
Yes, sorry, copy/paste artifact. PR is on its way. Stay tuned... |
Fixes spring-projects#3247 When there is no path on the SFTP server, a `ChannelSftp.SSH_FX_NO_SUCH_FILE` error is returned in the thrown `SftpException`. * Fix `SftpSession.exists()` to check for the `SSH_FX_NO_SUCH_FILE` to return `false` and re-throw an exception otherwise * Add mock test for `SftpSession.exists()` * Add `org.mockito.AdditionalMatchers` to `checkstyle.xml` exclusions **Cherry-pick to 5.2.x & 5.1.x**
* GH-3247: Fix `SftpSession.exists` for error code Fixes #3247 When there is no path on the SFTP server, a `ChannelSftp.SSH_FX_NO_SUCH_FILE` error is returned in the thrown `SftpException`. * Fix `SftpSession.exists()` to check for the `SSH_FX_NO_SUCH_FILE` to return `false` and re-throw an exception otherwise * Add mock test for `SftpSession.exists()` * Add `org.mockito.AdditionalMatchers` to `checkstyle.xml` exclusions **Cherry-pick to 5.2.x & 5.1.x** * * Add exists tests against Mina embedded server
* GH-3247: Fix `SftpSession.exists` for error code Fixes #3247 When there is no path on the SFTP server, a `ChannelSftp.SSH_FX_NO_SUCH_FILE` error is returned in the thrown `SftpException`. * Fix `SftpSession.exists()` to check for the `SSH_FX_NO_SUCH_FILE` to return `false` and re-throw an exception otherwise * Add mock test for `SftpSession.exists()` * Add `org.mockito.AdditionalMatchers` to `checkstyle.xml` exclusions **Cherry-pick to 5.2.x & 5.1.x** * * Add exists tests against Mina embedded server
* GH-3247: Fix `SftpSession.exists` for error code Fixes #3247 When there is no path on the SFTP server, a `ChannelSftp.SSH_FX_NO_SUCH_FILE` error is returned in the thrown `SftpException`. * Fix `SftpSession.exists()` to check for the `SSH_FX_NO_SUCH_FILE` to return `false` and re-throw an exception otherwise * Add mock test for `SftpSession.exists()` * Add `org.mockito.AdditionalMatchers` to `checkstyle.xml` exclusions **Cherry-pick to 5.2.x & 5.1.x** * * Add exists tests against Mina embedded server
SftpSession.exists()
method catchesSftpException
but ignores it. Why not throw aNestedIOException
like other methods do?In my code I use
exists
to check whether the remote file exists or not before I callremove
to delete the file. In case when the logic insideexists
throws anIOException
(Pipe closed), it returnsfalse
, indicating the remote file does not exists.Thanks,
Gary
The text was updated successfully, but these errors were encountered: