Goldstein Lyor created SSHD-426:
-----------------------------------

             Summary: 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


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)

Reply via email to