You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Goldstein Lyor (JIRA)" <ji...@apache.org> on 2015/03/01 10:30:04 UTC

[jira] [Updated] (SSHD-426) Fix SftpTest#testOpen code to take into account Windows behavior

     [ https://issues.apache.org/jira/browse/SSHD-426?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Goldstein Lyor updated SSHD-426:
--------------------------------
    Attachment: 0029-SSHD-426-Fix-SftpTest-testOpen-code-to-take-into-acc.patch

Attached recommended patch. *Note:* I also modified _SftpClient#open_ method to accept a _Collection_ of options instead of an _EnumSet_ since we don't really care if there are repeated options in it.

> Fix SftpTest#testOpen code to take into account Windows behavior
> ----------------------------------------------------------------
>
>                 Key: SSHD-426
>                 URL: https://issues.apache.org/jira/browse/SSHD-426
>             Project: MINA SSHD
>          Issue Type: Bug
>    Affects Versions: 1.0.0
>            Reporter: Goldstein Lyor
>            Priority: Minor
>         Attachments: 0029-SSHD-426-Fix-SftpTest-testOpen-code-to-take-into-acc.patch
>
>
> The problem with the truncate option lies in the new Java 7 code for _FileHandle_ constructor:
> {code:java}
> channel = FileChannel.open(file, options, attributes);
> {code}
> When the _SftpClient#open_ code passes only the _Truncate_ option, this is translated to a _Set_ of options that contains only the _StandardOpenOption.TRUNCATE_EXISTING_ value. According to the [_FileChannel#open_ Javadoc|http://docs.oracle.com/javase/7/docs/api/java/nio/channels/FileChannel.html#open(java.nio.file.Path,%20java.util.Set,%20java.nio.file.attribute.FileAttribute...)]:
> {panel}
> If neither READ / WRITE option (or the APPEND option) is contained in the array then the file is opened for reading.
> {panel}
> Therefore, in our case, on _Windows_ an attempt will be made to open the file for READ (and TRUNCATE, but that's besides the point). Since in _Windows_ this always succeeds (files are always readable), the test fails the _"Empty truncate should have failed"_ assertion.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)